org.apache.commons.cli2.builder
Class ArgumentBuilder

java.lang.Object
  extended by org.apache.commons.cli2.builder.ArgumentBuilder

public class ArgumentBuilder
extends java.lang.Object

Builds Argument instances.


Field Summary
private  java.lang.String consumeRemaining
          used to identify the consume remaining option, typically "--"
private  java.util.List defaultValues
          default values for argument
private  java.lang.String description
          description of the argument.
private  int id
          id of the argument
private  char initialSeparator
          character used to separate the values from the option
private  int maximum
          maximum number of values permitted
private  int minimum
          minimum number of values required
private  java.lang.String name
          name of the argument.
private static ResourceHelper resources
          i18n
private  char subsequentSeparator
          character used to separate the values from each other
private  Validator validator
          object that should be used to ensure the values are valid
 
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(java.lang.String newConsumeRemaining)
          Sets the "consume remaining" option, defaults to "--".
 ArgumentBuilder withDefault(java.lang.Object defaultValue)
          Sets the default value.
 ArgumentBuilder withDefaults(java.util.List newDefaultValues)
          Sets the default values.
 ArgumentBuilder withDescription(java.lang.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(java.lang.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
 

Field Detail

resources

private static final ResourceHelper resources
i18n


name

private java.lang.String name
name of the argument. Used for display and lookups in CommandLine


description

private java.lang.String description
description of the argument. Used in the automated online help


minimum

private int minimum
minimum number of values required


maximum

private int maximum
maximum number of values permitted


initialSeparator

private char initialSeparator
character used to separate the values from the option


subsequentSeparator

private char subsequentSeparator
character used to separate the values from each other


validator

private Validator validator
object that should be used to ensure the values are valid


consumeRemaining

private java.lang.String consumeRemaining
used to identify the consume remaining option, typically "--"


defaultValues

private java.util.List defaultValues
default values for argument


id

private int id
id of the argument

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.


withName

public final ArgumentBuilder withName(java.lang.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(java.lang.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(java.lang.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(java.lang.Object defaultValue)
Sets the default value.

Parameters:
defaultValue - the default value for the Argument
Returns:
this ArgumentBuilder

withDefaults

public final ArgumentBuilder withDefaults(java.util.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