net.dpml.cli.builder

Class ArgumentBuilder

public class ArgumentBuilder extends Object

Builds Argument instances.

Version: @PROJECT-VERSION@

Author: @PUBLISHER-NAME@

Constructor Summary
ArgumentBuilder()
Creates a new ArgumentBuilder instance
Method Summary
Argumentcreate()
Creates a new Argument instance using the options specified in this ArgumentBuilder.
ArgumentBuilderreset()
Resets the ArgumentBuilder to the defaults for a new Argument.
ArgumentBuilderwithConsumeRemaining(String newConsumeRemaining)
Sets the "consume remaining" option, defaults to "--".
ArgumentBuilderwithDefault(Object defaultValue)
Sets the default value.
ArgumentBuilderwithDefaults(List newDefaultValues)
Sets the default values.
ArgumentBuilderwithDescription(String newDescription)
Sets the description of the argument.
ArgumentBuilderwithId(int newId)
Sets the id
ArgumentBuilderwithInitialSeparator(char newInitialSeparator)
Sets the character used to separate the values from the option.
ArgumentBuilderwithMaximum(int newMaximum)
Sets the maximum number of values allowed for the argument to be valid.
ArgumentBuilderwithMinimum(int newMinimum)
Sets the minimum number of values needed for the argument to be valid.
ArgumentBuilderwithName(String newName)
Sets the name of the argument.
ArgumentBuilderwithSubsequentSeparator(char newSubsequentSeparator)
Sets the character used to separate the values from each other.
ArgumentBuilderwithValidator(Validator newValidator)
Sets the validator instance used to perform validation on the Argument values.

Constructor Detail

ArgumentBuilder

public ArgumentBuilder()
Creates a new ArgumentBuilder instance

Method Detail

create

public final Argument create()
Creates a new Argument instance using the options specified in this ArgumentBuilder.

Returns: A new Argument instance using the options specified in this ArgumentBuilder.

reset

public final ArgumentBuilder reset()
Resets the ArgumentBuilder to the defaults for a new Argument. The method is called automatically at the end of a create() call.

Returns: the argument builder

withConsumeRemaining

public final ArgumentBuilder withConsumeRemaining(String newConsumeRemaining)
Sets the "consume remaining" option, defaults to "--". Use this if you want to allow values that might be confused with option strings.

Parameters: newConsumeRemaining the string to use for the consume remaining option

Returns: this ArgumentBuilder

withDefault

public final ArgumentBuilder withDefault(Object defaultValue)
Sets the default value.

Parameters: defaultValue the default value for the Argument

Returns: this ArgumentBuilder

withDefaults

public final ArgumentBuilder withDefaults(List newDefaultValues)
Sets the default values.

Parameters: newDefaultValues the default values for the Argument

Returns: this ArgumentBuilder

withDescription

public final ArgumentBuilder withDescription(String newDescription)
Sets the description of the argument. The description is used when displaying online help.

Parameters: newDescription a description of the argument

Returns: this ArgumentBuilder

withId

public final ArgumentBuilder withId(int newId)
Sets the id

Parameters: newId the id of the Argument

Returns: this ArgumentBuilder

withInitialSeparator

public final ArgumentBuilder withInitialSeparator(char newInitialSeparator)
Sets the character used to separate the values from the option. When an argument is of the form -libs:dir1,dir2,dir3 the initialSeparator would be ':'.

Parameters: newInitialSeparator the character used to separate the values from the option

Returns: this ArgumentBuilder

withMaximum

public final ArgumentBuilder withMaximum(int newMaximum)
Sets the maximum number of values allowed for the argument to be valid.

Parameters: newMaximum the number of values allowed

Returns: this ArgumentBuilder

withMinimum

public final ArgumentBuilder withMinimum(int newMinimum)
Sets the minimum number of values needed for the argument to be valid.

Parameters: newMinimum the number of values needed

Returns: this ArgumentBuilder

withName

public final ArgumentBuilder withName(String newName)
Sets the name of the argument. The name is used when displaying usage information and to allow lookups in the CommandLine object.

Parameters: newName the name of the argument

Returns: this ArgumentBuilder

See Also:

withSubsequentSeparator

public final ArgumentBuilder withSubsequentSeparator(char newSubsequentSeparator)
Sets the character used to separate the values from each other. When an argument is of the form -libs:dir1,dir2,dir3 the subsequentSeparator would be ','.

Parameters: newSubsequentSeparator the character used to separate the values from each other

Returns: this ArgumentBuilder

withValidator

public final ArgumentBuilder withValidator(Validator newValidator)
Sets the validator instance used to perform validation on the Argument values.

Parameters: newValidator a Validator instance

Returns: this ArgumentBuilder