View Javadoc
1   // SECTION-START[License Header]
2   // <editor-fold defaultstate="collapsed" desc=" Generated License ">
3   /*
4    * Java Object Management and Configuration
5    * Copyright (C) Christian Schulte <cs@schulte.it>, 2005-206
6    * All rights reserved.
7    *
8    * Redistribution and use in source and binary forms, with or without
9    * modification, are permitted provided that the following conditions
10   * are met:
11   *
12   *   o Redistributions of source code must retain the above copyright
13   *     notice, this list of conditions and the following disclaimer.
14   *
15   *   o Redistributions in binary form must reproduce the above copyright
16   *     notice, this list of conditions and the following disclaimer in
17   *     the documentation and/or other materials provided with the
18   *     distribution.
19   *
20   * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22   * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
24   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30   *
31   * $JOMC: Jomc.java 5061 2015-05-31 13:20:40Z schulte $
32   *
33   */
34  // </editor-fold>
35  // SECTION-END
36  package org.jomc.cli;
37  
38  import java.io.BufferedReader;
39  import java.io.IOException;
40  import java.io.PrintWriter;
41  import java.io.StringReader;
42  import java.io.StringWriter;
43  import java.util.Date;
44  import java.util.logging.Level;
45  import org.apache.commons.cli.CommandLine;
46  import org.apache.commons.cli.HelpFormatter;
47  import org.apache.commons.cli.Options;
48  import org.apache.commons.cli.ParseException;
49  import org.apache.commons.lang.StringUtils;
50  import org.jomc.model.modlet.DefaultModelProcessor;
51  import org.jomc.model.modlet.DefaultModelProvider;
52  import org.jomc.modlet.DefaultModletProvider;
53  
54  // SECTION-START[Documentation]
55  // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
56  /**
57   * JOMC command line interface.
58   *
59   * <dl>
60   *   <dt><b>Identifier:</b></dt><dd>JOMC ⁑ CLI ⁑ Application</dd>
61   *   <dt><b>Name:</b></dt><dd>JOMC ⁑ CLI ⁑ Application</dd>
62   *   <dt><b>Abstract:</b></dt><dd>No</dd>
63   *   <dt><b>Final:</b></dt><dd>No</dd>
64   *   <dt><b>Stateless:</b></dt><dd>No</dd>
65   * </dl>
66   *
67   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
68   * @version 1.9
69   */
70  // </editor-fold>
71  // SECTION-END
72  // SECTION-START[Annotations]
73  // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
74  @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
75  // </editor-fold>
76  // SECTION-END
77  public final class Jomc
78  {
79      // SECTION-START[Jomc]
80  
81      /**
82       * Log level events are logged at by default.
83       *
84       * @see #getDefaultLogLevel()
85       */
86      private static final Level DEFAULT_LOG_LEVEL = Level.WARNING;
87  
88      /**
89       * Default log level.
90       */
91      private static volatile Level defaultLogLevel;
92  
93      /**
94       * Print writer of the instance.
95       */
96      private PrintWriter printWriter;
97  
98      /**
99       * Log level of the instance.
100      */
101     private Level logLevel;
102 
103     /**
104      * Greatest severity logged by the command.
105      */
106     private Level severity = Level.ALL;
107 
108     /**
109      * Gets the print writer of the instance.
110      *
111      * @return The print writer of the instance.
112      *
113      * @see #setPrintWriter(java.io.PrintWriter)
114      */
115     public PrintWriter getPrintWriter()
116     {
117         if ( this.printWriter == null )
118         {
119             // JDK: As of JDK 6, "this.printWriter = System.console().writer()".
120             this.printWriter = new PrintWriter( System.out, true );
121         }
122 
123         return this.printWriter;
124     }
125 
126     /**
127      * Sets the print writer of the instance.
128      *
129      * @param value The new print writer of the instance or {@code null}.
130      *
131      * @see #getPrintWriter()
132      */
133     public void setPrintWriter( final PrintWriter value )
134     {
135         this.printWriter = value;
136     }
137 
138     /**
139      * Gets the default log level events are logged at.
140      * <p>
141      * The default log level is controlled by system property {@code org.jomc.cli.Jomc.defaultLogLevel} holding the
142      * log level to log events at by default. If that property is not set, the {@code WARNING} default is returned.
143      * </p>
144      *
145      * @return The log level events are logged at by default.
146      *
147      * @see #getLogLevel()
148      * @see Level#parse(java.lang.String)
149      */
150     public static Level getDefaultLogLevel()
151     {
152         if ( defaultLogLevel == null )
153         {
154             defaultLogLevel = Level.parse( System.getProperty(
155                 "org.jomc.cli.Jomc.defaultLogLevel", DEFAULT_LOG_LEVEL.getName() ) );
156 
157         }
158 
159         return defaultLogLevel;
160     }
161 
162     /**
163      * Sets the default log level events are logged at.
164      *
165      * @param value The new default level events are logged at or {@code null}.
166      *
167      * @see #getDefaultLogLevel()
168      */
169     public static void setDefaultLogLevel( final Level value )
170     {
171         defaultLogLevel = value;
172     }
173 
174     /**
175      * Gets the log level of the instance.
176      *
177      * @return The log level of the instance.
178      *
179      * @see #getDefaultLogLevel()
180      * @see #setLogLevel(java.util.logging.Level)
181      * @see #isLoggable(java.util.logging.Level)
182      */
183     public Level getLogLevel()
184     {
185         if ( this.logLevel == null )
186         {
187             this.logLevel = getDefaultLogLevel();
188 
189             if ( this.isLoggable( Level.CONFIG ) )
190             {
191                 this.log( Level.CONFIG,
192                           this.getDefaultLogLevelInfo( this.getLocale(), this.logLevel.getLocalizedName() ), null );
193 
194             }
195         }
196 
197         return this.logLevel;
198     }
199 
200     /**
201      * Sets the log level of the instance.
202      *
203      * @param value The new log level of the instance or {@code null}.
204      *
205      * @see #getLogLevel()
206      * @see #isLoggable(java.util.logging.Level)
207      */
208     public void setLogLevel( final Level value )
209     {
210         this.logLevel = value;
211     }
212 
213     /**
214      * Checks if a message at a given level is provided to the listeners of the instance.
215      *
216      * @param level The level to test.
217      *
218      * @return {@code true}, if messages at {@code level} are provided to the listeners of the instance;
219      * {@code false}, if messages at {@code level} are not provided to the listeners of the instance.
220      *
221      * @throws NullPointerException if {@code level} is {@code null}.
222      *
223      * @see #getLogLevel()
224      * @see #setLogLevel(java.util.logging.Level)
225      */
226     public boolean isLoggable( final Level level )
227     {
228         if ( level == null )
229         {
230             throw new NullPointerException( "level" );
231         }
232 
233         return level.intValue() >= this.getLogLevel().intValue();
234     }
235 
236     /**
237      * Processes the given arguments and executes the corresponding command.
238      *
239      * @param args Arguments to process.
240      *
241      * @return Status code.
242      *
243      * @see Command#STATUS_SUCCESS
244      * @see Command#STATUS_FAILURE
245      */
246     public int jomc( final String[] args )
247     {
248         Command cmd = null;
249         this.severity = Level.ALL;
250 
251         try
252         {
253             DefaultModelProvider.setDefaultModuleLocation( "META-INF/jomc-cli.xml" );
254             DefaultModelProcessor.setDefaultTransformerLocation( "META-INF/jomc-cli.xsl" );
255             DefaultModletProvider.setDefaultModletLocation( "META-INF/jomc-modlet.xml" );
256 
257             final StringBuilder commandInfo = new StringBuilder();
258 
259             for ( final Command c : this.getCommands() )
260             {
261                 if ( cmd == null && args != null && args.length > 0
262                          && ( args[0].equals( c.getName() ) || args[0].equals( c.getAbbreviatedName() ) ) )
263                 {
264                     cmd = c;
265                 }
266 
267                 commandInfo.append( StringUtils.rightPad( c.getName(), 25 ) ).append( " : " ).
268                     append( c.getShortDescription( this.getLocale() ) ).append( " (" ).append( c.getAbbreviatedName() ).
269                     append( ")" ).append( System.getProperty( "line.separator", "\n" ) );
270 
271             }
272 
273             if ( cmd == null )
274             {
275                 this.getPrintWriter().println( this.getUsage( this.getLocale(), this.getHelpCommandName() ) );
276                 this.getPrintWriter().println();
277                 this.getPrintWriter().println( commandInfo.toString() );
278                 return Command.STATUS_FAILURE;
279             }
280 
281             final String[] commandArguments = new String[ args.length - 1 ];
282             System.arraycopy( args, 1, commandArguments, 0, commandArguments.length );
283 
284             final Options options = cmd.getOptions();
285             options.addOption( this.getDebugOption() );
286             options.addOption( this.getVerboseOption() );
287             options.addOption( this.getFailOnWarningsOption() );
288 
289             if ( commandArguments.length > 0 && this.getHelpCommandName().equals( commandArguments[0] ) )
290             {
291                 final StringWriter usage = new StringWriter();
292                 final StringWriter opts = new StringWriter();
293                 final HelpFormatter formatter = new HelpFormatter();
294 
295                 PrintWriter pw = new PrintWriter( usage );
296                 formatter.printUsage( pw, this.getWidth(), cmd.getName(), options );
297                 pw.close();
298                 assert !pw.checkError() : "Unexpected error printing usage.";
299 
300                 pw = new PrintWriter( opts );
301                 formatter.printOptions( pw, this.getWidth(), options, this.getLeftPad(), this.getDescPad() );
302                 pw.close();
303                 assert !pw.checkError() : "Unexpected error printing options.";
304 
305                 this.getPrintWriter().println( cmd.getShortDescription( this.getLocale() ) );
306                 this.getPrintWriter().println();
307                 this.getPrintWriter().println( usage.toString() );
308                 this.getPrintWriter().println( opts.toString() );
309                 this.getPrintWriter().println();
310                 this.getPrintWriter().println( cmd.getLongDescription( this.getLocale() ) );
311                 this.getPrintWriter().println();
312                 return Command.STATUS_SUCCESS;
313             }
314 
315             cmd.getListeners().add( new Command.Listener()
316             {
317 
318                 public void onLog( final Level level, final String message, final Throwable t )
319                 {
320                     log( level, message, t );
321                 }
322 
323             } );
324 
325             DefaultModelProvider.setDefaultModuleLocation( null );
326             DefaultModelProcessor.setDefaultTransformerLocation( null );
327             DefaultModletProvider.setDefaultModletLocation( null );
328 
329             final CommandLine commandLine = this.getCommandLineParser().parse( options, commandArguments );
330             final boolean debug = commandLine.hasOption( this.getDebugOption().getOpt() );
331             final boolean verbose = commandLine.hasOption( this.getVerboseOption().getOpt() );
332             Level debugLevel = Level.ALL;
333 
334             if ( debug )
335             {
336                 final String debugOption = commandLine.getOptionValue( this.getDebugOption().getOpt() );
337                 if ( debugOption != null )
338                 {
339                     debugLevel = Level.parse( debugOption );
340                 }
341             }
342 
343             if ( debug || verbose )
344             {
345                 this.setLogLevel( debug ? debugLevel : Level.INFO );
346             }
347 
348             cmd.setLogLevel( this.getLogLevel() );
349 
350             if ( this.isLoggable( Level.FINER ) )
351             {
352                 for ( int i = 0; i < args.length; i++ )
353                 {
354                     this.log( Level.FINER, new StringBuilder().append( "[" ).append( i ).append( "] -> '" ).
355                               append( args[i] ).append( "'" ).append( System.getProperty( "line.separator", "\n" ) ).
356                               toString(), null );
357 
358                 }
359             }
360 
361             final boolean failOnWarnings = commandLine.hasOption( this.getFailOnWarningsOption().getOpt() );
362 
363             final int status = cmd.execute( commandLine );
364             if ( status == Command.STATUS_SUCCESS && failOnWarnings
365                      && this.severity.intValue() >= Level.WARNING.intValue() )
366             {
367                 return Command.STATUS_FAILURE;
368             }
369 
370             return status;
371         }
372         catch ( final ParseException e )
373         {
374             this.log( Level.SEVERE, this.getIllegalArgumentsInfo(
375                       this.getLocale(), cmd.getName(), this.getHelpCommandName() ), e );
376 
377             return Command.STATUS_FAILURE;
378         }
379         catch ( final Throwable t )
380         {
381             this.log( Level.SEVERE, null, t );
382             return Command.STATUS_FAILURE;
383         }
384         finally
385         {
386             DefaultModelProvider.setDefaultModuleLocation( null );
387             DefaultModelProcessor.setDefaultTransformerLocation( null );
388             DefaultModletProvider.setDefaultModletLocation( null );
389             this.getPrintWriter().flush();
390             this.severity = Level.ALL;
391         }
392     }
393 
394     /**
395      * Main entry point.
396      *
397      * @param args The application arguments.
398      */
399     public static void main( final String[] args )
400     {
401         System.exit( run( args ) );
402     }
403 
404     /**
405      * Main entry point without exiting the VM.
406      *
407      * @param args The application arguments.
408      *
409      * @return Status code.
410      *
411      * @see Command#STATUS_SUCCESS
412      * @see Command#STATUS_FAILURE
413      */
414     public static int run( final String[] args )
415     {
416         return new Jomc().jomc( args );
417     }
418 
419     /**
420      * Logs to the print writer of the instance.
421      *
422      * @param level The level of the event.
423      * @param message The message of the event or {@code null}.
424      * @param throwable The throwable of the event {@code null}.
425      *
426      * @throws NullPointerException if {@code level} is {@code null}.
427      */
428     private void log( final Level level, final String message, final Throwable throwable )
429     {
430         if ( level == null )
431         {
432             throw new NullPointerException( "level" );
433         }
434 
435         if ( this.severity.intValue() < level.intValue() )
436         {
437             this.severity = level;
438         }
439 
440         if ( this.isLoggable( level ) )
441         {
442             if ( message != null )
443             {
444                 this.getPrintWriter().print( this.formatLogLines( level, "" ) );
445                 this.getPrintWriter().print( this.formatLogLines( level, message ) );
446             }
447 
448             if ( throwable != null )
449             {
450                 this.getPrintWriter().print( this.formatLogLines( level, "" ) );
451                 final String m = getMessage( throwable );
452 
453                 if ( m != null && m.length() > 0 )
454                 {
455                     this.getPrintWriter().print( this.formatLogLines( level, m ) );
456                 }
457                 else
458                 {
459                     this.getPrintWriter().print( this.formatLogLines(
460                         level, this.getDefaultExceptionMessage( this.getLocale() ) ) );
461 
462                 }
463 
464                 if ( this.getLogLevel().intValue() < Level.INFO.intValue() )
465                 {
466                     final StringWriter stackTrace = new StringWriter();
467                     final PrintWriter pw = new PrintWriter( stackTrace );
468                     throwable.printStackTrace( pw );
469                     pw.flush();
470                     this.getPrintWriter().print( this.formatLogLines( level, stackTrace.toString() ) );
471                 }
472             }
473         }
474 
475         this.getPrintWriter().flush();
476     }
477 
478     private String formatLogLines( final Level level, final String text )
479     {
480         BufferedReader reader = null;
481         boolean suppressExceptionOnClose = true;
482 
483         try
484         {
485             final StringBuilder lines = new StringBuilder( text.length() );
486             reader = new BufferedReader( new StringReader( text ) );
487 
488             String line;
489             while ( ( line = reader.readLine() ) != null )
490             {
491                 final boolean debug = this.getLogLevel().intValue() < Level.INFO.intValue();
492                 lines.append( "[" ).append( level.getLocalizedName() );
493 
494                 if ( debug )
495                 {
496                     lines.append( "|" ).append( Thread.currentThread().getName() ).append( "|" ).
497                         append( this.getTimeInfo( this.getLocale(), new Date( System.currentTimeMillis() ) ) );
498 
499                 }
500 
501                 lines.append( "] " ).append( line ).append( System.getProperty( "line.separator", "\n" ) );
502             }
503 
504             suppressExceptionOnClose = false;
505             return lines.toString();
506         }
507         catch ( final IOException e )
508         {
509             throw new AssertionError( e );
510         }
511         finally
512         {
513             try
514             {
515                 if ( reader != null )
516                 {
517                     reader.close();
518                 }
519             }
520             catch ( final IOException e )
521             {
522                 if ( suppressExceptionOnClose )
523                 {
524                     this.log( Level.SEVERE, getMessage( e ), e );
525                 }
526                 else
527                 {
528                     throw new AssertionError( e );
529                 }
530             }
531         }
532     }
533 
534     private static String getMessage( final Throwable t )
535     {
536         return t != null
537                    ? t.getMessage() != null && t.getMessage().trim().length() > 0
538                          ? t.getMessage()
539                          : getMessage( t.getCause() )
540                    : null;
541 
542     }
543 
544     // SECTION-END
545     // SECTION-START[Constructors]
546     // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
547     /** Creates a new {@code Jomc} instance. */
548     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
549     public Jomc()
550     {
551         // SECTION-START[Default Constructor]
552         super();
553         // SECTION-END
554     }
555     // </editor-fold>
556     // SECTION-END
557     // SECTION-START[Dependencies]
558     // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies ">
559     /**
560      * Gets the {@code <Command Line Parser>} dependency.
561      * <p>
562      *   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.
563      *   That specification does not apply to any scope. A new object is returned whenever requested.
564      * </p>
565      * <dl>
566      *   <dt><b>Final:</b></dt><dd>No</dd>
567      * </dl>
568      * @return The {@code <Command Line Parser>} dependency.
569      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
570      */
571     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
572     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
573     private org.apache.commons.cli.CommandLineParser getCommandLineParser()
574     {
575         final org.apache.commons.cli.CommandLineParser _d = (org.apache.commons.cli.CommandLineParser) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Command Line Parser" );
576         assert _d != null : "'Command Line Parser' dependency not found.";
577         return _d;
578     }
579     /**
580      * Gets the {@code <Commands>} dependency.
581      * <p>
582      *   This method returns any available object of the {@code <JOMC ⁑ CLI ⁑ Command>} specification at specification level 1.0.
583      *   That specification does not apply to any scope. A new object is returned whenever requested.
584      * </p>
585      * <dl>
586      *   <dt><b>Final:</b></dt><dd>No</dd>
587      * </dl>
588      * @return The {@code <Commands>} dependency.
589      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
590      */
591     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
592     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
593     private org.jomc.cli.Command[] getCommands()
594     {
595         final org.jomc.cli.Command[] _d = (org.jomc.cli.Command[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Commands" );
596         assert _d != null : "'Commands' dependency not found.";
597         return _d;
598     }
599     /**
600      * Gets the {@code <Debug Option>} dependency.
601      * <p>
602      *   This method returns the {@code <JOMC ⁑ CLI ⁑ Debug Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2.
603      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
604      * </p>
605      * <dl>
606      *   <dt><b>Final:</b></dt><dd>No</dd>
607      * </dl>
608      * @return The {@code <Debug Option>} dependency.
609      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
610      */
611     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
612     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
613     private org.apache.commons.cli.Option getDebugOption()
614     {
615         final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Debug Option" );
616         assert _d != null : "'Debug Option' dependency not found.";
617         return _d;
618     }
619     /**
620      * Gets the {@code <Fail On Warnings Option>} dependency.
621      * <p>
622      *   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.
623      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
624      * </p>
625      * <dl>
626      *   <dt><b>Final:</b></dt><dd>No</dd>
627      * </dl>
628      * @return The {@code <Fail On Warnings Option>} dependency.
629      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
630      */
631     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
632     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
633     private org.apache.commons.cli.Option getFailOnWarningsOption()
634     {
635         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" );
636         assert _d != null : "'Fail On Warnings Option' dependency not found.";
637         return _d;
638     }
639     /**
640      * Gets the {@code <Locale>} dependency.
641      * <p>
642      *   This method returns the {@code <default>} object of the {@code <java.util.Locale>} specification at specification level 1.1.
643      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
644      * </p>
645      * <dl>
646      *   <dt><b>Final:</b></dt><dd>No</dd>
647      * </dl>
648      * @return The {@code <Locale>} dependency.
649      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
650      */
651     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
652     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
653     private java.util.Locale getLocale()
654     {
655         final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
656         assert _d != null : "'Locale' dependency not found.";
657         return _d;
658     }
659     /**
660      * Gets the {@code <Verbose Option>} dependency.
661      * <p>
662      *   This method returns the {@code <JOMC ⁑ CLI ⁑ Verbose Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2.
663      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
664      * </p>
665      * <dl>
666      *   <dt><b>Final:</b></dt><dd>No</dd>
667      * </dl>
668      * @return The {@code <Verbose Option>} dependency.
669      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
670      */
671     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
672     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
673     private org.apache.commons.cli.Option getVerboseOption()
674     {
675         final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Verbose Option" );
676         assert _d != null : "'Verbose Option' dependency not found.";
677         return _d;
678     }
679     // </editor-fold>
680     // SECTION-END
681     // SECTION-START[Properties]
682     // <editor-fold defaultstate="collapsed" desc=" Generated Properties ">
683     /**
684      * Gets the value of the {@code <Desc Pad>} property.
685      * <p><dl>
686      *   <dt><b>Final:</b></dt><dd>No</dd>
687      * </dl></p>
688      * @return The number of characters of padding to be prefixed to each description line.
689      * @throws org.jomc.ObjectManagementException if getting the property instance fails.
690      */
691     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
692     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
693     private int getDescPad()
694     {
695         final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Desc Pad" );
696         assert _p != null : "'Desc Pad' property not found.";
697         return _p.intValue();
698     }
699     /**
700      * Gets the value of the {@code <Help Command Name>} property.
701      * <p><dl>
702      *   <dt><b>Final:</b></dt><dd>No</dd>
703      * </dl></p>
704      * @return The name of the command used to request help.
705      * @throws org.jomc.ObjectManagementException if getting the property instance fails.
706      */
707     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
708     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
709     private java.lang.String getHelpCommandName()
710     {
711         final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Help Command Name" );
712         assert _p != null : "'Help Command Name' property not found.";
713         return _p;
714     }
715     /**
716      * Gets the value of the {@code <Left Pad>} property.
717      * <p><dl>
718      *   <dt><b>Final:</b></dt><dd>No</dd>
719      * </dl></p>
720      * @return The number of characters of padding to be prefixed to each line.
721      * @throws org.jomc.ObjectManagementException if getting the property instance fails.
722      */
723     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
724     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
725     private int getLeftPad()
726     {
727         final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Left Pad" );
728         assert _p != null : "'Left Pad' property not found.";
729         return _p.intValue();
730     }
731     /**
732      * Gets the value of the {@code <width>} property.
733      * <p><dl>
734      *   <dt><b>Final:</b></dt><dd>No</dd>
735      * </dl></p>
736      * @return The number of characters per line for the usage statement.
737      * @throws org.jomc.ObjectManagementException if getting the property instance fails.
738      */
739     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
740     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
741     private int getWidth()
742     {
743         final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "width" );
744         assert _p != null : "'width' property not found.";
745         return _p.intValue();
746     }
747     // </editor-fold>
748     // SECTION-END
749     // SECTION-START[Messages]
750     // <editor-fold defaultstate="collapsed" desc=" Generated Messages ">
751     /**
752      * Gets the text of the {@code <Default Exception Message>} message.
753      * <p><dl>
754      *   <dt><b>Languages:</b></dt>
755      *     <dd>English (default)</dd>
756      *     <dd>Deutsch</dd>
757      *   <dt><b>Final:</b></dt><dd>No</dd>
758      * </dl></p>
759      * @param locale The locale of the message to return.
760      * @return The text of the {@code <Default Exception Message>} message for {@code locale}.
761      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
762      */
763     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
764     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
765     private String getDefaultExceptionMessage( final java.util.Locale locale )
766     {
767         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Exception Message", locale );
768         assert _m != null : "'Default Exception Message' message not found.";
769         return _m;
770     }
771     /**
772      * Gets the text of the {@code <Default Log Level Info>} message.
773      * <p><dl>
774      *   <dt><b>Languages:</b></dt>
775      *     <dd>English (default)</dd>
776      *     <dd>Deutsch</dd>
777      *   <dt><b>Final:</b></dt><dd>No</dd>
778      * </dl></p>
779      * @param locale The locale of the message to return.
780      * @param defaultLogLevel Format argument.
781      * @return The text of the {@code <Default Log Level Info>} message for {@code locale}.
782      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
783      */
784     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
785     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
786     private String getDefaultLogLevelInfo( final java.util.Locale locale, final java.lang.String defaultLogLevel )
787     {
788         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Log Level Info", locale, defaultLogLevel );
789         assert _m != null : "'Default Log Level Info' message not found.";
790         return _m;
791     }
792     /**
793      * Gets the text of the {@code <Illegal Arguments Info>} message.
794      * <p><dl>
795      *   <dt><b>Languages:</b></dt>
796      *     <dd>English (default)</dd>
797      *     <dd>Deutsch</dd>
798      *   <dt><b>Final:</b></dt><dd>No</dd>
799      * </dl></p>
800      * @param locale The locale of the message to return.
801      * @param command Format argument.
802      * @param helpCommandName Format argument.
803      * @return The text of the {@code <Illegal Arguments Info>} message for {@code locale}.
804      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
805      */
806     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
807     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
808     private String getIllegalArgumentsInfo( final java.util.Locale locale, final java.lang.String command, final java.lang.String helpCommandName )
809     {
810         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Illegal Arguments Info", locale, command, helpCommandName );
811         assert _m != null : "'Illegal Arguments Info' message not found.";
812         return _m;
813     }
814     /**
815      * Gets the text of the {@code <Time Info>} message.
816      * <p><dl>
817      *   <dt><b>Languages:</b></dt>
818      *     <dd>English (default)</dd>
819      *     <dd>Deutsch</dd>
820      *   <dt><b>Final:</b></dt><dd>No</dd>
821      * </dl></p>
822      * @param locale The locale of the message to return.
823      * @param time Format argument.
824      * @return The text of the {@code <Time Info>} message for {@code locale}.
825      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
826      */
827     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
828     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
829     private String getTimeInfo( final java.util.Locale locale, final java.util.Date time )
830     {
831         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Time Info", locale, time );
832         assert _m != null : "'Time Info' message not found.";
833         return _m;
834     }
835     /**
836      * Gets the text of the {@code <Usage>} message.
837      * <p><dl>
838      *   <dt><b>Languages:</b></dt>
839      *     <dd>English (default)</dd>
840      *     <dd>Deutsch</dd>
841      *   <dt><b>Final:</b></dt><dd>No</dd>
842      * </dl></p>
843      * @param locale The locale of the message to return.
844      * @param helpCommandName Format argument.
845      * @return The text of the {@code <Usage>} message for {@code locale}.
846      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
847      */
848     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
849     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
850     private String getUsage( final java.util.Locale locale, final java.lang.String helpCommandName )
851     {
852         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Usage", locale, helpCommandName );
853         assert _m != null : "'Usage' message not found.";
854         return _m;
855     }
856     // </editor-fold>
857     // SECTION-END
858 
859 }