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