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: Jomc.java 4712 2013-01-02 13:56:12Z schulte $
032 *
033 */
034// </editor-fold>
035// SECTION-END
036package org.jomc.cli;
037
038import java.io.BufferedReader;
039import java.io.IOException;
040import java.io.PrintWriter;
041import java.io.StringReader;
042import java.io.StringWriter;
043import java.util.Date;
044import java.util.logging.Level;
045import org.apache.commons.cli.CommandLine;
046import org.apache.commons.cli.HelpFormatter;
047import org.apache.commons.cli.Options;
048import org.apache.commons.cli.ParseException;
049import org.apache.commons.lang.StringUtils;
050import org.jomc.model.modlet.DefaultModelProcessor;
051import org.jomc.model.modlet.DefaultModelProvider;
052import org.jomc.modlet.DefaultModletProvider;
053
054// SECTION-START[Documentation]
055// <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
056/**
057 * JOMC command line interface.
058 *
059 * <dl>
060 *   <dt><b>Identifier:</b></dt><dd>JOMC ⁑ CLI ⁑ Application</dd>
061 *   <dt><b>Name:</b></dt><dd>JOMC ⁑ CLI ⁑ Application</dd>
062 *   <dt><b>Abstract:</b></dt><dd>No</dd>
063 *   <dt><b>Final:</b></dt><dd>No</dd>
064 *   <dt><b>Stateless:</b></dt><dd>No</dd>
065 * </dl>
066 *
067 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
068 * @version 1.4
069 */
070// </editor-fold>
071// SECTION-END
072// SECTION-START[Annotations]
073// <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
074@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
075// </editor-fold>
076// SECTION-END
077public final class Jomc
078{
079    // SECTION-START[Jomc]
080
081    /**
082     * Log level events are logged at by default.
083     * @see #getDefaultLogLevel()
084     */
085    private static final Level DEFAULT_LOG_LEVEL = Level.WARNING;
086
087    /** Default log level. */
088    private static volatile Level defaultLogLevel;
089
090    /** Print writer of the instance. */
091    private PrintWriter printWriter;
092
093    /** Log level of the instance. */
094    private Level logLevel;
095
096    /** Greatest severity logged by the command. */
097    private Level severity = Level.ALL;
098
099    /**
100     * Gets the print writer of the instance.
101     *
102     * @return The print writer of the instance.
103     *
104     * @see #setPrintWriter(java.io.PrintWriter)
105     */
106    public PrintWriter getPrintWriter()
107    {
108        if ( this.printWriter == null )
109        {
110            // JDK: As of JDK 6, "this.printWriter = System.console().writer()".
111            this.printWriter = new PrintWriter( System.out, true );
112        }
113
114        return this.printWriter;
115    }
116
117    /**
118     * Sets the print writer of the instance.
119     *
120     * @param value The new print writer of the instance or {@code null}.
121     *
122     * @see #getPrintWriter()
123     */
124    public void setPrintWriter( final PrintWriter value )
125    {
126        this.printWriter = value;
127    }
128
129    /**
130     * Gets the default log level events are logged at.
131     * <p>The default log level is controlled by system property {@code org.jomc.cli.Jomc.defaultLogLevel} holding the
132     * log level to log events at by default. If that property is not set, the {@code WARNING} default is returned.</p>
133     *
134     * @return The log level events are logged at by default.
135     *
136     * @see #getLogLevel()
137     * @see Level#parse(java.lang.String)
138     */
139    public static Level getDefaultLogLevel()
140    {
141        if ( defaultLogLevel == null )
142        {
143            defaultLogLevel = Level.parse( System.getProperty(
144                "org.jomc.cli.Jomc.defaultLogLevel", DEFAULT_LOG_LEVEL.getName() ) );
145
146        }
147
148        return defaultLogLevel;
149    }
150
151    /**
152     * Sets the default log level events are logged at.
153     *
154     * @param value The new default level events are logged at or {@code null}.
155     *
156     * @see #getDefaultLogLevel()
157     */
158    public static void setDefaultLogLevel( final Level value )
159    {
160        defaultLogLevel = value;
161    }
162
163    /**
164     * Gets the log level of the instance.
165     *
166     * @return The log level of the instance.
167     *
168     * @see #getDefaultLogLevel()
169     * @see #setLogLevel(java.util.logging.Level)
170     * @see #isLoggable(java.util.logging.Level)
171     */
172    public Level getLogLevel()
173    {
174        if ( this.logLevel == null )
175        {
176            this.logLevel = getDefaultLogLevel();
177
178            if ( this.isLoggable( Level.CONFIG ) )
179            {
180                this.log( Level.CONFIG,
181                          this.getDefaultLogLevelInfo( this.getLocale(), this.logLevel.getLocalizedName() ), null );
182
183            }
184        }
185
186        return this.logLevel;
187    }
188
189    /**
190     * Sets the log level of the instance.
191     *
192     * @param value The new log level of the instance or {@code null}.
193     *
194     * @see #getLogLevel()
195     * @see #isLoggable(java.util.logging.Level)
196     */
197    public void setLogLevel( final Level value )
198    {
199        this.logLevel = value;
200    }
201
202    /**
203     * Checks if a message at a given level is provided to the listeners of the instance.
204     *
205     * @param level The level to test.
206     *
207     * @return {@code true}, if messages at {@code level} are provided to the listeners of the instance;
208     * {@code false}, if messages at {@code level} are not provided to the listeners of the instance.
209     *
210     * @throws NullPointerException if {@code level} is {@code null}.
211     *
212     * @see #getLogLevel()
213     * @see #setLogLevel(java.util.logging.Level)
214     */
215    public boolean isLoggable( final Level level )
216    {
217        if ( level == null )
218        {
219            throw new NullPointerException( "level" );
220        }
221
222        return level.intValue() >= this.getLogLevel().intValue();
223    }
224
225    /**
226     * Processes the given arguments and executes the corresponding command.
227     *
228     * @param args Arguments to process.
229     *
230     * @return Status code.
231     *
232     * @see Command#STATUS_SUCCESS
233     * @see Command#STATUS_FAILURE
234     */
235    public int jomc( final String[] args )
236    {
237        Command cmd = null;
238        this.severity = Level.ALL;
239
240        try
241        {
242            DefaultModelProvider.setDefaultModuleLocation( "META-INF/jomc-cli.xml" );
243            DefaultModelProcessor.setDefaultTransformerLocation( "META-INF/jomc-cli.xsl" );
244            DefaultModletProvider.setDefaultModletLocation( "META-INF/jomc-modlet.xml" );
245
246            final StringBuilder commandInfo = new StringBuilder();
247
248            for ( Command c : this.getCommands() )
249            {
250                if ( cmd == null && args != null && args.length > 0
251                     && ( args[0].equals( c.getName() ) || args[0].equals( c.getAbbreviatedName() ) ) )
252                {
253                    cmd = c;
254                }
255
256                commandInfo.append( StringUtils.rightPad( c.getName(), 25 ) ).append( " : " ).
257                    append( c.getShortDescription( this.getLocale() ) ).append( " (" ).append( c.getAbbreviatedName() ).
258                    append( ")" ).append( System.getProperty( "line.separator", "\n" ) );
259
260            }
261
262            if ( cmd == null )
263            {
264                this.getPrintWriter().println( this.getUsage( this.getLocale(), this.getHelpCommandName() ) );
265                this.getPrintWriter().println();
266                this.getPrintWriter().println( commandInfo.toString() );
267                return Command.STATUS_FAILURE;
268            }
269
270            final String[] commandArguments = new String[ args.length - 1 ];
271            System.arraycopy( args, 1, commandArguments, 0, commandArguments.length );
272
273            final Options options = cmd.getOptions();
274            options.addOption( this.getDebugOption() );
275            options.addOption( this.getVerboseOption() );
276            options.addOption( this.getFailOnWarningsOption() );
277
278            if ( commandArguments.length > 0 && this.getHelpCommandName().equals( commandArguments[0] ) )
279            {
280                final StringWriter usage = new StringWriter();
281                final StringWriter opts = new StringWriter();
282                final HelpFormatter formatter = new HelpFormatter();
283
284                PrintWriter pw = new PrintWriter( usage );
285                formatter.printUsage( pw, this.getWidth(), cmd.getName(), options );
286                pw.close();
287                assert !pw.checkError() : "Unexpected error printing usage.";
288
289                pw = new PrintWriter( opts );
290                formatter.printOptions( pw, this.getWidth(), options, this.getLeftPad(), this.getDescPad() );
291                pw.close();
292                assert !pw.checkError() : "Unexpected error printing options.";
293
294                this.getPrintWriter().println( cmd.getShortDescription( this.getLocale() ) );
295                this.getPrintWriter().println();
296                this.getPrintWriter().println( usage.toString() );
297                this.getPrintWriter().println( opts.toString() );
298                this.getPrintWriter().println();
299                this.getPrintWriter().println( cmd.getLongDescription( this.getLocale() ) );
300                this.getPrintWriter().println();
301                return Command.STATUS_SUCCESS;
302            }
303
304            cmd.getListeners().add( new Command.Listener()
305            {
306
307                public void onLog( final Level level, final String message, final Throwable t )
308                {
309                    log( level, message, t );
310                }
311
312            } );
313
314            DefaultModelProvider.setDefaultModuleLocation( null );
315            DefaultModelProcessor.setDefaultTransformerLocation( null );
316            DefaultModletProvider.setDefaultModletLocation( null );
317
318            final CommandLine commandLine = this.getCommandLineParser().parse( options, commandArguments );
319            final boolean debug = commandLine.hasOption( this.getDebugOption().getOpt() );
320            final boolean verbose = commandLine.hasOption( this.getVerboseOption().getOpt() );
321            Level debugLevel = Level.ALL;
322
323            if ( debug )
324            {
325                final String debugOption = commandLine.getOptionValue( this.getDebugOption().getOpt() );
326                if ( debugOption != null )
327                {
328                    debugLevel = Level.parse( debugOption );
329                }
330            }
331
332            if ( debug || verbose )
333            {
334                this.setLogLevel( debug ? debugLevel : Level.INFO );
335            }
336
337            cmd.setLogLevel( this.getLogLevel() );
338
339            if ( this.isLoggable( Level.FINER ) )
340            {
341                for ( int i = 0; i < args.length; i++ )
342                {
343                    this.log( Level.FINER, new StringBuilder().append( "[" ).append( i ).append( "] -> '" ).
344                        append( args[i] ).append( "'" ).append( System.getProperty( "line.separator", "\n" ) ).
345                        toString(), null );
346
347                }
348            }
349
350            final boolean failOnWarnings = commandLine.hasOption( this.getFailOnWarningsOption().getOpt() );
351
352            final int status = cmd.execute( commandLine );
353            if ( status == Command.STATUS_SUCCESS && failOnWarnings
354                 && this.severity.intValue() >= Level.WARNING.intValue() )
355            {
356                return Command.STATUS_FAILURE;
357            }
358
359            return status;
360        }
361        catch ( final ParseException e )
362        {
363            this.log( Level.SEVERE, this.getIllegalArgumentsInfo(
364                this.getLocale(), cmd.getName(), this.getHelpCommandName() ), e );
365
366            return Command.STATUS_FAILURE;
367        }
368        catch ( final Throwable t )
369        {
370            this.log( Level.SEVERE, null, t );
371            return Command.STATUS_FAILURE;
372        }
373        finally
374        {
375            DefaultModelProvider.setDefaultModuleLocation( null );
376            DefaultModelProcessor.setDefaultTransformerLocation( null );
377            DefaultModletProvider.setDefaultModletLocation( null );
378            this.getPrintWriter().flush();
379            this.severity = Level.ALL;
380        }
381    }
382
383    /**
384     * Main entry point.
385     *
386     * @param args The application arguments.
387     */
388    public static void main( final String[] args )
389    {
390        System.exit( run( args ) );
391    }
392
393    /**
394     * Main entry point without exiting the VM.
395     *
396     * @param args The application arguments.
397     *
398     * @return Status code.
399     *
400     * @see Command#STATUS_SUCCESS
401     * @see Command#STATUS_FAILURE
402     */
403    public static int run( final String[] args )
404    {
405        return new Jomc().jomc( args );
406    }
407
408    /**
409     * Logs to the print writer of the instance.
410     *
411     * @param level The level of the event.
412     * @param message The message of the event or {@code null}.
413     * @param throwable The throwable of the event {@code null}.
414     *
415     * @throws NullPointerException if {@code level} is {@code null}.
416     */
417    private void log( final Level level, final String message, final Throwable throwable )
418    {
419        if ( level == null )
420        {
421            throw new NullPointerException( "level" );
422        }
423
424        if ( this.severity.intValue() < level.intValue() )
425        {
426            this.severity = level;
427        }
428
429        if ( this.isLoggable( level ) )
430        {
431            if ( message != null )
432            {
433                this.getPrintWriter().print( this.formatLogLines( level, "" ) );
434                this.getPrintWriter().print( this.formatLogLines( level, message ) );
435            }
436
437            if ( throwable != null )
438            {
439                this.getPrintWriter().print( this.formatLogLines( level, "" ) );
440                final String m = getMessage( throwable );
441
442                if ( m != null && m.length() > 0 )
443                {
444                    this.getPrintWriter().print( this.formatLogLines( level, m ) );
445                }
446                else
447                {
448                    this.getPrintWriter().print( this.formatLogLines(
449                        level, this.getDefaultExceptionMessage( this.getLocale() ) ) );
450
451                }
452
453                if ( this.getLogLevel().intValue() < Level.INFO.intValue() )
454                {
455                    final StringWriter stackTrace = new StringWriter();
456                    final PrintWriter pw = new PrintWriter( stackTrace );
457                    throwable.printStackTrace( pw );
458                    pw.flush();
459                    this.getPrintWriter().print( this.formatLogLines( level, stackTrace.toString() ) );
460                }
461            }
462        }
463
464        this.getPrintWriter().flush();
465    }
466
467    private String formatLogLines( final Level level, final String text )
468    {
469        BufferedReader reader = null;
470        boolean suppressExceptionOnClose = true;
471
472        try
473        {
474            final StringBuilder lines = new StringBuilder( text.length() );
475            reader = new BufferedReader( new StringReader( text ) );
476
477            String line;
478            while ( ( line = reader.readLine() ) != null )
479            {
480                final boolean debug = this.getLogLevel().intValue() < Level.INFO.intValue();
481                lines.append( "[" ).append( level.getLocalizedName() );
482
483                if ( debug )
484                {
485                    lines.append( "|" ).append( Thread.currentThread().getName() ).append( "|" ).
486                        append( this.getTimeInfo( this.getLocale(), new Date( System.currentTimeMillis() ) ) );
487
488                }
489
490                lines.append( "] " ).append( line ).append( System.getProperty( "line.separator", "\n" ) );
491            }
492
493            suppressExceptionOnClose = false;
494            return lines.toString();
495        }
496        catch ( final IOException e )
497        {
498            throw new AssertionError( e );
499        }
500        finally
501        {
502            try
503            {
504                if ( reader != null )
505                {
506                    reader.close();
507                }
508            }
509            catch ( final IOException e )
510            {
511                if ( suppressExceptionOnClose )
512                {
513                    this.log( Level.SEVERE, getMessage( e ), e );
514                }
515                else
516                {
517                    throw new AssertionError( e );
518                }
519            }
520        }
521    }
522
523    private static String getMessage( final Throwable t )
524    {
525        return t != null ? t.getMessage() != null ? t.getMessage() : getMessage( t.getCause() ) : null;
526    }
527
528    // SECTION-END
529    // SECTION-START[Constructors]
530    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
531    /** Creates a new {@code Jomc} instance. */
532    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
533    public Jomc()
534    {
535        // SECTION-START[Default Constructor]
536        super();
537        // SECTION-END
538    }
539    // </editor-fold>
540    // SECTION-END
541    // SECTION-START[Dependencies]
542    // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies ">
543    /**
544     * Gets the {@code <Command Line Parser>} dependency.
545     * <p>
546     *   This method returns the {@code <Commons CLI - GNU Command Line Parser>} object of the {@code <org.apache.commons.cli.CommandLineParser>} specification at any specification level.
547     *   That specification does not apply to any scope. A new object is returned whenever requested.
548     * </p>
549     * <dl>
550     *   <dt><b>Final:</b></dt><dd>No</dd>
551     * </dl>
552     * @return The {@code <Command Line Parser>} dependency.
553     * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
554     */
555    @SuppressWarnings("unused")
556    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
557    private org.apache.commons.cli.CommandLineParser getCommandLineParser()
558    {
559        final org.apache.commons.cli.CommandLineParser _d = (org.apache.commons.cli.CommandLineParser) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Command Line Parser" );
560        assert _d != null : "'Command Line Parser' dependency not found.";
561        return _d;
562    }
563    /**
564     * Gets the {@code <Commands>} dependency.
565     * <p>
566     *   This method returns any available object of the {@code <JOMC ⁑ CLI ⁑ Command>} specification at specification level 1.0.
567     *   That specification does not apply to any scope. A new object is returned whenever requested.
568     * </p>
569     * <dl>
570     *   <dt><b>Final:</b></dt><dd>No</dd>
571     * </dl>
572     * @return The {@code <Commands>} dependency.
573     * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
574     */
575    @SuppressWarnings("unused")
576    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
577    private org.jomc.cli.Command[] getCommands()
578    {
579        final org.jomc.cli.Command[] _d = (org.jomc.cli.Command[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Commands" );
580        assert _d != null : "'Commands' dependency not found.";
581        return _d;
582    }
583    /**
584     * Gets the {@code <Debug Option>} dependency.
585     * <p>
586     *   This method returns the {@code <JOMC ⁑ CLI ⁑ Debug Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2.
587     *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
588     * </p>
589     * <dl>
590     *   <dt><b>Final:</b></dt><dd>No</dd>
591     * </dl>
592     * @return The {@code <Debug Option>} dependency.
593     * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
594     */
595    @SuppressWarnings("unused")
596    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
597    private org.apache.commons.cli.Option getDebugOption()
598    {
599        final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Debug Option" );
600        assert _d != null : "'Debug Option' dependency not found.";
601        return _d;
602    }
603    /**
604     * Gets the {@code <Fail On Warnings Option>} dependency.
605     * <p>
606     *   This method returns the {@code <JOMC ⁑ CLI ⁑ Fail-On-Warnings Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2.
607     *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
608     * </p>
609     * <dl>
610     *   <dt><b>Final:</b></dt><dd>No</dd>
611     * </dl>
612     * @return The {@code <Fail On Warnings Option>} dependency.
613     * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
614     */
615    @SuppressWarnings("unused")
616    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
617    private org.apache.commons.cli.Option getFailOnWarningsOption()
618    {
619        final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Fail On Warnings Option" );
620        assert _d != null : "'Fail On Warnings Option' dependency not found.";
621        return _d;
622    }
623    /**
624     * Gets the {@code <Locale>} dependency.
625     * <p>
626     *   This method returns the {@code <default>} object of the {@code <java.util.Locale>} specification at specification level 1.1.
627     *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
628     * </p>
629     * <dl>
630     *   <dt><b>Final:</b></dt><dd>No</dd>
631     * </dl>
632     * @return The {@code <Locale>} dependency.
633     * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
634     */
635    @SuppressWarnings("unused")
636    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
637    private java.util.Locale getLocale()
638    {
639        final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
640        assert _d != null : "'Locale' dependency not found.";
641        return _d;
642    }
643    /**
644     * Gets the {@code <Verbose Option>} dependency.
645     * <p>
646     *   This method returns the {@code <JOMC ⁑ CLI ⁑ Verbose Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2.
647     *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
648     * </p>
649     * <dl>
650     *   <dt><b>Final:</b></dt><dd>No</dd>
651     * </dl>
652     * @return The {@code <Verbose Option>} dependency.
653     * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
654     */
655    @SuppressWarnings("unused")
656    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
657    private org.apache.commons.cli.Option getVerboseOption()
658    {
659        final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Verbose Option" );
660        assert _d != null : "'Verbose Option' dependency not found.";
661        return _d;
662    }
663    // </editor-fold>
664    // SECTION-END
665    // SECTION-START[Properties]
666    // <editor-fold defaultstate="collapsed" desc=" Generated Properties ">
667    /**
668     * Gets the value of the {@code <Desc Pad>} property.
669     * <p><dl>
670     *   <dt><b>Final:</b></dt><dd>No</dd>
671     * </dl></p>
672     * @return The number of characters of padding to be prefixed to each description line.
673     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
674     */
675    @SuppressWarnings("unused")
676    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
677    private int getDescPad()
678    {
679        final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Desc Pad" );
680        assert _p != null : "'Desc Pad' property not found.";
681        return _p.intValue();
682    }
683    /**
684     * Gets the value of the {@code <Help Command Name>} property.
685     * <p><dl>
686     *   <dt><b>Final:</b></dt><dd>No</dd>
687     * </dl></p>
688     * @return The name of the command used to request help.
689     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
690     */
691    @SuppressWarnings("unused")
692    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
693    private java.lang.String getHelpCommandName()
694    {
695        final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Help Command Name" );
696        assert _p != null : "'Help Command Name' property not found.";
697        return _p;
698    }
699    /**
700     * Gets the value of the {@code <Left Pad>} property.
701     * <p><dl>
702     *   <dt><b>Final:</b></dt><dd>No</dd>
703     * </dl></p>
704     * @return The number of characters of padding to be prefixed to each line.
705     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
706     */
707    @SuppressWarnings("unused")
708    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
709    private int getLeftPad()
710    {
711        final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Left Pad" );
712        assert _p != null : "'Left Pad' property not found.";
713        return _p.intValue();
714    }
715    /**
716     * Gets the value of the {@code <width>} property.
717     * <p><dl>
718     *   <dt><b>Final:</b></dt><dd>No</dd>
719     * </dl></p>
720     * @return The number of characters per line for the usage statement.
721     * @throws org.jomc.ObjectManagementException if getting the property instance fails.
722     */
723    @SuppressWarnings("unused")
724    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
725    private int getWidth()
726    {
727        final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "width" );
728        assert _p != null : "'width' property not found.";
729        return _p.intValue();
730    }
731    // </editor-fold>
732    // SECTION-END
733    // SECTION-START[Messages]
734    // <editor-fold defaultstate="collapsed" desc=" Generated Messages ">
735    /**
736     * Gets the text of the {@code <Default Exception Message>} message.
737     * <p><dl>
738     *   <dt><b>Languages:</b></dt>
739     *     <dd>English (default)</dd>
740     *     <dd>Deutsch</dd>
741     *   <dt><b>Final:</b></dt><dd>No</dd>
742     * </dl></p>
743     * @param locale The locale of the message to return.
744     * @return The text of the {@code <Default Exception Message>} message for {@code locale}.
745     * @throws org.jomc.ObjectManagementException if getting the message instance fails.
746     */
747    @SuppressWarnings("unused")
748    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
749    private String getDefaultExceptionMessage( final java.util.Locale locale )
750    {
751        final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Exception Message", locale );
752        assert _m != null : "'Default Exception Message' message not found.";
753        return _m;
754    }
755    /**
756     * Gets the text of the {@code <Default Log Level Info>} message.
757     * <p><dl>
758     *   <dt><b>Languages:</b></dt>
759     *     <dd>English (default)</dd>
760     *     <dd>Deutsch</dd>
761     *   <dt><b>Final:</b></dt><dd>No</dd>
762     * </dl></p>
763     * @param locale The locale of the message to return.
764     * @param defaultLogLevel Format argument.
765     * @return The text of the {@code <Default Log Level Info>} message for {@code locale}.
766     * @throws org.jomc.ObjectManagementException if getting the message instance fails.
767     */
768    @SuppressWarnings("unused")
769    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
770    private String getDefaultLogLevelInfo( final java.util.Locale locale, final java.lang.String defaultLogLevel )
771    {
772        final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Log Level Info", locale, defaultLogLevel );
773        assert _m != null : "'Default Log Level Info' message not found.";
774        return _m;
775    }
776    /**
777     * Gets the text of the {@code <Illegal Arguments Info>} message.
778     * <p><dl>
779     *   <dt><b>Languages:</b></dt>
780     *     <dd>English (default)</dd>
781     *     <dd>Deutsch</dd>
782     *   <dt><b>Final:</b></dt><dd>No</dd>
783     * </dl></p>
784     * @param locale The locale of the message to return.
785     * @param command Format argument.
786     * @param helpCommandName Format argument.
787     * @return The text of the {@code <Illegal Arguments Info>} message for {@code locale}.
788     * @throws org.jomc.ObjectManagementException if getting the message instance fails.
789     */
790    @SuppressWarnings("unused")
791    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
792    private String getIllegalArgumentsInfo( final java.util.Locale locale, final java.lang.String command, final java.lang.String helpCommandName )
793    {
794        final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Illegal Arguments Info", locale, command, helpCommandName );
795        assert _m != null : "'Illegal Arguments Info' message not found.";
796        return _m;
797    }
798    /**
799     * Gets the text of the {@code <Time Info>} message.
800     * <p><dl>
801     *   <dt><b>Languages:</b></dt>
802     *     <dd>English (default)</dd>
803     *     <dd>Deutsch</dd>
804     *   <dt><b>Final:</b></dt><dd>No</dd>
805     * </dl></p>
806     * @param locale The locale of the message to return.
807     * @param time Format argument.
808     * @return The text of the {@code <Time Info>} message for {@code locale}.
809     * @throws org.jomc.ObjectManagementException if getting the message instance fails.
810     */
811    @SuppressWarnings("unused")
812    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
813    private String getTimeInfo( final java.util.Locale locale, final java.util.Date time )
814    {
815        final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Time Info", locale, time );
816        assert _m != null : "'Time Info' message not found.";
817        return _m;
818    }
819    /**
820     * Gets the text of the {@code <Usage>} message.
821     * <p><dl>
822     *   <dt><b>Languages:</b></dt>
823     *     <dd>English (default)</dd>
824     *     <dd>Deutsch</dd>
825     *   <dt><b>Final:</b></dt><dd>No</dd>
826     * </dl></p>
827     * @param locale The locale of the message to return.
828     * @param helpCommandName Format argument.
829     * @return The text of the {@code <Usage>} message for {@code locale}.
830     * @throws org.jomc.ObjectManagementException if getting the message instance fails.
831     */
832    @SuppressWarnings("unused")
833    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
834    private String getUsage( final java.util.Locale locale, final java.lang.String helpCommandName )
835    {
836        final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Usage", locale, helpCommandName );
837        assert _m != null : "'Usage' message not found.";
838        return _m;
839    }
840    // </editor-fold>
841    // SECTION-END
842}