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, 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 4948 2014-03-26 00:59:29Z 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.7 |
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.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
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 | * @see #getDefaultLogLevel() |
84 | */ |
85 | private static final Level DEFAULT_LOG_LEVEL = Level.WARNING; |
86 | |
87 | /** Default log level. */ |
88 | private static volatile Level defaultLogLevel; |
89 | |
90 | /** Print writer of the instance. */ |
91 | private PrintWriter printWriter; |
92 | |
93 | /** Log level of the instance. */ |
94 | private Level logLevel; |
95 | |
96 | /** Greatest severity logged by the command. */ |
97 | private Level severity = Level.ALL; |
98 | |
99 | /** |
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 |
526 | ? t.getMessage() != null && t.getMessage().trim().length() > 0 |
527 | ? t.getMessage() |
528 | : getMessage( t.getCause() ) |
529 | : null; |
530 | |
531 | } |
532 | |
533 | // SECTION-END |
534 | // SECTION-START[Constructors] |
535 | // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> |
536 | /** Creates a new {@code Jomc} instance. */ |
537 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
538 | public Jomc() |
539 | { |
540 | // SECTION-START[Default Constructor] |
541 | super(); |
542 | // SECTION-END |
543 | } |
544 | // </editor-fold> |
545 | // SECTION-END |
546 | // SECTION-START[Dependencies] |
547 | // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies "> |
548 | /** |
549 | * Gets the {@code <Command Line Parser>} dependency. |
550 | * <p> |
551 | * 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. |
552 | * That specification does not apply to any scope. A new object is returned whenever requested. |
553 | * </p> |
554 | * <dl> |
555 | * <dt><b>Final:</b></dt><dd>No</dd> |
556 | * </dl> |
557 | * @return The {@code <Command Line Parser>} dependency. |
558 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
559 | */ |
560 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
561 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
562 | private org.apache.commons.cli.CommandLineParser getCommandLineParser() |
563 | { |
564 | final org.apache.commons.cli.CommandLineParser _d = (org.apache.commons.cli.CommandLineParser) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Command Line Parser" ); |
565 | assert _d != null : "'Command Line Parser' dependency not found."; |
566 | return _d; |
567 | } |
568 | /** |
569 | * Gets the {@code <Commands>} dependency. |
570 | * <p> |
571 | * This method returns any available object of the {@code <JOMC ⁑ CLI ⁑ Command>} specification at specification level 1.0. |
572 | * That specification does not apply to any scope. A new object is returned whenever requested. |
573 | * </p> |
574 | * <dl> |
575 | * <dt><b>Final:</b></dt><dd>No</dd> |
576 | * </dl> |
577 | * @return The {@code <Commands>} dependency. |
578 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
579 | */ |
580 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
581 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
582 | private org.jomc.cli.Command[] getCommands() |
583 | { |
584 | final org.jomc.cli.Command[] _d = (org.jomc.cli.Command[]) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Commands" ); |
585 | assert _d != null : "'Commands' dependency not found."; |
586 | return _d; |
587 | } |
588 | /** |
589 | * Gets the {@code <Debug Option>} dependency. |
590 | * <p> |
591 | * This method returns the {@code <JOMC ⁑ CLI ⁑ Debug Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2. |
592 | * That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance. |
593 | * </p> |
594 | * <dl> |
595 | * <dt><b>Final:</b></dt><dd>No</dd> |
596 | * </dl> |
597 | * @return The {@code <Debug Option>} dependency. |
598 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
599 | */ |
600 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
601 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
602 | private org.apache.commons.cli.Option getDebugOption() |
603 | { |
604 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Debug Option" ); |
605 | assert _d != null : "'Debug Option' dependency not found."; |
606 | return _d; |
607 | } |
608 | /** |
609 | * Gets the {@code <Fail On Warnings Option>} dependency. |
610 | * <p> |
611 | * 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. |
612 | * That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance. |
613 | * </p> |
614 | * <dl> |
615 | * <dt><b>Final:</b></dt><dd>No</dd> |
616 | * </dl> |
617 | * @return The {@code <Fail On Warnings Option>} dependency. |
618 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
619 | */ |
620 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
621 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
622 | private org.apache.commons.cli.Option getFailOnWarningsOption() |
623 | { |
624 | 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" ); |
625 | assert _d != null : "'Fail On Warnings Option' dependency not found."; |
626 | return _d; |
627 | } |
628 | /** |
629 | * Gets the {@code <Locale>} dependency. |
630 | * <p> |
631 | * This method returns the {@code <default>} object of the {@code <java.util.Locale>} specification at specification level 1.1. |
632 | * That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance. |
633 | * </p> |
634 | * <dl> |
635 | * <dt><b>Final:</b></dt><dd>No</dd> |
636 | * </dl> |
637 | * @return The {@code <Locale>} dependency. |
638 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
639 | */ |
640 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
641 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
642 | private java.util.Locale getLocale() |
643 | { |
644 | final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" ); |
645 | assert _d != null : "'Locale' dependency not found."; |
646 | return _d; |
647 | } |
648 | /** |
649 | * Gets the {@code <Verbose Option>} dependency. |
650 | * <p> |
651 | * This method returns the {@code <JOMC ⁑ CLI ⁑ Verbose Option>} object of the {@code <JOMC ⁑ CLI ⁑ Application Option>} specification at specification level 1.2. |
652 | * That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance. |
653 | * </p> |
654 | * <dl> |
655 | * <dt><b>Final:</b></dt><dd>No</dd> |
656 | * </dl> |
657 | * @return The {@code <Verbose Option>} dependency. |
658 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
659 | */ |
660 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
661 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
662 | private org.apache.commons.cli.Option getVerboseOption() |
663 | { |
664 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Verbose Option" ); |
665 | assert _d != null : "'Verbose Option' dependency not found."; |
666 | return _d; |
667 | } |
668 | // </editor-fold> |
669 | // SECTION-END |
670 | // SECTION-START[Properties] |
671 | // <editor-fold defaultstate="collapsed" desc=" Generated Properties "> |
672 | /** |
673 | * Gets the value of the {@code <Desc Pad>} property. |
674 | * <p><dl> |
675 | * <dt><b>Final:</b></dt><dd>No</dd> |
676 | * </dl></p> |
677 | * @return The number of characters of padding to be prefixed to each description line. |
678 | * @throws org.jomc.ObjectManagementException if getting the property instance fails. |
679 | */ |
680 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
681 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
682 | private int getDescPad() |
683 | { |
684 | final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Desc Pad" ); |
685 | assert _p != null : "'Desc Pad' property not found."; |
686 | return _p.intValue(); |
687 | } |
688 | /** |
689 | * Gets the value of the {@code <Help Command Name>} property. |
690 | * <p><dl> |
691 | * <dt><b>Final:</b></dt><dd>No</dd> |
692 | * </dl></p> |
693 | * @return The name of the command used to request help. |
694 | * @throws org.jomc.ObjectManagementException if getting the property instance fails. |
695 | */ |
696 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
697 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
698 | private java.lang.String getHelpCommandName() |
699 | { |
700 | final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Help Command Name" ); |
701 | assert _p != null : "'Help Command Name' property not found."; |
702 | return _p; |
703 | } |
704 | /** |
705 | * Gets the value of the {@code <Left Pad>} property. |
706 | * <p><dl> |
707 | * <dt><b>Final:</b></dt><dd>No</dd> |
708 | * </dl></p> |
709 | * @return The number of characters of padding to be prefixed to each line. |
710 | * @throws org.jomc.ObjectManagementException if getting the property instance fails. |
711 | */ |
712 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
713 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
714 | private int getLeftPad() |
715 | { |
716 | final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "Left Pad" ); |
717 | assert _p != null : "'Left Pad' property not found."; |
718 | return _p.intValue(); |
719 | } |
720 | /** |
721 | * Gets the value of the {@code <width>} property. |
722 | * <p><dl> |
723 | * <dt><b>Final:</b></dt><dd>No</dd> |
724 | * </dl></p> |
725 | * @return The number of characters per line for the usage statement. |
726 | * @throws org.jomc.ObjectManagementException if getting the property instance fails. |
727 | */ |
728 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
729 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
730 | private int getWidth() |
731 | { |
732 | final java.lang.Integer _p = (java.lang.Integer) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "width" ); |
733 | assert _p != null : "'width' property not found."; |
734 | return _p.intValue(); |
735 | } |
736 | // </editor-fold> |
737 | // SECTION-END |
738 | // SECTION-START[Messages] |
739 | // <editor-fold defaultstate="collapsed" desc=" Generated Messages "> |
740 | /** |
741 | * Gets the text of the {@code <Default Exception Message>} message. |
742 | * <p><dl> |
743 | * <dt><b>Languages:</b></dt> |
744 | * <dd>English (default)</dd> |
745 | * <dd>Deutsch</dd> |
746 | * <dt><b>Final:</b></dt><dd>No</dd> |
747 | * </dl></p> |
748 | * @param locale The locale of the message to return. |
749 | * @return The text of the {@code <Default Exception Message>} message for {@code locale}. |
750 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
751 | */ |
752 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
753 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
754 | private String getDefaultExceptionMessage( final java.util.Locale locale ) |
755 | { |
756 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Exception Message", locale ); |
757 | assert _m != null : "'Default Exception Message' message not found."; |
758 | return _m; |
759 | } |
760 | /** |
761 | * Gets the text of the {@code <Default Log Level Info>} message. |
762 | * <p><dl> |
763 | * <dt><b>Languages:</b></dt> |
764 | * <dd>English (default)</dd> |
765 | * <dd>Deutsch</dd> |
766 | * <dt><b>Final:</b></dt><dd>No</dd> |
767 | * </dl></p> |
768 | * @param locale The locale of the message to return. |
769 | * @param defaultLogLevel Format argument. |
770 | * @return The text of the {@code <Default Log Level Info>} message for {@code locale}. |
771 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
772 | */ |
773 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
774 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
775 | private String getDefaultLogLevelInfo( final java.util.Locale locale, final java.lang.String defaultLogLevel ) |
776 | { |
777 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Default Log Level Info", locale, defaultLogLevel ); |
778 | assert _m != null : "'Default Log Level Info' message not found."; |
779 | return _m; |
780 | } |
781 | /** |
782 | * Gets the text of the {@code <Illegal Arguments Info>} message. |
783 | * <p><dl> |
784 | * <dt><b>Languages:</b></dt> |
785 | * <dd>English (default)</dd> |
786 | * <dd>Deutsch</dd> |
787 | * <dt><b>Final:</b></dt><dd>No</dd> |
788 | * </dl></p> |
789 | * @param locale The locale of the message to return. |
790 | * @param command Format argument. |
791 | * @param helpCommandName Format argument. |
792 | * @return The text of the {@code <Illegal Arguments Info>} message for {@code locale}. |
793 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
794 | */ |
795 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
796 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
797 | private String getIllegalArgumentsInfo( final java.util.Locale locale, final java.lang.String command, final java.lang.String helpCommandName ) |
798 | { |
799 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Illegal Arguments Info", locale, command, helpCommandName ); |
800 | assert _m != null : "'Illegal Arguments Info' message not found."; |
801 | return _m; |
802 | } |
803 | /** |
804 | * Gets the text of the {@code <Time Info>} message. |
805 | * <p><dl> |
806 | * <dt><b>Languages:</b></dt> |
807 | * <dd>English (default)</dd> |
808 | * <dd>Deutsch</dd> |
809 | * <dt><b>Final:</b></dt><dd>No</dd> |
810 | * </dl></p> |
811 | * @param locale The locale of the message to return. |
812 | * @param time Format argument. |
813 | * @return The text of the {@code <Time Info>} message for {@code locale}. |
814 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
815 | */ |
816 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
817 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
818 | private String getTimeInfo( final java.util.Locale locale, final java.util.Date time ) |
819 | { |
820 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Time Info", locale, time ); |
821 | assert _m != null : "'Time Info' message not found."; |
822 | return _m; |
823 | } |
824 | /** |
825 | * Gets the text of the {@code <Usage>} message. |
826 | * <p><dl> |
827 | * <dt><b>Languages:</b></dt> |
828 | * <dd>English (default)</dd> |
829 | * <dd>Deutsch</dd> |
830 | * <dt><b>Final:</b></dt><dd>No</dd> |
831 | * </dl></p> |
832 | * @param locale The locale of the message to return. |
833 | * @param helpCommandName Format argument. |
834 | * @return The text of the {@code <Usage>} message for {@code locale}. |
835 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
836 | */ |
837 | @SuppressWarnings({"unused", "PMD.UnnecessaryFullyQualifiedName"}) |
838 | @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.7", comments = "See http://www.jomc.org/jomc/1.7/jomc-tools-1.7" ) |
839 | private String getUsage( final java.util.Locale locale, final java.lang.String helpCommandName ) |
840 | { |
841 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "Usage", locale, helpCommandName ); |
842 | assert _m != null : "'Usage' message not found."; |
843 | return _m; |
844 | } |
845 | // </editor-fold> |
846 | // SECTION-END |
847 | } |