Top Inners Fields Constructors Methods
com.beust.jcommander

public Class ParameterDescription

extends Object
Class Inheritance
Imports
com.beust.jcommander.validators.NoValidator, .NoValueValidator, java.lang.annotation.Annotation, java.lang.reflect.Field, java.util.*, .ResourceBundle

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private boolean
assigned

Keep track of whether a value was added to flag an error

private ResourceBundle
private Object
private String
private DynamicParameter
private JCommander
private String
longestName

Longest of the names(), used to present usage() alphabetically

private Object
private Parameter
private Parameterized
parameterized

The field/method

private WrappedParameter

Constructor Summary

AccessConstructor and Description
public
ParameterDescription(Object object, DynamicParameter annotation, Parameterized parameterized, ResourceBundle bundle, JCommander jc)

public
ParameterDescription(Object object, Parameter annotation, Parameterized parameterized, ResourceBundle bundle, JCommander jc)

Method Summary

Modifier and TypeMethod and Description
public void
public void
addValue(String value, boolean isDefault)

Add the specified value to the field.

pack-priv Object
addValue(String name, String value, boolean isDefault, boolean validate, int currentIndex)

private boolean
fieldIsSetForTheFirstTime(boolean isDefault)

private ResourceBundle
findResourceBundle(Object o)

Find the resource bundle in the annotations.

private List<ParameterDescription.SubParameterIndex>
public Object
public String
public String
public String
public Object
public WrappedParameter
public Parameter
public Parameterized
private Object
handleSubParameters(String value, int currentIndex, Class<?> type, List<ParameterDescription.SubParameterIndex> subParameters)

private void
init(Object
the object defining the command-line arguments
object
,
Parameterized
the wrapper for the field or method annotated with \@Parameter this represents
parameterized
,
ResourceBundle
the locale
bundle
,
JCommander
the parent JCommander instance
jCommander
)

Initializes the state of this parameter description.

private void
initDescription(String description, String descriptionKey, String[] names)

public boolean

Returns:

true if this parameter received a value during the parsing phase.
isAssigned
()

public boolean
private boolean
public boolean
private boolean
public boolean
private Collection<Object>
private void
p(String string)

public void
setAssigned(boolean b)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
private void
public void
validateParameter(Class<? extends IParameterValidator> validator, String name, String value)

pack-priv void
public void
validateValueParameter(Class<? extends IValueValidator<T>> validator, String name, Object value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

assignedback to summary
private boolean assigned

Keep track of whether a value was added to flag an error

bundleback to summary
private ResourceBundle bundle
defaultObjectback to summary
private Object defaultObject
descriptionback to summary
private String description
dynamicParameterAnnotationback to summary
private DynamicParameter dynamicParameterAnnotation
jCommanderback to summary
private JCommander jCommander
longestNameback to summary
private String longestName

Longest of the names(), used to present usage() alphabetically

objectback to summary
private Object object
parameterAnnotationback to summary
private Parameter parameterAnnotation
parameterizedback to summary
private Parameterized parameterized

The field/method

wrappedParameterback to summary
private WrappedParameter wrappedParameter

Constructor Detail

ParameterDescriptionback to summary
public ParameterDescription(Object object, DynamicParameter annotation, Parameterized parameterized, ResourceBundle bundle, JCommander jc)
ParameterDescriptionback to summary
public ParameterDescription(Object object, Parameter annotation, Parameterized parameterized, ResourceBundle bundle, JCommander jc)

Method Detail

addValueback to summary
public void addValue(String value)
addValueback to summary
public void addValue(String value, boolean isDefault)

Add the specified value to the field. First, validate the value if a validator was specified. Then look up any field converter, then any type converter, and if we can't find any, throw an exception.

addValueback to summary
pack-priv Object addValue(String name, String value, boolean isDefault, boolean validate, int currentIndex)
fieldIsSetForTheFirstTimeback to summary
private boolean fieldIsSetForTheFirstTime(boolean isDefault)
findResourceBundleback to summary
private ResourceBundle findResourceBundle(Object o)

Find the resource bundle in the annotations.

Annotations
@SuppressWarnings:deprecation
findSubParametersback to summary
private List<ParameterDescription.SubParameterIndex> findSubParameters(Class<?> type)
getDefaultback to summary
public Object getDefault()
getDescriptionback to summary
public String getDescription()
getLongestNameback to summary
public String getLongestName()
getNamesback to summary
public String getNames()
getObjectback to summary
public Object getObject()
getParameterback to summary
public WrappedParameter getParameter()
getParameterAnnotationback to summary
public Parameter getParameterAnnotation()
getParameterizedback to summary
public Parameterized getParameterized()
handleSubParametersback to summary
private Object handleSubParameters(String value, int currentIndex, Class<?> type, List<ParameterDescription.SubParameterIndex> subParameters)
initback to summary
private void init(Object object, Parameterized parameterized, ResourceBundle bundle, JCommander jCommander)

Initializes the state of this parameter description. This will set an appropriate bundle if it is null<. If its the description in is empty and it refers to an enum type, then the description will be set to its possible values. It will also attempt to validate the default value of the parameter.

Parameters
object:Object

the object defining the command-line arguments

parameterized:Parameterized

the wrapper for the field or method annotated with \@Parameter this represents

bundle:ResourceBundle

the locale

jCommander:JCommander

the parent JCommander instance

Annotations
@SuppressWarnings:unchecked
See Also
initDescription(String, String, String[])
initDescriptionback to summary
private void initDescription(String description, String descriptionKey, String[] names)
isAssignedback to summary
public boolean isAssigned()
Returns:boolean

true if this parameter received a value during the parsing phase.

isDynamicParameterback to summary
public boolean isDynamicParameter()
isEmptyback to summary
private boolean isEmpty(String s)
isHelpback to summary
public boolean isHelp()
isMultiOptionback to summary
private boolean isMultiOption()
isNonOverwritableForcedback to summary
public boolean isNonOverwritableForced()
newCollectionback to summary
private Collection<Object> newCollection(Class<?> type)
Annotations
@SuppressWarnings:unchecked
pback to summary
private void p(String string)
setAssignedback to summary
public void setAssigned(boolean b)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
validateDefaultValuesback to summary
private void validateDefaultValues(String[] names)
validateParameterback to summary
private void validateParameter(String name, String value)
validateParameterback to summary
public void validateParameter(Class<? extends IParameterValidator> validator, String name, String value)
validateValueParameterback to summary
pack-priv void validateValueParameter(String name, Object value)
validateValueParameterback to summary
public void validateValueParameter(Class<? extends IValueValidator<T>> validator, String name, Object value)
com.beust.jcommander back to summary

pack-priv Class ParameterDescription.SubParameterIndex

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Field
pack-priv int

Constructor Summary

AccessConstructor and Description
public
SubParameterIndex(int order, Field field)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fieldback to summary
pack-priv Field field
orderback to summary
pack-priv int order

Constructor Detail

SubParameterIndexback to summary
public SubParameterIndex(int order, Field field)