net.dpml.cli.option
Class SourceDestArgument

java.lang.Object
  extended by net.dpml.cli.option.OptionImpl
      extended by net.dpml.cli.option.ArgumentImpl
          extended by net.dpml.cli.option.SourceDestArgument
All Implemented Interfaces:
Argument, Option

public class SourceDestArgument
extends ArgumentImpl

An Argument implementation that allows a variable size Argument to precede a fixed size argument. The canonical example of it's use is in the unix cp command where a number of source can be specified with exactly one destination specfied at the end.

Version:
1.0.0
Author:
Digital Product Meta Library

Field Summary
 
Fields inherited from class net.dpml.cli.option.ArgumentImpl
DEFAULT_CONSUME_REMAINING, DEFAULT_INITIAL_SEPARATOR, DEFAULT_SUBSEQUENT_SEPARATOR
 
Constructor Summary
SourceDestArgument(Argument source, Argument dest)
          Creates a SourceDestArgument using defaults where possible.
SourceDestArgument(Argument source, Argument dest, char initialSeparator, char subsequentSeparator, String consumeRemaining, List defaultValues)
          Creates a SourceDestArgument using the specified parameters.
 
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.
 List helpLines(int depth, Set helpSettings, Comparator comp)
          Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
 void validate(WriteableCommandLine commandLine, Option option)
          Checks that the supplied CommandLine is valid with respect to the suppled option.
 
Methods inherited from class net.dpml.cli.option.ArgumentImpl
defaults, defaultValues, getConsumeRemaining, getDefaultValues, getDescription, getInitialSeparator, getMaximum, getMinimum, getPreferredName, getPrefixes, getSubsequentSeparator, getTriggers, getValidator, isRequired, process, processValues, stripBoundaryQuotes, validate
 
Methods inherited from class net.dpml.cli.option.OptionImpl
canProcess, checkPrefixes, equals, findOption, getId, hashCode, 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, findOption, getId
 

Constructor Detail

SourceDestArgument

public SourceDestArgument(Argument source,
                          Argument dest)
Creates a SourceDestArgument using defaults where possible.

Parameters:
source - the variable size Argument
dest - the fixed size Argument

SourceDestArgument

public SourceDestArgument(Argument source,
                          Argument dest,
                          char initialSeparator,
                          char subsequentSeparator,
                          String consumeRemaining,
                          List defaultValues)
Creates a SourceDestArgument using the specified parameters.

Parameters:
source - the variable size Argument
dest - the fixed size Argument
initialSeparator - the inistial separator to use
subsequentSeparator - the subsequent separator to use
consumeRemaining - the token triggering consume remaining behaviour
defaultValues - the default values for the SourceDestArgument
Method Detail

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 ArgumentImpl
Parameters:
buffer - the buffer to append to
helpSettings - a set of display settings @see DisplaySetting
comp - a comparator used to sort the Options

helpLines

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

Specified by:
helpLines in interface Option
Overrides:
helpLines in class ArgumentImpl
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

validate

public void validate(WriteableCommandLine commandLine,
                     Option option)
              throws OptionException
Checks that the supplied CommandLine is valid with respect to the suppled option.

Specified by:
validate in interface Argument
Overrides:
validate in class ArgumentImpl
Parameters:
commandLine - the CommandLine to check.
option - the option to evaluate
Throws:
OptionException - if the CommandLine is not valid.
See Also:
CommandLine.getValues(Option)

canProcess

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

Specified by:
canProcess in interface Option
Overrides:
canProcess in class ArgumentImpl
Parameters:
commandLine - the CommandLine object to store defaults in
arg - the argument to be tested
Returns:
true if the argument can be processed by this Option