net.dpml.cli.option
Class OptionImpl
java.lang.Object
net.dpml.cli.option.OptionImpl
- Option
A base implementation of Option providing limited ground work for further
Option implementations.
OptionImpl(int id, boolean required) - Creates an OptionImpl with the specified id
|
boolean | canProcess(WriteableCommandLine commandLine, ListIterator arguments) - Indicates whether this Option will be able to process the particular
argument.
|
protected void | checkPrefixes(Set prefixes) - Check prefixes.
|
void | defaults(WriteableCommandLine commandLine) - Adds defaults to a CommandLine.
|
boolean | equals(Object thatObj) - Evaluate this instance against the supplied instance for equality.
|
Option | findOption(String trigger) - Recursively searches for an option with the supplied trigger.
|
int | getId() - Returns the id of the option.
|
int | hashCode() - Return the hashcode value for this instance.
|
boolean | isRequired() - Indicates whether this option is required to be present.
|
String | toString() - Returns a string representation of the option.
|
OptionImpl
public OptionImpl(int id,
boolean required)
Creates an OptionImpl with the specified id
id
- the unique id of this Optionrequired
- true iff this Option must be present
canProcess
public boolean canProcess(WriteableCommandLine commandLine,
ListIterator arguments)
Indicates whether this Option will be able to process the particular
argument. The ListIterator must be restored to the initial state before
returning the boolean.
- canProcess in interface Option
commandLine
- the CommandLine object to store defaults inarguments
- the ListIterator over String arguments
- true if the argument can be processed by this Option
canProcess(WriteableCommandLine,String)
checkPrefixes
protected void checkPrefixes(Set prefixes)
Check prefixes.
prefixes
- the prefixes set
defaults
public void defaults(WriteableCommandLine commandLine)
Adds defaults to a CommandLine.
Any defaults for this option are applied as well as the defaults for
any contained options
- defaults in interface Option
commandLine
- the CommandLine object to store defaults in
equals
public boolean equals(Object thatObj)
Evaluate this instance against the supplied instance for equality.
thatObj
- the other object
- true if the supplied instance is equal to this instance
findOption
public Option findOption(String trigger)
Recursively searches for an option with the supplied trigger.
- findOption in interface Option
trigger
- the trigger to search for.
- the matching option or null.
getId
public int getId()
Returns the id of the option. This can be used in a loop and switch
construct:
for(Option o : cmd.getOptions()){
switch(o.getId()){
case POTENTIAL_OPTION:
...
}
}
The returned value is not guarenteed to be unique.
- getId in interface Option
hashCode
public int hashCode()
Return the hashcode value for this instance.
isRequired
public boolean isRequired()
Indicates whether this option is required to be present.
- isRequired in interface Option
- true if the CommandLine will be invalid without this Option
toString
public String toString()
Returns a string representation of the option.