org.apache.commons.cli2.option
Class ParentImpl

java.lang.Object
  extended by org.apache.commons.cli2.option.OptionImpl
      extended by org.apache.commons.cli2.option.ParentImpl
All Implemented Interfaces:
Option, Parent
Direct Known Subclasses:
Command, DefaultOption, Switch

public abstract class ParentImpl
extends OptionImpl
implements Parent

A base implementation of Parent providing limited ground work for further Parent implementations.


Constructor Summary
protected ParentImpl(Argument argument, Group children, String description, int id, boolean required)
           
 
Method Summary
 void appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp)
          Appends usage information to the specified StringBuffer
 boolean canProcess(WriteableCommandLine commandLine, String arg)
          Indicates whether this Option will be able to process the particular argument.
 void defaults(WriteableCommandLine commandLine)
          Adds defaults to a CommandLine.
 Option findOption(String trigger)
          Recursively searches for an option with the supplied trigger.
 Argument getArgument()
           
 Group getChildren()
           
 String getDescription()
          Returns a description of the option.
 Set getPrefixes()
          Identifies the argument prefixes that should be considered options.
 List helpLines(int depth, Set helpSettings, Comparator comp)
          Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
 void process(WriteableCommandLine commandLine, ListIterator arguments)
          Processes String arguments into a CommandLine.
 void validate(WriteableCommandLine commandLine)
          Checks that the supplied CommandLine is valid with respect to this option.
 
Methods inherited from class org.apache.commons.cli2.option.OptionImpl
canProcess, checkPrefixes, equals, getId, getParent, hashCode, isRequired, setParent, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.commons.cli2.Parent
processParent
 
Methods inherited from interface org.apache.commons.cli2.Option
canProcess, getId, getParent, getPreferredName, getTriggers, isRequired, setParent
 

Constructor Detail

ParentImpl

protected ParentImpl(Argument argument,
                     Group children,
                     String description,
                     int id,
                     boolean required)
Method Detail

process

public void process(WriteableCommandLine commandLine,
                    ListIterator arguments)
             throws OptionException
Description copied from interface: Option
Processes String arguments into a CommandLine. The iterator will initially point at the first argument to be processed and at the end of the method should point to the first argument not processed. This method MUST process at least one argument from the ListIterator.

Specified by:
process in interface Option
Parameters:
commandLine - The CommandLine object to store results in
arguments - The arguments to process
Throws:
OptionException - if any problems occur

canProcess

public boolean canProcess(WriteableCommandLine commandLine,
                          String arg)
Description copied from interface: Option
Indicates whether this Option will be able to process the particular argument.

Specified by:
canProcess in interface Option
Parameters:
commandLine - The CommandLine to check
arg - The argument to be tested
Returns:
true if the argument can be processed by this Option

getPrefixes

public Set getPrefixes()
Description copied from interface: Option
Identifies the argument prefixes that should be considered options. This is used to identify whether a given string looks like an option or an argument value. Typically an option would return the set [--,-] while switches might offer [-,+]. The returned Set must not be null.

Specified by:
getPrefixes in interface Option
Returns:
The set of prefixes for this Option

validate

public void validate(WriteableCommandLine commandLine)
              throws OptionException
Description copied from interface: Option
Checks that the supplied CommandLine is valid with respect to this option.

Specified by:
validate in interface Option
Parameters:
commandLine - The CommandLine to check.
Throws:
OptionException - if the CommandLine is not valid.

appendUsage

public void appendUsage(StringBuffer buffer,
                        Set helpSettings,
                        Comparator comp)
Description copied from interface: Option
Appends usage information to the specified StringBuffer

Specified by:
appendUsage in interface Option
Parameters:
buffer - the buffer to append to
helpSettings - a set of display settings @see DisplaySetting
comp - a comparator used to sort the Options

getDescription

public String getDescription()
Description copied from interface: Option
Returns a description of the option. This string is used to build help messages as in the HelpFormatter.

Specified by:
getDescription in interface Option
Returns:
a description of this parent option
See Also:
HelpFormatter

helpLines

public List helpLines(int depth,
                      Set helpSettings,
                      Comparator comp)
Description copied from interface: Option
Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.

Specified by:
helpLines in interface Option
Parameters:
depth - the initial indent depth
helpSettings - the HelpSettings that should be applied
comp - a comparator used to sort options when applicable.
Returns:
a List of HelpLineImpl objects
See Also:
HelpLine, HelpFormatter

getArgument

public Argument getArgument()
Returns:
Returns the argument.

getChildren

public Group getChildren()
Returns:
Returns the children.

findOption

public Option findOption(String trigger)
Description copied from interface: Option
Recursively searches for an option with the supplied trigger.

Specified by:
findOption in interface Option
Overrides:
findOption in class OptionImpl
Parameters:
trigger - the trigger to search for.
Returns:
the matching option or null.

defaults

public void defaults(WriteableCommandLine commandLine)
Description copied from interface: Option
Adds defaults to a CommandLine. Any defaults for this option are applied as well as the defaults for any contained options

Specified by:
defaults in interface Option
Overrides:
defaults in class OptionImpl
Parameters:
commandLine - The CommandLine object to store defaults in


Copyright © 2002-2010 Apache Software Foundation. All Rights Reserved.