compbio.metadata
Class Option<T>

java.lang.Object
  extended by compbio.metadata.Option<T>
Type Parameters:
T - type of executable
All Implemented Interfaces:
Argument<T>
Direct Known Subclasses:
Parameter

public class Option<T>
extends Object
implements Argument<T>

Command line option/flag or multiple exclusive options with no value. Example -protein, -dna, -auto

Version:
1.0 October 2009
Author:
pvtroshin

Field Summary
protected  String defaultValue
           
protected  String description
           
protected  URL furtherDetails
           
protected  boolean isRequired
           
protected  String name
           
 
Constructor Summary
Option(String name, String description)
           
 
Method Summary
 Set<String> addOptionNames(String... value)
          Adds an option to the optionName list
 boolean equals(Object obj)
           
 String getDefaultValue()
          A default value of the option.
 String getDescription()
          A long description of the Option
 URL getFurtherDetails()
          The URL where further details about the option can be found
 String getName()
          Human readable name of the option
 List<String> getOptionNames()
           
 List<String> getPossibleValues()
          List of possible optionNames
 int hashCode()
           
 boolean isRequired()
          Flag that indicated that this option must be specified in the command line for an executable to run
 void setDefaultValue(String defaultVal)
          Sets one of the values defined in optionList as default.
 void setDescription(String description)
           
 void setFurtherDetails(URL furtherDetails)
           
 void setName(String name)
           
 void setOptionNames(Set<String> optionNames)
           
 void setRequired(boolean isRequired)
           
 void setValue(String dValue)
          Set default values for the parameter or an option
 String toCommand(String nameValueSeparator)
          Convert the option to the command string.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

description

protected String description

name

protected String name

isRequired

protected boolean isRequired

furtherDetails

protected URL furtherDetails

defaultValue

protected String defaultValue
Constructor Detail

Option

public Option(String name,
              String description)
Method Detail

getName

public String getName()
Human readable name of the option

Specified by:
getName in interface Argument<T>

setName

public void setName(String name)

getDescription

public String getDescription()
A long description of the Option

Specified by:
getDescription in interface Argument<T>

setDescription

public void setDescription(String description)

getFurtherDetails

public URL getFurtherDetails()
The URL where further details about the option can be found

Specified by:
getFurtherDetails in interface Argument<T>

setFurtherDetails

public void setFurtherDetails(URL furtherDetails)

getDefaultValue

public String getDefaultValue()
A default value of the option. Defaults to command line argument name e.g. -auto

Specified by:
getDefaultValue in interface Argument<T>

setDefaultValue

public void setDefaultValue(String defaultVal)
                     throws WrongParameterException
Sets one of the values defined in optionList as default. Attempting set the value not listed there will result in WrongParameter exception

Parameters:
defaultVal -
Throws:
WrongParameterException - is thrown if the defaultValue is not found in optionList

isRequired

public boolean isRequired()
Flag that indicated that this option must be specified in the command line for an executable to run

Returns:
true is the option is required, false otherwise

setRequired

public void setRequired(boolean isRequired)

getOptionNames

public List<String> getOptionNames()
Returns:
List of option names

setOptionNames

public void setOptionNames(Set<String> optionNames)

addOptionNames

public Set<String> addOptionNames(String... value)
Adds an option to the optionName list

Parameters:
value -
Returns:
modified optionName list

toString

public String toString()
Overrides:
toString in class Object

toCommand

public String toCommand(String nameValueSeparator)
Convert the option to the command string.

Returns:
If only one optionName is defined, than it is returned, if many option names are defined, then the defaultValue is returned. Option must have a default value if there are many optionNames to be valid.

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getPossibleValues

public List<String> getPossibleValues()
List of possible optionNames

Specified by:
getPossibleValues in interface Argument<T>
Returns:
List of values allowed for an Argument

setValue

public void setValue(String dValue)
              throws WrongParameterException
Description copied from interface: Argument
Set default values for the parameter or an option

Specified by:
setValue in interface Argument<T>
Parameters:
dValue - the value to be set
Throws:
WrongParameterException - - when the value to be set is illegal. Wrong value for numeric parameter is the value defined outside it , for string type parameter, wrong value is the one which is not listed in possible values list
See Also:
ValueConstrain