|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.beust.jcommander.JCommander
public class JCommander
The main class for JCommander. It's responsible for parsing the object that contains all the annotated fields, parse the command line and assign the fields with the correct values and a few other helper methods, such as usage(). The object(s) you pass in the constructor are expected to have one or more
Field Summary | |
---|---|
static String |
DEBUG_PROPERTY
|
Constructor Summary | |
---|---|
JCommander(Object object)
|
|
JCommander(Object object,
ResourceBundle bundle,
String... args)
|
|
JCommander(Object object,
String... args)
|
Method Summary | ||
---|---|---|
void |
addCommand(String name,
Object object)
Add a command object. |
|
void |
addConverterFactory(IStringConverterFactory converterFactory)
|
|
Object |
convertValue(Field field,
Class type,
String value)
|
|
Object |
convertValue(ParameterDescription pd,
String value)
|
|
|
findConverter(Class<T> cls)
|
|
String |
getCommandDescription(String commandName)
|
|
Map<String,JCommander> |
getCommands()
|
|
List<Object> |
getObjects()
|
|
List<ParameterDescription> |
getParameters()
|
|
String |
getParsedCommand()
|
|
void |
parse(String... args)
Parse the command line parameters. |
|
void |
setDefaultProvider(IDefaultProvider defaultProvider)
Define the default provider for this instance. |
|
void |
setProgramName(String name)
Set the program name (used only in the usage). |
|
void |
usage()
Display a the help on System.out. |
|
void |
usage(String commandName)
Display the usage for this command. |
|
void |
usage(StringBuilder out)
Store the help in the passed string builder. |
|
void |
usage(String commandName,
StringBuilder out)
Store the help for the command in the passed string builder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEBUG_PROPERTY
Constructor Detail |
---|
public JCommander(Object object)
object
- The arg object expected to contain @Parameter
annotations.public JCommander(Object object, ResourceBundle bundle, String... args)
object
- The arg object expected to contain @Parameter
annotations.bundle
- The bundle to use for the descriptions. Can be null.args
- The arguments to parse (optional).public JCommander(Object object, String... args)
object
- The arg object expected to contain @Parameter
annotations.args
- The arguments to parse (optional).Method Detail |
---|
public void parse(String... args)
public void setProgramName(String name)
public void usage(String commandName)
public void usage(String commandName, StringBuilder out)
public String getCommandDescription(String commandName)
public void usage()
public void usage(StringBuilder out)
public List<ParameterDescription> getParameters()
public void setDefaultProvider(IDefaultProvider defaultProvider)
public void addConverterFactory(IStringConverterFactory converterFactory)
public <T> Class<? extends IStringConverter<T>> findConverter(Class<T> cls)
public Object convertValue(ParameterDescription pd, String value)
public Object convertValue(Field field, Class type, String value)
type
- The class of the fieldannotation
- The annotationvalue
- The value to convertpublic void addCommand(String name, Object object)
public Map<String,JCommander> getCommands()
public String getParsedCommand()
public List<Object> getObjects()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |