net.dpml.cli.builder
Class ArgumentBuilder

java.lang.Object
  extended bynet.dpml.cli.builder.ArgumentBuilder

public class ArgumentBuilder
extends Object

Builds Argument instances.

Version:
1.0.0
Author:
Digital Product Meta Library

Constructor Summary
ArgumentBuilder()
          Creates a new ArgumentBuilder instance
 
Method Summary
 Argument create()
          Creates a new Argument instance using the options specified in this ArgumentBuilder.
 ArgumentBuilder reset()
          Resets the ArgumentBuilder to the defaults for a new Argument.
 ArgumentBuilder withConsumeRemaining(String newConsumeRemaining)
          Sets the "consume remaining" option, defaults to "--".
 ArgumentBuilder withDefault(Object defaultValue)
          Sets the default value.
 ArgumentBuilder withDefaults(List newDefaultValues)
          Sets the default values.
 ArgumentBuilder withDescription(String newDescription)
          Sets the description of the argument.
 ArgumentBuilder withId(int newId)
          Sets the id
 ArgumentBuilder withInitialSeparator(char newInitialSeparator)
          Sets the character used to separate the values from the option.
 ArgumentBuilder withMaximum(int newMaximum)
          Sets the maximum number of values allowed for the argument to be valid.
 ArgumentBuilder withMinimum(int newMinimum)
          Sets the minimum number of values needed for the argument to be valid.
 ArgumentBuilder withName(String newName)
          Sets the name of the argument.
 ArgumentBuilder withSubsequentSeparator(char newSubsequentSeparator)
          Sets the character used to separate the values from each other.
 ArgumentBuilder withValidator(Validator newValidator)
          Sets the validator instance used to perform validation on the Argument values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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:
CommandLine.getValue(String)

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

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

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

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

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

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

withId

public final ArgumentBuilder withId(int newId)
Sets the id

Parameters:
newId - the id of the Argument
Returns:
this ArgumentBuilder