uk.ac.ncl.cs.instantsoap.commandlineprocessor.commandLine
Class Option<Value>

java.lang.Object
  extended by uk.ac.ncl.cs.instantsoap.commandlineprocessor.commandLine.Argument<Value>
      extended by uk.ac.ncl.cs.instantsoap.commandlineprocessor.commandLine.Option<Value>

public class Option<Value>
extends Argument<Value>

Command-line option. This is composed of a name, and (possibly zero) values.

Either the letter or longName parameter must be non-null. If both are provided, then one will be chosen according to the commandline hints.

In a command like tail -f, the option is f. In a command like tar -f foo.tar, the option name is f and the values list contains the single value foo.tar.

Author:
Matthew Pocock

Nested Class Summary
 
Nested classes/interfaces inherited from class uk.ac.ncl.cs.instantsoap.commandlineprocessor.commandLine.Argument
Argument.ArgumentVisitor<Value>
 
Constructor Summary
Option()
          Create a new option with an empty list of values.
Option(String letter, String name, List<Value> values)
          Create a new option with the specified properties.
Option(String letter, String name, Value... values)
          Create a new option with the specified properties.
 
Method Summary
 boolean equals(Object o)
           
 String getLetter()
          Get the short name of this option.
 String getLongName()
          Get the long name of this option.
 List<Value> getValues()
          Get the value list.
 int hashCode()
           
 void setLetter(String letter)
          Set the short-name of this option.
 void setLongName(String longName)
          Set the long name of this option.
 void setValues(List<Value> values)
          Set the value list.
 String toString()
           
 void visit(Argument.ArgumentVisitor<Value> valueArgumentVisitor)
          Visit this argument, triggering the handle method of the visitor specific to the concrete class of the argument.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Option

public Option()
Create a new option with an empty list of values.


Option

public Option(String letter,
              String name,
              List<Value> values)
Create a new option with the specified properties.

Parameters:
letter - the short name (usually a single letter)
name - the long name
values - the List of Values

Option

public Option(String letter,
              String name,
              Value... values)
Create a new option with the specified properties.

Parameters:
letter - the short name (usually a single letter)
name - the long name
values - the Values
Method Detail

visit

public void visit(Argument.ArgumentVisitor<Value> valueArgumentVisitor)
Description copied from class: Argument
Visit this argument, triggering the handle method of the visitor specific to the concrete class of the argument.

Specified by:
visit in class Argument<Value>
Parameters:
valueArgumentVisitor - the argumentVisitor that should visit this argument

getLetter

public String getLetter()
Get the short name of this option. If no short name is provided, null.

Returns:
the short name (usually a single letter)

setLetter

public void setLetter(String letter)
Set the short-name of this option.

Parameters:
letter - the new short name, or null if no short-name should be used

getLongName

public String getLongName()
Get the long name of this option. If no long name is provided, null.

Returns:
the long name

setLongName

public void setLongName(String longName)
Set the long name of this option.

Parameters:
longName - the new long name of this option, or null if no long name is provided

getValues

public List<Value> getValues()
Get the value list.

Returns:
the List of Values of this option

setValues

public void setValues(List<Value> values)
Set the value list.

Parameters:
values - the List of Value of this option

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2006-2008. All Rights Reserved.