Jomc.java

  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. import java.io.BufferedReader;
  38. import java.io.IOException;
  39. import java.io.PrintWriter;
  40. import java.io.StringReader;
  41. import java.io.StringWriter;
  42. import java.util.Date;
  43. import java.util.logging.Level;
  44. import org.apache.commons.cli.CommandLine;
  45. import org.apache.commons.cli.HelpFormatter;
  46. import org.apache.commons.cli.Options;
  47. import org.apache.commons.cli.ParseException;
  48. import org.apache.commons.lang.StringUtils;
  49. import org.jomc.model.modlet.DefaultModelProcessor;
  50. import org.jomc.model.modlet.DefaultModelProvider;
  51. import org.jomc.modlet.DefaultModletProvider;

  52. // SECTION-START[Documentation]
  53. // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
  54. /**
  55.  * JOMC command line interface.
  56.  *
  57.  * <dl>
  58.  *   <dt><b>Identifier:</b></dt><dd>JOMC ⁑ CLI ⁑ Application</dd>
  59.  *   <dt><b>Name:</b></dt><dd>JOMC ⁑ CLI ⁑ Application</dd>
  60.  *   <dt><b>Abstract:</b></dt><dd>No</dd>
  61.  *   <dt><b>Final:</b></dt><dd>No</dd>
  62.  *   <dt><b>Stateless:</b></dt><dd>No</dd>
  63.  * </dl>
  64.  *
  65.  * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
  66.  * @version 1.9
  67.  */
  68. // </editor-fold>
  69. // SECTION-END
  70. // SECTION-START[Annotations]
  71. // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
  72. @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  73. // </editor-fold>
  74. // SECTION-END
  75. public final class Jomc
  76. {
  77.     // SECTION-START[Jomc]

  78.     /**
  79.      * Log level events are logged at by default.
  80.      *
  81.      * @see #getDefaultLogLevel()
  82.      */
  83.     private static final Level DEFAULT_LOG_LEVEL = Level.WARNING;

  84.     /**
  85.      * Default log level.
  86.      */
  87.     private static volatile Level defaultLogLevel;

  88.     /**
  89.      * Print writer of the instance.
  90.      */
  91.     private PrintWriter printWriter;

  92.     /**
  93.      * Log level of the instance.
  94.      */
  95.     private Level logLevel;

  96.     /**
  97.      * Greatest severity logged by the command.
  98.      */
  99.     private Level severity = Level.ALL;

  100.     /**
  101.      * Gets the print writer of the instance.
  102.      *
  103.      * @return The print writer of the instance.
  104.      *
  105.      * @see #setPrintWriter(java.io.PrintWriter)
  106.      */
  107.     public PrintWriter getPrintWriter()
  108.     {
  109.         if ( this.printWriter == null )
  110.         {
  111.             // JDK: As of JDK 6, "this.printWriter = System.console().writer()".
  112.             this.printWriter = new PrintWriter( System.out, true );
  113.         }

  114.         return this.printWriter;
  115.     }

  116.     /**
  117.      * Sets the print writer of the instance.
  118.      *
  119.      * @param value The new print writer of the instance or {@code null}.
  120.      *
  121.      * @see #getPrintWriter()
  122.      */
  123.     public void setPrintWriter( final PrintWriter value )
  124.     {
  125.         this.printWriter = value;
  126.     }

  127.     /**
  128.      * Gets the default log level events are logged at.
  129.      * <p>
  130.      * The default log level is controlled by system property {@code org.jomc.cli.Jomc.defaultLogLevel} holding the
  131.      * log level to log events at by default. If that property is not set, the {@code WARNING} default is returned.
  132.      * </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.         return defaultLogLevel;
  147.     }

  148.     /**
  149.      * Sets the default log level events are logged at.
  150.      *
  151.      * @param value The new default level events are logged at or {@code null}.
  152.      *
  153.      * @see #getDefaultLogLevel()
  154.      */
  155.     public static void setDefaultLogLevel( final Level value )
  156.     {
  157.         defaultLogLevel = value;
  158.     }

  159.     /**
  160.      * Gets the log level of the instance.
  161.      *
  162.      * @return The log level of the instance.
  163.      *
  164.      * @see #getDefaultLogLevel()
  165.      * @see #setLogLevel(java.util.logging.Level)
  166.      * @see #isLoggable(java.util.logging.Level)
  167.      */
  168.     public Level getLogLevel()
  169.     {
  170.         if ( this.logLevel == null )
  171.         {
  172.             this.logLevel = getDefaultLogLevel();

  173.             if ( this.isLoggable( Level.CONFIG ) )
  174.             {
  175.                 this.log( Level.CONFIG,
  176.                           this.getDefaultLogLevelInfo( this.getLocale(), this.logLevel.getLocalizedName() ), null );

  177.             }
  178.         }

  179.         return this.logLevel;
  180.     }

  181.     /**
  182.      * Sets the log level of the instance.
  183.      *
  184.      * @param value The new log level of the instance or {@code null}.
  185.      *
  186.      * @see #getLogLevel()
  187.      * @see #isLoggable(java.util.logging.Level)
  188.      */
  189.     public void setLogLevel( final Level value )
  190.     {
  191.         this.logLevel = value;
  192.     }

  193.     /**
  194.      * Checks if a message at a given level is provided to the listeners of the instance.
  195.      *
  196.      * @param level The level to test.
  197.      *
  198.      * @return {@code true}, if messages at {@code level} are provided to the listeners of the instance;
  199.      * {@code false}, if messages at {@code level} are not provided to the listeners of the instance.
  200.      *
  201.      * @throws NullPointerException if {@code level} is {@code null}.
  202.      *
  203.      * @see #getLogLevel()
  204.      * @see #setLogLevel(java.util.logging.Level)
  205.      */
  206.     public boolean isLoggable( final Level level )
  207.     {
  208.         if ( level == null )
  209.         {
  210.             throw new NullPointerException( "level" );
  211.         }

  212.         return level.intValue() >= this.getLogLevel().intValue();
  213.     }

  214.     /**
  215.      * Processes the given arguments and executes the corresponding command.
  216.      *
  217.      * @param args Arguments to process.
  218.      *
  219.      * @return Status code.
  220.      *
  221.      * @see Command#STATUS_SUCCESS
  222.      * @see Command#STATUS_FAILURE
  223.      */
  224.     public int jomc( final String[] args )
  225.     {
  226.         Command cmd = null;
  227.         this.severity = Level.ALL;

  228.         try
  229.         {
  230.             DefaultModelProvider.setDefaultModuleLocation( "META-INF/jomc-cli.xml" );
  231.             DefaultModelProcessor.setDefaultTransformerLocation( "META-INF/jomc-cli.xsl" );
  232.             DefaultModletProvider.setDefaultModletLocation( "META-INF/jomc-modlet.xml" );

  233.             final StringBuilder commandInfo = new StringBuilder();

  234.             for ( final Command c : this.getCommands() )
  235.             {
  236.                 if ( cmd == null && args != null && args.length > 0
  237.                          && ( args[0].equals( c.getName() ) || args[0].equals( c.getAbbreviatedName() ) ) )
  238.                 {
  239.                     cmd = c;
  240.                 }

  241.                 commandInfo.append( StringUtils.rightPad( c.getName(), 25 ) ).append( " : " ).
  242.                     append( c.getShortDescription( this.getLocale() ) ).append( " (" ).append( c.getAbbreviatedName() ).
  243.                     append( ")" ).append( System.getProperty( "line.separator", "\n" ) );

  244.             }

  245.             if ( cmd == null )
  246.             {
  247.                 this.getPrintWriter().println( this.getUsage( this.getLocale(), this.getHelpCommandName() ) );
  248.                 this.getPrintWriter().println();
  249.                 this.getPrintWriter().println( commandInfo.toString() );
  250.                 return Command.STATUS_FAILURE;
  251.             }

  252.             final String[] commandArguments = new String[ args.length - 1 ];
  253.             System.arraycopy( args, 1, commandArguments, 0, commandArguments.length );

  254.             final Options options = cmd.getOptions();
  255.             options.addOption( this.getDebugOption() );
  256.             options.addOption( this.getVerboseOption() );
  257.             options.addOption( this.getFailOnWarningsOption() );

  258.             if ( commandArguments.length > 0 && this.getHelpCommandName().equals( commandArguments[0] ) )
  259.             {
  260.                 final StringWriter usage = new StringWriter();
  261.                 final StringWriter opts = new StringWriter();
  262.                 final HelpFormatter formatter = new HelpFormatter();

  263.                 PrintWriter pw = new PrintWriter( usage );
  264.                 formatter.printUsage( pw, this.getWidth(), cmd.getName(), options );
  265.                 pw.close();
  266.                 assert !pw.checkError() : "Unexpected error printing usage.";

  267.                 pw = new PrintWriter( opts );
  268.                 formatter.printOptions( pw, this.getWidth(), options, this.getLeftPad(), this.getDescPad() );
  269.                 pw.close();
  270.                 assert !pw.checkError() : "Unexpected error printing options.";

  271.                 this.getPrintWriter().println( cmd.getShortDescription( this.getLocale() ) );
  272.                 this.getPrintWriter().println();
  273.                 this.getPrintWriter().println( usage.toString() );
  274.                 this.getPrintWriter().println( opts.toString() );
  275.                 this.getPrintWriter().println();
  276.                 this.getPrintWriter().println( cmd.getLongDescription( this.getLocale() ) );
  277.                 this.getPrintWriter().println();
  278.                 return Command.STATUS_SUCCESS;
  279.             }

  280.             cmd.getListeners().add( new Command.Listener()
  281.             {

  282.                 public void onLog( final Level level, final String message, final Throwable t )
  283.                 {
  284.                     log( level, message, t );
  285.                 }

  286.             } );

  287.             DefaultModelProvider.setDefaultModuleLocation( null );
  288.             DefaultModelProcessor.setDefaultTransformerLocation( null );
  289.             DefaultModletProvider.setDefaultModletLocation( null );

  290.             final CommandLine commandLine = this.getCommandLineParser().parse( options, commandArguments );
  291.             final boolean debug = commandLine.hasOption( this.getDebugOption().getOpt() );
  292.             final boolean verbose = commandLine.hasOption( this.getVerboseOption().getOpt() );
  293.             Level debugLevel = Level.ALL;

  294.             if ( debug )
  295.             {
  296.                 final String debugOption = commandLine.getOptionValue( this.getDebugOption().getOpt() );
  297.                 if ( debugOption != null )
  298.                 {
  299.                     debugLevel = Level.parse( debugOption );
  300.                 }
  301.             }

  302.             if ( debug || verbose )
  303.             {
  304.                 this.setLogLevel( debug ? debugLevel : Level.INFO );
  305.             }

  306.             cmd.setLogLevel( this.getLogLevel() );

  307.             if ( this.isLoggable( Level.FINER ) )
  308.             {
  309.                 for ( int i = 0; i < args.length; i++ )
  310.                 {
  311.                     this.log( Level.FINER, new StringBuilder().append( "[" ).append( i ).append( "] -> '" ).
  312.                               append( args[i] ).append( "'" ).append( System.getProperty( "line.separator", "\n" ) ).
  313.                               toString(), null );

  314.                 }
  315.             }

  316.             final boolean failOnWarnings = commandLine.hasOption( this.getFailOnWarningsOption().getOpt() );

  317.             final int status = cmd.execute( commandLine );
  318.             if ( status == Command.STATUS_SUCCESS && failOnWarnings
  319.                      && this.severity.intValue() >= Level.WARNING.intValue() )
  320.             {
  321.                 return Command.STATUS_FAILURE;
  322.             }

  323.             return status;
  324.         }
  325.         catch ( final ParseException e )
  326.         {
  327.             this.log( Level.SEVERE, this.getIllegalArgumentsInfo(
  328.                       this.getLocale(), cmd.getName(), this.getHelpCommandName() ), e );

  329.             return Command.STATUS_FAILURE;
  330.         }
  331.         catch ( final Throwable t )
  332.         {
  333.             this.log( Level.SEVERE, null, t );
  334.             return Command.STATUS_FAILURE;
  335.         }
  336.         finally
  337.         {
  338.             DefaultModelProvider.setDefaultModuleLocation( null );
  339.             DefaultModelProcessor.setDefaultTransformerLocation( null );
  340.             DefaultModletProvider.setDefaultModletLocation( null );
  341.             this.getPrintWriter().flush();
  342.             this.severity = Level.ALL;
  343.         }
  344.     }

  345.     /**
  346.      * Main entry point.
  347.      *
  348.      * @param args The application arguments.
  349.      */
  350.     public static void main( final String[] args )
  351.     {
  352.         System.exit( run( args ) );
  353.     }

  354.     /**
  355.      * Main entry point without exiting the VM.
  356.      *
  357.      * @param args The application arguments.
  358.      *
  359.      * @return Status code.
  360.      *
  361.      * @see Command#STATUS_SUCCESS
  362.      * @see Command#STATUS_FAILURE
  363.      */
  364.     public static int run( final String[] args )
  365.     {
  366.         return new Jomc().jomc( args );
  367.     }

  368.     /**
  369.      * Logs to the print writer of the instance.
  370.      *
  371.      * @param level The level of the event.
  372.      * @param message The message of the event or {@code null}.
  373.      * @param throwable The throwable of the event {@code null}.
  374.      *
  375.      * @throws NullPointerException if {@code level} is {@code null}.
  376.      */
  377.     private void log( final Level level, final String message, final Throwable throwable )
  378.     {
  379.         if ( level == null )
  380.         {
  381.             throw new NullPointerException( "level" );
  382.         }

  383.         if ( this.severity.intValue() < level.intValue() )
  384.         {
  385.             this.severity = level;
  386.         }

  387.         if ( this.isLoggable( level ) )
  388.         {
  389.             if ( message != null )
  390.             {
  391.                 this.getPrintWriter().print( this.formatLogLines( level, "" ) );
  392.                 this.getPrintWriter().print( this.formatLogLines( level, message ) );
  393.             }

  394.             if ( throwable != null )
  395.             {
  396.                 this.getPrintWriter().print( this.formatLogLines( level, "" ) );
  397.                 final String m = getMessage( throwable );

  398.                 if ( m != null && m.length() > 0 )
  399.                 {
  400.                     this.getPrintWriter().print( this.formatLogLines( level, m ) );
  401.                 }
  402.                 else
  403.                 {
  404.                     this.getPrintWriter().print( this.formatLogLines(
  405.                         level, this.getDefaultExceptionMessage( this.getLocale() ) ) );

  406.                 }

  407.                 if ( this.getLogLevel().intValue() < Level.INFO.intValue() )
  408.                 {
  409.                     final StringWriter stackTrace = new StringWriter();
  410.                     final PrintWriter pw = new PrintWriter( stackTrace );
  411.                     throwable.printStackTrace( pw );
  412.                     pw.flush();
  413.                     this.getPrintWriter().print( this.formatLogLines( level, stackTrace.toString() ) );
  414.                 }
  415.             }
  416.         }

  417.         this.getPrintWriter().flush();
  418.     }

  419.     private String formatLogLines( final Level level, final String text )
  420.     {
  421.         BufferedReader reader = null;
  422.         boolean suppressExceptionOnClose = true;

  423.         try
  424.         {
  425.             final StringBuilder lines = new StringBuilder( text.length() );
  426.             reader = new BufferedReader( new StringReader( text ) );

  427.             String line;
  428.             while ( ( line = reader.readLine() ) != null )
  429.             {
  430.                 final boolean debug = this.getLogLevel().intValue() < Level.INFO.intValue();
  431.                 lines.append( "[" ).append( level.getLocalizedName() );

  432.                 if ( debug )
  433.                 {
  434.                     lines.append( "|" ).append( Thread.currentThread().getName() ).append( "|" ).
  435.                         append( this.getTimeInfo( this.getLocale(), new Date( System.currentTimeMillis() ) ) );

  436.                 }

  437.                 lines.append( "] " ).append( line ).append( System.getProperty( "line.separator", "\n" ) );
  438.             }

  439.             suppressExceptionOnClose = false;
  440.             return lines.toString();
  441.         }
  442.         catch ( final IOException e )
  443.         {
  444.             throw new AssertionError( e );
  445.         }
  446.         finally
  447.         {
  448.             try
  449.             {
  450.                 if ( reader != null )
  451.                 {
  452.                     reader.close();
  453.                 }
  454.             }
  455.             catch ( final IOException e )
  456.             {
  457.                 if ( suppressExceptionOnClose )
  458.                 {
  459.                     this.log( Level.SEVERE, getMessage( e ), e );
  460.                 }
  461.                 else
  462.                 {
  463.                     throw new AssertionError( e );
  464.                 }
  465.             }
  466.         }
  467.     }

  468.     private static String getMessage( final Throwable t )
  469.     {
  470.         return t != null
  471.                    ? t.getMessage() != null && t.getMessage().trim().length() > 0
  472.                          ? t.getMessage()
  473.                          : getMessage( t.getCause() )
  474.                    : null;

  475.     }

  476.     // SECTION-END
  477.     // SECTION-START[Constructors]
  478.     // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
  479.     /** Creates a new {@code Jomc} instance. */
  480.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  481.     public Jomc()
  482.     {
  483.         // SECTION-START[Default Constructor]
  484.         super();
  485.         // SECTION-END
  486.     }
  487.     // </editor-fold>
  488.     // SECTION-END
  489.     // SECTION-START[Dependencies]
  490.     // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies ">
  491.     /**
  492.      * Gets the {@code <Command Line Parser>} dependency.
  493.      * <p>
  494.      *   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.
  495.      *   That specification does not apply to any scope. A new object is returned whenever requested.
  496.      * </p>
  497.      * <dl>
  498.      *   <dt><b>Final:</b></dt><dd>No</dd>
  499.      * </dl>
  500.      * @return The {@code <Command Line Parser>} dependency.
  501.      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
  502.      */
  503.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  504.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  505.     private org.apache.commons.cli.CommandLineParser getCommandLineParser()
  506.     {
  507.         final org.apache.commons.cli.CommandLineParser _d = (org.apache.commons.cli.CommandLineParser) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Command Line Parser" );
  508.         assert _d != null : "'Command Line Parser' dependency not found.";
  509.         return _d;
  510.     }
  511.     /**
  512.      * Gets the {@code <Commands>} dependency.
  513.      * <p>
  514.      *   This method returns any available object of the {@code <JOMC ⁑ CLI ⁑ Command>} specification at specification level 1.0.
  515.      *   That specification does not apply to any scope. A new object is returned whenever requested.
  516.      * </p>
  517.      * <dl>
  518.      *   <dt><b>Final:</b></dt><dd>No</dd>
  519.      * </dl>
  520.      * @return The {@code <Commands>} dependency.
  521.      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
  522.      */
  523.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  524.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  525.     private org.jomc.cli.Command[] getCommands()
  526.     {
  527.         final org.jomc.cli.Command[] _d = (org.jomc.cli.Command[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Commands" );
  528.         assert _d != null : "'Commands' dependency not found.";
  529.         return _d;
  530.     }
  531.     /**
  532.      * Gets the {@code <Debug Option>} dependency.
  533.      * <p>
  534.      *   This method returns the {@code <JOMC ⁑ CLI ⁑ Debug Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2.
  535.      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
  536.      * </p>
  537.      * <dl>
  538.      *   <dt><b>Final:</b></dt><dd>No</dd>
  539.      * </dl>
  540.      * @return The {@code <Debug Option>} dependency.
  541.      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
  542.      */
  543.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  544.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  545.     private org.apache.commons.cli.Option getDebugOption()
  546.     {
  547.         final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Debug Option" );
  548.         assert _d != null : "'Debug Option' dependency not found.";
  549.         return _d;
  550.     }
  551.     /**
  552.      * Gets the {@code <Fail On Warnings Option>} dependency.
  553.      * <p>
  554.      *   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.
  555.      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
  556.      * </p>
  557.      * <dl>
  558.      *   <dt><b>Final:</b></dt><dd>No</dd>
  559.      * </dl>
  560.      * @return The {@code <Fail On Warnings Option>} dependency.
  561.      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
  562.      */
  563.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  564.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  565.     private org.apache.commons.cli.Option getFailOnWarningsOption()
  566.     {
  567.         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" );
  568.         assert _d != null : "'Fail On Warnings Option' dependency not found.";
  569.         return _d;
  570.     }
  571.     /**
  572.      * Gets the {@code <Locale>} dependency.
  573.      * <p>
  574.      *   This method returns the {@code <default>} object of the {@code <java.util.Locale>} specification at specification level 1.1.
  575.      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
  576.      * </p>
  577.      * <dl>
  578.      *   <dt><b>Final:</b></dt><dd>No</dd>
  579.      * </dl>
  580.      * @return The {@code <Locale>} dependency.
  581.      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
  582.      */
  583.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  584.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  585.     private java.util.Locale getLocale()
  586.     {
  587.         final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" );
  588.         assert _d != null : "'Locale' dependency not found.";
  589.         return _d;
  590.     }
  591.     /**
  592.      * Gets the {@code <Verbose Option>} dependency.
  593.      * <p>
  594.      *   This method returns the {@code <JOMC ⁑ CLI ⁑ Verbose Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2.
  595.      *   That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.
  596.      * </p>
  597.      * <dl>
  598.      *   <dt><b>Final:</b></dt><dd>No</dd>
  599.      * </dl>
  600.      * @return The {@code <Verbose Option>} dependency.
  601.      * @throws org.jomc.ObjectManagementException if getting the dependency instance fails.
  602.      */
  603.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  604.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  605.     private org.apache.commons.cli.Option getVerboseOption()
  606.     {
  607.         final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Verbose Option" );
  608.         assert _d != null : "'Verbose Option' dependency not found.";
  609.         return _d;
  610.     }
  611.     // </editor-fold>
  612.     // SECTION-END
  613.     // SECTION-START[Properties]
  614.     // <editor-fold defaultstate="collapsed" desc=" Generated Properties ">
  615.     /**
  616.      * Gets the value of the {@code <Desc Pad>} property.
  617.      * <p><dl>
  618.      *   <dt><b>Final:</b></dt><dd>No</dd>
  619.      * </dl></p>
  620.      * @return The number of characters of padding to be prefixed to each description line.
  621.      * @throws org.jomc.ObjectManagementException if getting the property instance fails.
  622.      */
  623.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  624.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  625.     private int getDescPad()
  626.     {
  627.         final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Desc Pad" );
  628.         assert _p != null : "'Desc Pad' property not found.";
  629.         return _p.intValue();
  630.     }
  631.     /**
  632.      * Gets the value of the {@code <Help Command Name>} property.
  633.      * <p><dl>
  634.      *   <dt><b>Final:</b></dt><dd>No</dd>
  635.      * </dl></p>
  636.      * @return The name of the command used to request help.
  637.      * @throws org.jomc.ObjectManagementException if getting the property instance fails.
  638.      */
  639.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  640.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  641.     private java.lang.String getHelpCommandName()
  642.     {
  643.         final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Help Command Name" );
  644.         assert _p != null : "'Help Command Name' property not found.";
  645.         return _p;
  646.     }
  647.     /**
  648.      * Gets the value of the {@code <Left Pad>} property.
  649.      * <p><dl>
  650.      *   <dt><b>Final:</b></dt><dd>No</dd>
  651.      * </dl></p>
  652.      * @return The number of characters of padding to be prefixed to each line.
  653.      * @throws org.jomc.ObjectManagementException if getting the property instance fails.
  654.      */
  655.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  656.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  657.     private int getLeftPad()
  658.     {
  659.         final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Left Pad" );
  660.         assert _p != null : "'Left Pad' property not found.";
  661.         return _p.intValue();
  662.     }
  663.     /**
  664.      * Gets the value of the {@code <width>} property.
  665.      * <p><dl>
  666.      *   <dt><b>Final:</b></dt><dd>No</dd>
  667.      * </dl></p>
  668.      * @return The number of characters per line for the usage statement.
  669.      * @throws org.jomc.ObjectManagementException if getting the property 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 int getWidth()
  674.     {
  675.         final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "width" );
  676.         assert _p != null : "'width' property not found.";
  677.         return _p.intValue();
  678.     }
  679.     // </editor-fold>
  680.     // SECTION-END
  681.     // SECTION-START[Messages]
  682.     // <editor-fold defaultstate="collapsed" desc=" Generated Messages ">
  683.     /**
  684.      * Gets the text of the {@code <Default Exception Message>} message.
  685.      * <p><dl>
  686.      *   <dt><b>Languages:</b></dt>
  687.      *     <dd>English (default)</dd>
  688.      *     <dd>Deutsch</dd>
  689.      *   <dt><b>Final:</b></dt><dd>No</dd>
  690.      * </dl></p>
  691.      * @param locale The locale of the message to return.
  692.      * @return The text of the {@code <Default Exception Message>} message for {@code locale}.
  693.      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
  694.      */
  695.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  696.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  697.     private String getDefaultExceptionMessage( final java.util.Locale locale )
  698.     {
  699.         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Exception Message", locale );
  700.         assert _m != null : "'Default Exception Message' message not found.";
  701.         return _m;
  702.     }
  703.     /**
  704.      * Gets the text of the {@code <Default Log Level Info>} message.
  705.      * <p><dl>
  706.      *   <dt><b>Languages:</b></dt>
  707.      *     <dd>English (default)</dd>
  708.      *     <dd>Deutsch</dd>
  709.      *   <dt><b>Final:</b></dt><dd>No</dd>
  710.      * </dl></p>
  711.      * @param locale The locale of the message to return.
  712.      * @param defaultLogLevel Format argument.
  713.      * @return The text of the {@code <Default Log Level Info>} message for {@code locale}.
  714.      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
  715.      */
  716.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  717.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  718.     private String getDefaultLogLevelInfo( final java.util.Locale locale, final java.lang.String defaultLogLevel )
  719.     {
  720.         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Log Level Info", locale, defaultLogLevel );
  721.         assert _m != null : "'Default Log Level Info' message not found.";
  722.         return _m;
  723.     }
  724.     /**
  725.      * Gets the text of the {@code <Illegal Arguments Info>} message.
  726.      * <p><dl>
  727.      *   <dt><b>Languages:</b></dt>
  728.      *     <dd>English (default)</dd>
  729.      *     <dd>Deutsch</dd>
  730.      *   <dt><b>Final:</b></dt><dd>No</dd>
  731.      * </dl></p>
  732.      * @param locale The locale of the message to return.
  733.      * @param command Format argument.
  734.      * @param helpCommandName Format argument.
  735.      * @return The text of the {@code <Illegal Arguments Info>} message for {@code locale}.
  736.      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
  737.      */
  738.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  739.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  740.     private String getIllegalArgumentsInfo( final java.util.Locale locale, final java.lang.String command, final java.lang.String helpCommandName )
  741.     {
  742.         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Illegal Arguments Info", locale, command, helpCommandName );
  743.         assert _m != null : "'Illegal Arguments Info' message not found.";
  744.         return _m;
  745.     }
  746.     /**
  747.      * Gets the text of the {@code <Time Info>} message.
  748.      * <p><dl>
  749.      *   <dt><b>Languages:</b></dt>
  750.      *     <dd>English (default)</dd>
  751.      *     <dd>Deutsch</dd>
  752.      *   <dt><b>Final:</b></dt><dd>No</dd>
  753.      * </dl></p>
  754.      * @param locale The locale of the message to return.
  755.      * @param time Format argument.
  756.      * @return The text of the {@code <Time Info>} message for {@code locale}.
  757.      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
  758.      */
  759.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  760.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  761.     private String getTimeInfo( final java.util.Locale locale, final java.util.Date time )
  762.     {
  763.         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Time Info", locale, time );
  764.         assert _m != null : "'Time Info' message not found.";
  765.         return _m;
  766.     }
  767.     /**
  768.      * Gets the text of the {@code <Usage>} message.
  769.      * <p><dl>
  770.      *   <dt><b>Languages:</b></dt>
  771.      *     <dd>English (default)</dd>
  772.      *     <dd>Deutsch</dd>
  773.      *   <dt><b>Final:</b></dt><dd>No</dd>
  774.      * </dl></p>
  775.      * @param locale The locale of the message to return.
  776.      * @param helpCommandName Format argument.
  777.      * @return The text of the {@code <Usage>} message for {@code locale}.
  778.      * @throws org.jomc.ObjectManagementException if getting the message instance fails.
  779.      */
  780.     @SuppressWarnings({"unchecked", "unused", "PMD.UnnecessaryFullyQualifiedName"})
  781.     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
  782.     private String getUsage( final java.util.Locale locale, final java.lang.String helpCommandName )
  783.     {
  784.         final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Usage", locale, helpCommandName );
  785.         assert _m != null : "'Usage' message not found.";
  786.         return _m;
  787.     }
  788.     // </editor-fold>
  789.     // SECTION-END

  790. }