001    // SECTION-START[License Header]
002    // <editor-fold defaultstate="collapsed" desc=" Generated License ">
003    /*
004     *   Java Object Management and Configuration
005     *   Copyright (C) Christian Schulte, 2005-206
006     *   All rights reserved.
007     *
008     *   Redistribution and use in source and binary forms, with or without
009     *   modification, are permitted provided that the following conditions
010     *   are met:
011     *
012     *     o Redistributions of source code must retain the above copyright
013     *       notice, this list of conditions and the following disclaimer.
014     *
015     *     o Redistributions in binary form must reproduce the above copyright
016     *       notice, this list of conditions and the following disclaimer in
017     *       the documentation and/or other materials provided with the
018     *       distribution.
019     *
020     *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
021     *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
022     *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
023     *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
024     *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
025     *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
026     *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
027     *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028     *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
029     *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030     *
031     *   $JOMC: Command.java 4511 2012-04-24 01:59:23Z schulte2005 $
032     *
033     */
034    // </editor-fold>
035    // SECTION-END
036    package org.jomc.cli;
037    
038    import java.util.List;
039    import java.util.Locale;
040    import java.util.logging.Level;
041    import org.apache.commons.cli.CommandLine;
042    import org.apache.commons.cli.Options;
043    
044    // SECTION-START[Documentation]
045    // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
046    /**
047     * Command.
048     *
049     * <dl>
050     *   <dt><b>Identifier:</b></dt><dd>JOMC CLI Command</dd>
051     *   <dt><b>Multiplicity:</b></dt><dd>Many</dd>
052     *   <dt><b>Scope:</b></dt><dd>None</dd>
053     * </dl>
054     *
055     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
056     * @version 1.0
057     * @see org.jomc.ObjectManager#getObject(java.lang.Class) getObject(Command[].class)
058     * @see org.jomc.ObjectManager#getObject(java.lang.Class,java.lang.String) getObject(Command.class, "<i>implementation name</i>")
059     * @see org.jomc.ObjectManagerFactory
060     */
061    // </editor-fold>
062    // SECTION-END
063    // SECTION-START[Annotations]
064    // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
065    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.3", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.3" )
066    // </editor-fold>
067    // SECTION-END
068    public interface Command
069    {
070        // SECTION-START[Command]
071    
072        /** Listener interface. */
073        public interface Listener
074        {
075    
076            /**
077             * Gets called on logging.
078             *
079             * @param level The level of the event.
080             * @param message The message of the event or {@code null}.
081             * @param t The throwable of the event or {@code null}.
082             *
083             * @throws NullPointerException if {@code level} is {@code null}.
084             */
085            void onLog( Level level, String message, Throwable t );
086    
087        }
088    
089        /** Status code when the command completed successfully. */
090        int STATUS_SUCCESS = 0;
091    
092        /** Status code when the command failed. */
093        int STATUS_FAILURE = 1;
094    
095        /**
096         * Gets the list of registered listeners.
097         *
098         * @return The list of registered listeners.
099         */
100        List<Listener> getListeners();
101    
102        /**
103         * Gets the log level of the instance.
104         *
105         * @return The log level of the instance.
106         *
107         * @see #setLogLevel(java.util.logging.Level)
108         */
109        Level getLogLevel();
110    
111        /**
112         * Sets the log level of the instance.
113         *
114         * @param value The new log level of the instance or {@code null}.
115         *
116         * @see #getLogLevel()
117         */
118        void setLogLevel( Level value );
119    
120        /**
121         * Gets the name of the command.
122         *
123         * @return The name of the command.
124         */
125        String getName();
126    
127        /**
128         * Gets the abbreviated name of the command.
129         *
130         * @return The abbreviated  name of the command.
131         */
132        String getAbbreviatedName();
133    
134        /**
135         * Gets the short description of the command.
136         *
137         * @param locale The locale of the short description to return.
138         *
139         * @return The short description of the command.
140         *
141         * @throws NullPointerException if {@code locale} is {@code null}.
142         */
143        String getShortDescription( Locale locale ) throws NullPointerException;
144    
145        /**
146         * Gets the long description of the command.
147         *
148         * @param locale The locale of the long description to return.
149         *
150         * @return The long description of the command.
151         *
152         * @throws NullPointerException if {@code locale} is {@code null}.
153         */
154        String getLongDescription( Locale locale ) throws NullPointerException;
155    
156        /**
157         * Gets the options of the command.
158         *
159         * @return The options of the command.
160         */
161        Options getOptions();
162    
163        /**
164         * Executes the command.
165         *
166         * @param commandLine Command line to execute.
167         *
168         * @return The status code to report.
169         *
170         * @throws NullPointerException if {@code commandLine} is {@code null}.
171         *
172         * @see #STATUS_SUCCESS
173         * @see #STATUS_FAILURE
174         */
175        int execute( CommandLine commandLine ) throws NullPointerException;
176    
177        // SECTION-END
178    }