net.dpml.cli.option
Class Command

java.lang.Object
  extended bynet.dpml.cli.option.OptionImpl
      extended bynet.dpml.cli.option.ParentImpl
          extended bynet.dpml.cli.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.

Version:
1.0.0
Author:
Digital Product Meta Library

Constructor Summary
Command(String preferredName, String description, Set aliases, boolean required, Argument argument, Group children, int id)
          Creates a new Command instance.
 
Method Summary
 void appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp)
          Appends usage information to the specified StringBuffer
 String getPreferredName()
          The preferred name of an option is used for generating help and usage information.
 Set getTriggers()
          Identifies the argument prefixes that should trigger this option.
 void processParent(WriteableCommandLine commandLine, ListIterator arguments)
          Process the parent.
 void validate(WriteableCommandLine commandLine)
          Checks that the supplied CommandLine is valid with respect to this option.
 
Methods inherited from class net.dpml.cli.option.ParentImpl
canProcess, defaults, findOption, getArgument, getChildren, getDescription, getPrefixes, helpLines, process
 
Methods inherited from class net.dpml.cli.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 net.dpml.cli.Option
canProcess, getId, isRequired
 

Constructor Detail

Command

public Command(String preferredName,
               String description,
               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 - true if 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,
                          ListIterator arguments)
                   throws OptionException
Process the parent.

Parameters:
commandLine - the commandline
arguments - an iterator of arguments
Throws:
OptionException - if an error occurs
See Also:
Option.process(WriteableCommandLine, ListIterator)

getTriggers

public Set getTriggers()
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
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(StringBuffer buffer,
                        Set helpSettings,
                        Comparator comp)
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 String getPreferredName()
The preferred name of an option is used for generating help and usage information.

Returns:
The preferred name of the option