Java Doc for CmdLineParser.java in  » Development » args4j » org » kohsuke » args4j » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » args4j » org.kohsuke.args4j 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.kohsuke.args4j.CmdLineParser

CmdLineParser
public class CmdLineParser (Code)
Command line argument owner.

For a typical usage, see this example.
author:
   Kohsuke Kawaguchi (kk@kohsuke.org)




Constructor Summary
public  CmdLineParser(Object bean)
     Creates a new command line owner that parses arguments/options and set them into the given object.

Method Summary
protected  OptionHandlercreateOptionHandler(OptionDef o, Setter setter)
     Creates an OptionHandler that handles the given Option annotation and the Setter instance.
protected  booleanisOption(String arg)
    
public  voidparseArgument(String... args)
     Parses the command line arguments and set them to the option bean given in the constructor.
public  StringprintExample(ExampleMode mode)
     Formats a command line example into a string.
public  StringprintExample(ExampleMode mode, ResourceBundle rb)
     Formats a command line example into a string.

This method produces a string like " -d <dir> -v -b", which is useful for printing a command line example, perhaps as a part of the usage screen.
Parameters:
  mode - One of the ExampleMode constants.

public  voidprintSingleLineUsage(OutputStream out)
     Prints a single-line usage to the screen.
public  voidprintSingleLineUsage(Writer w, ResourceBundle rb)
     Prints a single-line usage to the screen.
public  voidprintUsage(OutputStream out)
     Prints the list of options and their usages to the screen.
public  voidprintUsage(Writer out, ResourceBundle rb)
     Prints the list of options and their usages to the screen.
public static  voidregisterHandler(Class valueType, Class<? extends OptionHandler> handlerClass)
     Registers a user-defined OptionHandler class with args4j.
public  voidsetUsageWidth(int usageWidth)
    
public  voidstopOptionParsing()
    


Constructor Detail
CmdLineParser
public CmdLineParser(Object bean)(Code)
Creates a new command line owner that parses arguments/options and set them into the given object.
Parameters:
  bean - instance of a class annotated by Option and Argument.this object will receive values.
throws:
  IllegalAnnotationError - if the option bean class is using args4j annotations incorrectly.




Method Detail
createOptionHandler
protected OptionHandler createOptionHandler(OptionDef o, Setter setter)(Code)
Creates an OptionHandler that handles the given Option annotation and the Setter instance.



isOption
protected boolean isOption(String arg)(Code)
Returns true if the given token is an option (as opposed to an argument.)



parseArgument
public void parseArgument(String... args) throws CmdLineException(Code)
Parses the command line arguments and set them to the option bean given in the constructor.
Parameters:
  args - arguments to parse
throws:
  CmdLineException - if there's any error parsing arguments, or ifOption.required required option was not given.



printExample
public String printExample(ExampleMode mode)(Code)
Formats a command line example into a string. See CmdLineParser.printExample(ExampleMode,ResourceBundle) for more details.
Parameters:
  mode - must not be null.always non-null.



printExample
public String printExample(ExampleMode mode, ResourceBundle rb)(Code)
Formats a command line example into a string.

This method produces a string like " -d <dir> -v -b", which is useful for printing a command line example, perhaps as a part of the usage screen.
Parameters:
  mode - One of the ExampleMode constants. Must not be null.This determines what option should be a part of the returned string.
Parameters:
  rb - If non-null, meta variables (<dir> in the above example)is treated as a key to this resource bundle, and the associatedvalue is printed. See Option.metaVar. This is to supportlocalization.Passing null would print Option.metaVar directly.always non-null. If there's no option, this method returnsjust the empty string "". Otherwise, this method returns astring that contains a space at the beginning (but not at the end.)This allows you to do something like:

System.err.println("java -jar my.jar"+parser.printExample(REQUIRED)+" arg1 arg2");



printSingleLineUsage
public void printSingleLineUsage(OutputStream out)(Code)
Prints a single-line usage to the screen.

This is a convenience method for calling printUsage(new OutputStreamWriter(out),null) so that you can do printUsage(System.err) .




printSingleLineUsage
public void printSingleLineUsage(Writer w, ResourceBundle rb)(Code)
Prints a single-line usage to the screen.
Parameters:
  rb - if this is non-null, Option.usage is treatedas a key to obtain the actual message from this resource bundle.



printUsage
public void printUsage(OutputStream out)(Code)
Prints the list of options and their usages to the screen.

This is a convenience method for calling printUsage(new OutputStreamWriter(out),null) so that you can do printUsage(System.err) .




printUsage
public void printUsage(Writer out, ResourceBundle rb)(Code)
Prints the list of options and their usages to the screen.
Parameters:
  rb - if this is non-null, Option.usage is treatedas a key to obtain the actual message from this resource bundle.



registerHandler
public static void registerHandler(Class valueType, Class<? extends OptionHandler> handlerClass)(Code)
Registers a user-defined OptionHandler class with args4j.

This method allows users to extend the behavior of args4j by writing their own OptionHandler implementation.
Parameters:
  valueType - The specified handler is used when the field/method annotated by Optionis of this type.
Parameters:
  handlerClass - This class must have the constructor that has the same signature asOptionHandler.OptionHandler(CmdLineParserNamedOptionDefSetter).




setUsageWidth
public void setUsageWidth(int usageWidth)(Code)



stopOptionParsing
public void stopOptionParsing()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.