org.apache.commons.cli2.option
Class Command

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

public class Command
extends ParentImpl

Represents a cvs "update" style command line option. Like all Parents, Commands can have child options and can be part of Arguments


Field Summary
private  java.util.Set aliases
          The aliases for this command
private  java.lang.String preferredName
          The display name for the command
private  java.util.Set triggers
          All the names for this command
 
Constructor Summary
Command(java.lang.String preferredName, java.lang.String description, java.util.Set aliases, boolean required, Argument argument, Group children, int id)
          Creates a new Command instance.
 
Method Summary
 void appendUsage(java.lang.StringBuffer buffer, java.util.Set helpSettings, java.util.Comparator comp)
          Appends usage information to the specified StringBuffer
 java.lang.String getPreferredName()
          The preferred name of an option is used for generating help and usage information.
 java.util.Set getTriggers()
          Identifies the argument prefixes that should trigger this option.
 void processParent(WriteableCommandLine commandLine, java.util.ListIterator arguments)
          Processes the parent part of the Option.
 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.ParentImpl
canProcess, defaults, findOption, getArgument, getChildren, getDescription, getPrefixes, helpLines, process
 
Methods inherited from class org.apache.commons.cli2.option.OptionImpl
canProcess, checkPrefixes, equals, getId, hashCode, isRequired, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.commons.cli2.Option
canProcess, getId, isRequired
 

Field Detail

preferredName

private final java.lang.String preferredName
The display name for the command


aliases

private final java.util.Set aliases
The aliases for this command


triggers

private final java.util.Set triggers
All the names for this command

Constructor Detail

Command

public Command(java.lang.String preferredName,
               java.lang.String description,
               java.util.Set aliases,
               boolean required,
               Argument argument,
               Group children,
               int id)
Creates a new Command instance.

Parameters:
preferredName - The name normally used to refer to the Command
description - A description of the Command
aliases - Alternative names for the Command
required - Whether the Command is required
argument - An Argument that the command takes
children - The Group of child options for this Command
id - A unique id for the Command
See Also:
ParentImpl.ParentImpl(Argument, Group, String, int, boolean)
Method Detail

processParent

public void processParent(WriteableCommandLine commandLine,
                          java.util.ListIterator arguments)
                   throws OptionException
Description copied from interface: Parent
Processes the parent part of the Option. The combination of parent, argument and children is handled by the process method.

Parameters:
commandLine - the CommandLine to write results to
arguments - a ListIterator over argument strings positioned at the next argument to process
Throws:
OptionException - if an error occurs while processing
See Also:
Option.process(WriteableCommandLine, ListIterator)

getTriggers

public java.util.Set getTriggers()
Description copied from interface: Option
Identifies the argument prefixes that should trigger this option. This is used to decide which of many Options should be tried when processing a given argument string. The returned Set must not be null.

Returns:
The set of triggers 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
Overrides:
validate in class ParentImpl
Parameters:
commandLine - The CommandLine to check.
Throws:
OptionException - if the CommandLine is not valid.

appendUsage

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

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

getPreferredName

public java.lang.String getPreferredName()
Description copied from interface: Option
The preferred name of an option is used for generating help and usage information.

Returns:
The preferred name of the option