001    // SECTION-START[License Header]
002    // <editor-fold defaultstate="collapsed" desc=" Generated License ">
003    /*
004     *   Copyright (c) 2009 The JOMC Project
005     *   Copyright (c) 2005 Christian Schulte <cs@jomc.org>
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 BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS"
021     *   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
022     *   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
023     *   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR
024     *   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025     *   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026     *   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
027     *   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
028     *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
029     *   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
030     *   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031     *
032     *   $Id: Jomc.java 1102 2009-12-07 03:01:58Z schulte2005 $
033     *
034     */
035    // </editor-fold>
036    // SECTION-END
037    package org.jomc.cli;
038    
039    import java.io.BufferedReader;
040    import java.io.IOException;
041    import java.io.PrintWriter;
042    import java.io.StringReader;
043    import java.io.StringWriter;
044    import java.util.logging.Level;
045    import org.apache.commons.cli.CommandLine;
046    import org.apache.commons.cli.GnuParser;
047    import org.apache.commons.cli.HelpFormatter;
048    import org.apache.commons.cli.Option;
049    import org.apache.commons.cli.Options;
050    import org.apache.commons.cli.ParseException;
051    import org.apache.commons.lang.StringUtils;
052    import org.jomc.model.DefaultModelManager;
053    
054    // SECTION-START[Documentation]
055    // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
056    /**
057     * JOMC command line interface.
058     * <p><b>Properties</b><ul>
059     * <li>"{@link #getDebugOptionLongName debugOptionLongName}"
060     * <blockquote>Property of type {@code java.lang.String}.
061     * <p>Long name of the 'debug' option.</p>
062     * </blockquote></li>
063     * <li>"{@link #getDebugOptionShortName debugOptionShortName}"
064     * <blockquote>Property of type {@code java.lang.String}.
065     * <p>Name of the 'debug' option.</p>
066     * </blockquote></li>
067     * <li>"{@link #getDescPad descPad}"
068     * <blockquote>Property of type {@code int}.
069     * <p>The number of characters of padding to be prefixed to each description line.</p>
070     * </blockquote></li>
071     * <li>"{@link #getFailOnWarningsOptionLongName failOnWarningsOptionLongName}"
072     * <blockquote>Property of type {@code java.lang.String}.
073     * <p>Long name of the 'fail-on-warnings' option.</p>
074     * </blockquote></li>
075     * <li>"{@link #getFailOnWarningsOptionShortName failOnWarningsOptionShortName}"
076     * <blockquote>Property of type {@code java.lang.String}.
077     * <p>Name of the 'fail-on-warnings' option.</p>
078     * </blockquote></li>
079     * <li>"{@link #getHelpCommandName helpCommandName}"
080     * <blockquote>Property of type {@code java.lang.String}.
081     * <p>The name of the command used to request help.</p>
082     * </blockquote></li>
083     * <li>"{@link #getLeftPad leftPad}"
084     * <blockquote>Property of type {@code int}.
085     * <p>The number of characters of padding to be prefixed to each line.</p>
086     * </blockquote></li>
087     * <li>"{@link #getVerboseOptionLongName verboseOptionLongName}"
088     * <blockquote>Property of type {@code java.lang.String}.
089     * <p>Long name of the 'verbose' option.</p>
090     * </blockquote></li>
091     * <li>"{@link #getVerboseOptionShortName verboseOptionShortName}"
092     * <blockquote>Property of type {@code java.lang.String}.
093     * <p>Name of the 'verbose' option.</p>
094     * </blockquote></li>
095     * <li>"{@link #getWidth width}"
096     * <blockquote>Property of type {@code int}.
097     * <p>The number of characters per line for the usage statement.</p>
098     * </blockquote></li>
099     * </ul></p>
100     * <p><b>Dependencies</b><ul>
101     * <li>"{@link #getCommands Commands}"<blockquote>
102     * Dependency on {@code org.jomc.cli.Command} at specification level 1.0-alpha-11.</blockquote></li>
103     * <li>"{@link #getLocale Locale}"<blockquote>
104     * Dependency on {@code java.util.Locale} at specification level 1.1 bound to an instance.</blockquote></li>
105     * </ul></p>
106     * <p><b>Messages</b><ul>
107     * <li>"{@link #getCommandLineInfoMessage commandLineInfo}"<table>
108     * <tr><td valign="top">English:</td><td valign="top"><pre>Command line:
109     * {0}</pre></td></tr>
110     * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Kommandozeile:
111     * {0}</pre></td></tr>
112     * </table>
113     * <li>"{@link #getDebugOptionMessage debugOption}"<table>
114     * <tr><td valign="top">English:</td><td valign="top"><pre>Enables debug output.</pre></td></tr>
115     * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Aktiviert Diagnose-Ausgaben.</pre></td></tr>
116     * </table>
117     * <li>"{@link #getFailOnWarningsOptionMessage failOnWarningsOption}"<table>
118     * <tr><td valign="top">English:</td><td valign="top"><pre>Exit with failure on warnings.</pre></td></tr>
119     * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Bei Warnungen Fehler melden.</pre></td></tr>
120     * </table>
121     * <li>"{@link #getIllegalArgumentsMessage illegalArguments}"<table>
122     * <tr><td valign="top">English:</td><td valign="top"><pre>Illegal arguments. Type &raquo;jomc {0} {1}&laquo; for further information.</pre></td></tr>
123     * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Ung&uuml;ltige Argumente. Geben Sie &raquo;jomc {0} {1}&laquo; f&uuml;r weitere Informationen ein.</pre></td></tr>
124     * </table>
125     * <li>"{@link #getUsageMessage usage}"<table>
126     * <tr><td valign="top">English:</td><td valign="top"><pre>Type &raquo;jomc &lt;command&gt; {0}&laquo; for further information.</pre></td></tr>
127     * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Geben Sie &raquo;jomc &lt;Befehl&gt; {0}&laquo; f&uuml;r weitere Informationen ein.</pre></td></tr>
128     * </table>
129     * <li>"{@link #getVerboseOptionMessage verboseOption}"<table>
130     * <tr><td valign="top">English:</td><td valign="top"><pre>Enables verbose output.</pre></td></tr>
131     * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Aktiviert ausf&uuml;hrliche Ausgaben.</pre></td></tr>
132     * </table>
133     * </ul></p>
134     *
135     * @author <a href="mailto:cs@jomc.org">Christian Schulte</a> 1.0
136     * @version $Id: Jomc.java 1102 2009-12-07 03:01:58Z schulte2005 $
137     */
138    // </editor-fold>
139    // SECTION-END
140    // SECTION-START[Annotations]
141    // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
142    @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
143                                 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
144    // </editor-fold>
145    // SECTION-END
146    public class Jomc
147    {
148        // SECTION-START[Jomc]
149    
150        /**
151         * Log level events are logged at by default.
152         * @see #getDefaultLogLevel()
153         */
154        private static final Level DEFAULT_LOG_LEVEL = Level.WARNING;
155    
156        /** Default log level. */
157        private static volatile Level defaultLogLevel;
158    
159        /** 'verbose' option of the instance. */
160        private Option verboseOption;
161    
162        /** 'debug' option of the instance. */
163        private Option debugOption;
164    
165        /** 'fail-on-warnings' option of the instance. */
166        private Option failOnWarningsOption;
167    
168        /** Print writer of the instance. */
169        private PrintWriter printWriter;
170    
171        /** Log level of the instance. */
172        private Level logLevel;
173    
174        /** Greatest severity logged by the command. */
175        private Level severity = Level.ALL;
176    
177        /**
178         * Gets the print writer of the instance.
179         *
180         * @return The print writer of the instance.
181         */
182        public PrintWriter getPrintWriter()
183        {
184            if ( this.printWriter == null )
185            {
186                this.printWriter = new PrintWriter( System.out, true );
187            }
188    
189            return this.printWriter;
190        }
191    
192        /**
193         * Sets the print writer of the instance.
194         *
195         * @param value The new print writer of the instance or {@code null}.
196         */
197        public void setPrintWriter( final PrintWriter value )
198        {
199            this.printWriter = value;
200        }
201    
202        /**
203         * Gets the default log level events are logged at.
204         * <p>The default log level is controlled by system property {@code org.jomc.cli.Jomc.defaultLogLevel} holding the
205         * log level to log events at by default. If that property is not set, the {@code WARNING} default is returned.</p>
206         *
207         * @return The log level events are logged at by default.
208         *
209         * @see #getLogLevel()
210         * @see Level#parse(java.lang.String)
211         */
212        public static Level getDefaultLogLevel()
213        {
214            if ( defaultLogLevel == null )
215            {
216                defaultLogLevel = Level.parse( System.getProperty(
217                    "org.jomc.cli.Jomc.defaultLogLevel", DEFAULT_LOG_LEVEL.getName() ) );
218    
219            }
220    
221            return defaultLogLevel;
222        }
223    
224        /**
225         * Sets the default log level events are logged at.
226         *
227         * @param value The new default level events are logged at or {@code null}.
228         *
229         * @see #getDefaultLogLevel()
230         */
231        public static void setDefaultLogLevel( final Level value )
232        {
233            defaultLogLevel = value;
234        }
235    
236        /**
237         * Gets the log level of the instance.
238         *
239         * @return The log level of the instance.
240         *
241         * @see #getDefaultLogLevel()
242         * @see #setLogLevel(java.util.logging.Level)
243         * @see #isLoggable(java.util.logging.Level)
244         */
245        public Level getLogLevel()
246        {
247            if ( this.logLevel == null )
248            {
249                this.logLevel = getDefaultLogLevel();
250            }
251    
252            return this.logLevel;
253        }
254    
255        /**
256         * Sets the log level of the instance.
257         *
258         * @param value The new log level of the instance or {@code null}.
259         *
260         * @see #getLogLevel()
261         * @see #isLoggable(java.util.logging.Level)
262         */
263        public void setLogLevel( final Level value )
264        {
265            this.logLevel = value;
266        }
267    
268        /**
269         * Checks if a message at a given level is provided to the listeners of the instance.
270         *
271         * @param level The level to test.
272         *
273         * @return {@code true} if messages at {@code level} are provided to the listeners of the instance;
274         * {@code false} if messages at {@code level} are not provided to the listeners of the instance.
275         *
276         * @throws NullPointerException if {@code level} is {@code null}.
277         *
278         * @see #getLogLevel()
279         * @see #setLogLevel(java.util.logging.Level)
280         */
281        public boolean isLoggable( final Level level )
282        {
283            if ( level == null )
284            {
285                throw new NullPointerException( "level" );
286            }
287    
288            return level.intValue() >= this.getLogLevel().intValue();
289        }
290    
291        public Option getVerboseOption()
292        {
293            if ( this.verboseOption == null )
294            {
295                this.verboseOption = new Option( this.getVerboseOptionShortName(), this.getVerboseOptionLongName(),
296                                                 false, this.getVerboseOptionMessage( this.getLocale() ) );
297    
298            }
299    
300            return this.verboseOption;
301        }
302    
303        public Option getDebugOption()
304        {
305            if ( this.debugOption == null )
306            {
307                this.debugOption = new Option( this.getDebugOptionShortName(), this.getDebugOptionLongName(),
308                                               false, this.getDebugOptionMessage( this.getLocale() ) );
309    
310            }
311    
312            return this.debugOption;
313        }
314    
315        public Option getFailOnWarningsOption()
316        {
317            if ( this.failOnWarningsOption == null )
318            {
319                this.failOnWarningsOption = new Option( this.getFailOnWarningsOptionShortName(),
320                                                        this.getFailOnWarningsOptionLongName(),
321                                                        false, this.getFailOnWarningsOptionMessage( this.getLocale() ) );
322    
323            }
324    
325            return this.failOnWarningsOption;
326        }
327    
328        /**
329         * Processes the given arguments and executes the corresponding command.
330         *
331         * @param args Arguments to process.
332         *
333         * @return Status code.
334         *
335         * @see Command#STATUS_SUCCESS
336         * @see Command#STATUS_FAILURE
337         */
338        public int jomc( final String[] args )
339        {
340            Command cmd = null;
341            this.severity = Level.ALL;
342    
343            try
344            {
345                DefaultModelManager.setDefaultModuleLocation( "META-INF/jomc-cli.xml" );
346                DefaultModelManager.setDefaultSchemaLocation( "META-INF/jomc-bootstrap.xml" );
347                DefaultModelManager.setDefaultTransformerLocation( "META-INF/jomc-cli.xslt" );
348    
349                final StringBuilder commandInfo = new StringBuilder();
350    
351                for ( Command c : this.getCommands() )
352                {
353                    if ( cmd == null && args != null && args.length > 0 &&
354                         ( args[0].equals( c.getName() ) || args[0].equals( c.getAbbreviatedName() ) ) )
355                    {
356                        cmd = c;
357                    }
358    
359                    commandInfo.append( StringUtils.rightPad( c.getName(), 25 ) ).append( " : " ).
360                        append( c.getShortDescription( this.getLocale() ) ).append( " (" ).append( c.getAbbreviatedName() ).
361                        append( ")" ).append( System.getProperty( "line.separator" ) );
362    
363                }
364    
365                if ( cmd == null )
366                {
367                    this.getPrintWriter().println( this.getUsageMessage( this.getLocale(), this.getHelpCommandName() ) );
368                    this.getPrintWriter().println();
369                    this.getPrintWriter().println( commandInfo.toString() );
370                    return Command.STATUS_FAILURE;
371                }
372    
373                final String[] commandArguments = new String[ args.length - 1 ];
374                System.arraycopy( args, 1, commandArguments, 0, commandArguments.length );
375    
376                if ( commandArguments.length > 0 && this.getHelpCommandName().equals( commandArguments[0] ) )
377                {
378                    final StringWriter usage = new StringWriter();
379                    final StringWriter opts = new StringWriter();
380                    final HelpFormatter formatter = new HelpFormatter();
381                    final Options options = cmd.getOptions();
382                    options.addOption( this.getDebugOption() );
383                    options.addOption( this.getVerboseOption() );
384                    options.addOption( this.getFailOnWarningsOption() );
385    
386                    PrintWriter pw = new PrintWriter( usage );
387                    formatter.printUsage( pw, this.getWidth(), cmd.getName(), options );
388                    pw.close();
389    
390                    pw = new PrintWriter( opts );
391                    formatter.printOptions( pw, this.getWidth(), options, this.getLeftPad(), this.getDescPad() );
392                    pw.close();
393    
394                    this.getPrintWriter().println( cmd.getShortDescription( this.getLocale() ) );
395                    this.getPrintWriter().println();
396                    this.getPrintWriter().println( usage.toString() );
397                    this.getPrintWriter().println( opts.toString() );
398                    this.getPrintWriter().println();
399                    this.getPrintWriter().println( cmd.getLongDescription( this.getLocale() ) );
400                    this.getPrintWriter().println();
401                    return Command.STATUS_SUCCESS;
402                }
403    
404                cmd.getListeners().add( new Command.Listener()
405                {
406    
407                    public void onLog( final Level level, final String message, final Throwable t )
408                    {
409                        log( level, message, t );
410                    }
411    
412                } );
413    
414                DefaultModelManager.setDefaultModuleLocation( null );
415                DefaultModelManager.setDefaultSchemaLocation( null );
416                DefaultModelManager.setDefaultTransformerLocation( null );
417    
418                final Options options = cmd.getOptions();
419                options.addOption( this.getDebugOption() );
420                options.addOption( this.getVerboseOption() );
421                options.addOption( this.getFailOnWarningsOption() );
422    
423                final CommandLine commandLine = new GnuParser().parse( options, commandArguments );
424                final boolean debug = commandLine.hasOption( this.getDebugOption().getOpt() );
425                final boolean verbose = commandLine.hasOption( this.getVerboseOption().getOpt() );
426    
427                if ( debug || verbose )
428                {
429                    this.setLogLevel( debug ? Level.ALL : Level.INFO );
430                }
431    
432                cmd.setLogLevel( this.getLogLevel() );
433    
434                if ( this.isLoggable( Level.FINE ) )
435                {
436                    final StringBuilder argumentInfo = new StringBuilder();
437    
438                    for ( int i = 0; i < args.length; i++ )
439                    {
440                        argumentInfo.append( "\t[" ).append( i ).append( "]='" ).append( args[i] ).append( "'" ).
441                            append( System.getProperty( "line.separator" ) );
442    
443                    }
444    
445                    this.log( Level.FINE, this.getCommandLineInfoMessage(
446                        this.getLocale(), argumentInfo.toString() ), null );
447    
448                }
449    
450                final boolean failOnWarnings = commandLine.hasOption( this.getFailOnWarningsOption().getOpt() );
451    
452                final int status = cmd.execute( commandLine );
453                if ( status == Command.STATUS_SUCCESS && failOnWarnings &&
454                     this.severity.intValue() >= Level.WARNING.intValue() )
455                {
456                    return Command.STATUS_FAILURE;
457                }
458    
459                return status;
460            }
461            catch ( final ParseException e )
462            {
463                this.log( Level.SEVERE, this.getIllegalArgumentsMessage(
464                    this.getLocale(), cmd.getName(), this.getHelpCommandName() ), e );
465    
466                return Command.STATUS_FAILURE;
467            }
468            catch ( final Throwable t )
469            {
470                this.log( Level.SEVERE, t.getMessage(), t );
471                return Command.STATUS_FAILURE;
472            }
473            finally
474            {
475                DefaultModelManager.setDefaultModuleLocation( null );
476                DefaultModelManager.setDefaultSchemaLocation( null );
477                DefaultModelManager.setDefaultTransformerLocation( null );
478                this.getPrintWriter().flush();
479            }
480        }
481    
482        /**
483         * Main entry point.
484         *
485         * @param args The application arguments.
486         */
487        public static void main( final String[] args )
488        {
489            System.exit( run( args ) );
490        }
491    
492        /**
493         * Main entry point without exiting the VM.
494         *
495         * @param args The application arguments.
496         *
497         * @return Status code.
498         *
499         * @see Command#STATUS_SUCCESS
500         * @see Command#STATUS_FAILURE
501         */
502        public static int run( final String[] args )
503        {
504            return new Jomc().jomc( args );
505        }
506    
507        /**
508         * Logs to the print writer of the instance.
509         *
510         * @param level The level of the event.
511         * @param message The message of the event or {@code null}.
512         * @param throwable The throwable of the event {@code null}.
513         *
514         * @throws NullPointerException if {@code level} is {@code null}.
515         */
516        protected void log( final Level level, final String message, final Throwable throwable )
517        {
518            if ( level == null )
519            {
520                throw new NullPointerException( "level" );
521            }
522    
523            if ( this.severity.intValue() < level.intValue() )
524            {
525                this.severity = level;
526            }
527    
528            if ( this.isLoggable( level ) )
529            {
530                if ( message != null )
531                {
532                    this.getPrintWriter().print( this.formatLogLines( level, "" ) );
533                    this.getPrintWriter().print( this.formatLogLines( level, message ) );
534                }
535    
536                if ( throwable != null )
537                {
538                    this.getPrintWriter().print( this.formatLogLines( level, "" ) );
539                    final String m = this.getMessage( throwable );
540    
541                    if ( m != null )
542                    {
543                        this.getPrintWriter().print( this.formatLogLines( level, m ) );
544                    }
545                    else
546                    {
547                        this.getPrintWriter().print( this.formatLogLines( level, throwable.toString() ) );
548                    }
549    
550                    if ( this.getLogLevel().intValue() < Level.INFO.intValue() )
551                    {
552                        final StringWriter stackTrace = new StringWriter();
553                        final PrintWriter pw = new PrintWriter( stackTrace );
554                        throwable.printStackTrace( pw );
555                        pw.flush();
556                        this.getPrintWriter().print( this.formatLogLines( level, stackTrace.toString() ) );
557                    }
558                }
559            }
560    
561            this.getPrintWriter().flush();
562        }
563    
564        private String formatLogLines( final Level level, final String text )
565        {
566            try
567            {
568                final StringBuilder lines = new StringBuilder();
569                final BufferedReader reader = new BufferedReader( new StringReader( text ) );
570    
571                String line;
572                while ( ( line = reader.readLine() ) != null )
573                {
574                    lines.append( "[" ).append( level.getLocalizedName() ).append( "] " );
575                    lines.append( line ).append( System.getProperty( "line.separator" ) );
576                }
577    
578                return lines.toString();
579            }
580            catch ( final IOException e )
581            {
582                throw new AssertionError( e );
583            }
584        }
585    
586        private String getMessage( final Throwable throwable )
587        {
588            if ( throwable != null )
589            {
590                if ( throwable.getMessage() != null )
591                {
592                    return throwable.getMessage();
593                }
594    
595                return this.getMessage( throwable.getCause() );
596            }
597    
598            return null;
599        }
600    
601        // SECTION-END
602        // SECTION-START[Constructors]
603        // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
604    
605        /** Creates a new {@code Jomc} instance. */
606        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
607                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
608        public Jomc()
609        {
610            // SECTION-START[Default Constructor]
611            super();
612            // SECTION-END
613        }
614        // </editor-fold>
615        // SECTION-END
616        // SECTION-START[Dependencies]
617        // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies ">
618    
619        /**
620         * Gets the {@code Commands} dependency.
621         * <p>This method returns any available object of the {@code org.jomc.cli.Command} specification at specification level 1.0-alpha-11.</p>
622         * <p>That specification does not apply to any scope. A new object is returned whenever requested.</p>
623         * @return The {@code Commands} dependency.
624         * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
625         */
626        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
627                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
628        private org.jomc.cli.Command[] getCommands()
629        {
630            final org.jomc.cli.Command[] _d = (org.jomc.cli.Command[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Commands" );
631            assert _d != null : "'Commands' dependency not found.";
632            return _d;
633        }
634    
635        /**
636         * Gets the {@code Locale} dependency.
637         * <p>This method returns the "{@code default}" object of the {@code java.util.Locale} specification at specification level 1.1.</p>
638         * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p>
639         * @return The {@code Locale} dependency.
640         * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
641         */
642        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
643                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
644        private java.util.Locale getLocale()
645        {
646            final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
647            assert _d != null : "'Locale' dependency not found.";
648            return _d;
649        }
650        // </editor-fold>
651        // SECTION-END
652        // SECTION-START[Properties]
653        // <editor-fold defaultstate="collapsed" desc=" Generated Properties ">
654    
655        /**
656         * Gets the value of the {@code debugOptionLongName} property.
657         * @return Long name of the 'debug' option.
658         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
659         */
660        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
661                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
662        private java.lang.String getDebugOptionLongName()
663        {
664            final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "debugOptionLongName" );
665            assert _p != null : "'debugOptionLongName' property not found.";
666            return _p;
667        }
668    
669        /**
670         * Gets the value of the {@code debugOptionShortName} property.
671         * @return Name of the 'debug' option.
672         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
673         */
674        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
675                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
676        private java.lang.String getDebugOptionShortName()
677        {
678            final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "debugOptionShortName" );
679            assert _p != null : "'debugOptionShortName' property not found.";
680            return _p;
681        }
682    
683        /**
684         * Gets the value of the {@code descPad} property.
685         * @return The number of characters of padding to be prefixed to each description line.
686         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
687         */
688        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
689                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
690        private int getDescPad()
691        {
692            final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "descPad" );
693            assert _p != null : "'descPad' property not found.";
694            return _p.intValue();
695        }
696    
697        /**
698         * Gets the value of the {@code failOnWarningsOptionLongName} property.
699         * @return Long name of the 'fail-on-warnings' option.
700         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
701         */
702        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
703                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
704        private java.lang.String getFailOnWarningsOptionLongName()
705        {
706            final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "failOnWarningsOptionLongName" );
707            assert _p != null : "'failOnWarningsOptionLongName' property not found.";
708            return _p;
709        }
710    
711        /**
712         * Gets the value of the {@code failOnWarningsOptionShortName} property.
713         * @return Name of the 'fail-on-warnings' option.
714         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
715         */
716        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
717                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
718        private java.lang.String getFailOnWarningsOptionShortName()
719        {
720            final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "failOnWarningsOptionShortName" );
721            assert _p != null : "'failOnWarningsOptionShortName' property not found.";
722            return _p;
723        }
724    
725        /**
726         * Gets the value of the {@code helpCommandName} property.
727         * @return The name of the command used to request help.
728         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
729         */
730        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
731                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
732        private java.lang.String getHelpCommandName()
733        {
734            final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "helpCommandName" );
735            assert _p != null : "'helpCommandName' property not found.";
736            return _p;
737        }
738    
739        /**
740         * Gets the value of the {@code leftPad} property.
741         * @return The number of characters of padding to be prefixed to each line.
742         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
743         */
744        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
745                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
746        private int getLeftPad()
747        {
748            final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "leftPad" );
749            assert _p != null : "'leftPad' property not found.";
750            return _p.intValue();
751        }
752    
753        /**
754         * Gets the value of the {@code verboseOptionLongName} property.
755         * @return Long name of the 'verbose' option.
756         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
757         */
758        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
759                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
760        private java.lang.String getVerboseOptionLongName()
761        {
762            final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "verboseOptionLongName" );
763            assert _p != null : "'verboseOptionLongName' property not found.";
764            return _p;
765        }
766    
767        /**
768         * Gets the value of the {@code verboseOptionShortName} property.
769         * @return Name of the 'verbose' option.
770         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
771         */
772        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
773                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
774        private java.lang.String getVerboseOptionShortName()
775        {
776            final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "verboseOptionShortName" );
777            assert _p != null : "'verboseOptionShortName' property not found.";
778            return _p;
779        }
780    
781        /**
782         * Gets the value of the {@code width} property.
783         * @return The number of characters per line for the usage statement.
784         * @throws org.jomc.ObjectManagementException if getting the property instance fails.
785         */
786        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
787                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
788        private int getWidth()
789        {
790            final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "width" );
791            assert _p != null : "'width' property not found.";
792            return _p.intValue();
793        }
794        // </editor-fold>
795        // SECTION-END
796        // SECTION-START[Messages]
797        // <editor-fold defaultstate="collapsed" desc=" Generated Messages ">
798    
799        /**
800         * Gets the text of the {@code commandLineInfo} message.
801         * <p><b>Templates</b><br/><table>
802         * <tr><td valign="top">English:</td><td valign="top"><pre>Command line:
803         * {0}</pre></td></tr>
804         * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Kommandozeile:
805         * {0}</pre></td></tr>
806         * </table></p>
807         * @param locale The locale of the message to return.
808         * @param commandLine Format argument.
809         * @return The text of the {@code commandLineInfo} message.
810         *
811         * @throws org.jomc.ObjectManagementException if getting the message instance fails.
812         */
813        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
814                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
815        private String getCommandLineInfoMessage( final java.util.Locale locale, final java.lang.String commandLine )
816        {
817            final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "commandLineInfo", locale, new Object[] { commandLine, null } );
818            assert _m != null : "'commandLineInfo' message not found.";
819            return _m;
820        }
821    
822        /**
823         * Gets the text of the {@code debugOption} message.
824         * <p><b>Templates</b><br/><table>
825         * <tr><td valign="top">English:</td><td valign="top"><pre>Enables debug output.</pre></td></tr>
826         * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Aktiviert Diagnose-Ausgaben.</pre></td></tr>
827         * </table></p>
828         * @param locale The locale of the message to return.
829         * @return The text of the {@code debugOption} message.
830         *
831         * @throws org.jomc.ObjectManagementException if getting the message instance fails.
832         */
833        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
834                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
835        private String getDebugOptionMessage( final java.util.Locale locale )
836        {
837            final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "debugOption", locale,  null );
838            assert _m != null : "'debugOption' message not found.";
839            return _m;
840        }
841    
842        /**
843         * Gets the text of the {@code failOnWarningsOption} message.
844         * <p><b>Templates</b><br/><table>
845         * <tr><td valign="top">English:</td><td valign="top"><pre>Exit with failure on warnings.</pre></td></tr>
846         * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Bei Warnungen Fehler melden.</pre></td></tr>
847         * </table></p>
848         * @param locale The locale of the message to return.
849         * @return The text of the {@code failOnWarningsOption} message.
850         *
851         * @throws org.jomc.ObjectManagementException if getting the message instance fails.
852         */
853        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
854                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
855        private String getFailOnWarningsOptionMessage( final java.util.Locale locale )
856        {
857            final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "failOnWarningsOption", locale,  null );
858            assert _m != null : "'failOnWarningsOption' message not found.";
859            return _m;
860        }
861    
862        /**
863         * Gets the text of the {@code illegalArguments} message.
864         * <p><b>Templates</b><br/><table>
865         * <tr><td valign="top">English:</td><td valign="top"><pre>Illegal arguments. Type &raquo;jomc {0} {1}&laquo; for further information.</pre></td></tr>
866         * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Ung&uuml;ltige Argumente. Geben Sie &raquo;jomc {0} {1}&laquo; f&uuml;r weitere Informationen ein.</pre></td></tr>
867         * </table></p>
868         * @param locale The locale of the message to return.
869         * @param command Format argument.
870         * @param helpCommandName Format argument.
871         * @return The text of the {@code illegalArguments} message.
872         *
873         * @throws org.jomc.ObjectManagementException if getting the message instance fails.
874         */
875        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
876                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
877        private String getIllegalArgumentsMessage( final java.util.Locale locale, final java.lang.String command, final java.lang.String helpCommandName )
878        {
879            final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "illegalArguments", locale, new Object[] { command, helpCommandName, null } );
880            assert _m != null : "'illegalArguments' message not found.";
881            return _m;
882        }
883    
884        /**
885         * Gets the text of the {@code usage} message.
886         * <p><b>Templates</b><br/><table>
887         * <tr><td valign="top">English:</td><td valign="top"><pre>Type &raquo;jomc &lt;command&gt; {0}&laquo; for further information.</pre></td></tr>
888         * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Geben Sie &raquo;jomc &lt;Befehl&gt; {0}&laquo; f&uuml;r weitere Informationen ein.</pre></td></tr>
889         * </table></p>
890         * @param locale The locale of the message to return.
891         * @param helpCommandName Format argument.
892         * @return The text of the {@code usage} message.
893         *
894         * @throws org.jomc.ObjectManagementException if getting the message instance fails.
895         */
896        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
897                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
898        private String getUsageMessage( final java.util.Locale locale, final java.lang.String helpCommandName )
899        {
900            final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "usage", locale, new Object[] { helpCommandName, null } );
901            assert _m != null : "'usage' message not found.";
902            return _m;
903        }
904    
905        /**
906         * Gets the text of the {@code verboseOption} message.
907         * <p><b>Templates</b><br/><table>
908         * <tr><td valign="top">English:</td><td valign="top"><pre>Enables verbose output.</pre></td></tr>
909         * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Aktiviert ausf&uuml;hrliche Ausgaben.</pre></td></tr>
910         * </table></p>
911         * @param locale The locale of the message to return.
912         * @return The text of the {@code verboseOption} message.
913         *
914         * @throws org.jomc.ObjectManagementException if getting the message instance fails.
915         */
916        @javax.annotation.Generated( value = "org.jomc.tools.JavaSources",
917                                     comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" )
918        private String getVerboseOptionMessage( final java.util.Locale locale )
919        {
920            final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "verboseOption", locale,  null );
921            assert _m != null : "'verboseOption' message not found.";
922            return _m;
923        }
924        // </editor-fold>
925        // SECTION-END
926    }