org.fhcrc.cpl.toolbox.commandline.arguments
Class BaseArgumentDefinitionImpl

java.lang.Object
  extended by org.fhcrc.cpl.toolbox.commandline.arguments.BaseArgumentDefinitionImpl
All Implemented Interfaces:
CommandLineArgumentDefinition
Direct Known Subclasses:
BooleanArgumentDefinition, DecimalArgumentDefinition, DecimalListArgumentDefinition, DeltaMassArgumentDefinition, EnumeratedValuesArgumentDefinition, FileArgumentDefinition, FileToReadListArgumentDefinition, IntegerArgumentDefinition, ModificationListArgumentDefinition, StringArgumentDefinition, StringListArgumentDefinition

public abstract class BaseArgumentDefinitionImpl
extends java.lang.Object
implements CommandLineArgumentDefinition


Field Summary
protected  java.lang.String mArgumentHelpText
           
protected  java.lang.String mArgumentName
           
protected  java.lang.Object mDefaultValue
           
protected  java.lang.String mDisplayName
           
protected  boolean mIsAdvanced
           
protected  boolean mRequired
           
 
Fields inherited from interface org.fhcrc.cpl.toolbox.commandline.arguments.CommandLineArgumentDefinition
UNNAMED_PARAMETER_VALUE_ARGUMENT, UNNAMED_PARAMETER_VALUE_SERIES_ARGUMENT
 
Constructor Summary
BaseArgumentDefinitionImpl()
           
BaseArgumentDefinitionImpl(java.lang.String argumentName)
           
BaseArgumentDefinitionImpl(java.lang.String argumentName, boolean required, java.lang.String helpText)
           
BaseArgumentDefinitionImpl(java.lang.String argumentName, boolean required, java.lang.String helpText, java.lang.Object defaultValue)
          Set all the fundamental information about this argument definition, except basic/advanced status
BaseArgumentDefinitionImpl(java.lang.String argumentName, java.lang.String helpText)
           
 
Method Summary
 javax.swing.JComponent addComponentsForGUI(java.awt.Container parent, javax.swing.JDialog parentDialog, java.lang.String defaultValue)
          Add GUI components for specifying this argument.
 javax.swing.JComponent addComponentsForGUISeries(java.awt.Container parent, javax.swing.JDialog parentDialog, java.lang.String defaultValue)
          Add GUI components for specifying a series of this type of argument, separated by spaces.
abstract  java.lang.Object convertArgumentValue(java.lang.String argumentValue)
          Convert the argument value to the type of object that the subclass likes to work with.
 java.lang.String getArgumentDisplayName()
           
 java.lang.String getArgumentName()
           
 java.lang.Object getDefaultValue()
          Get the default value for this argument, or null if there is none.
 java.lang.String getDefaultValueAsString()
          Get the default value, as a String, for the help text.
 java.lang.String getDisplayName()
           
 java.lang.String getHelpText()
           
 java.lang.String getValueDescriptor()
          Return a String that will be used as a generic example for the value to be used for this argument, in auto-generated usage
 java.lang.String getValueFromGUIComponent(javax.swing.JComponent component)
          Interrogate the GUI component used for this argument, to get its value.
 boolean hasDefaultValue()
          Does this argument definition have a default value? Default implementation is to check getDefaultValue() for nullness.
 boolean isAdvanced()
          Is this argument "advanced"? That is, can a basic user of the module safely ignore it?
 boolean isRequired()
           
 void setAdvanced(boolean mIsAdvanced)
          Specify "advanced" status of this argument
 void setArgumentDisplayName(java.lang.String mDisplayName)
          Set the name of the argument for display purposes
 void setDefaultValue(java.lang.Object defaultValue)
          Set the default value for this argument
 void setDisplayName(java.lang.String mDisplayName)
           
 void setHelpText(java.lang.String mArgumentHelpText)
           
 void setRequired(boolean required)
          Declare whether this is a required argument.
 java.lang.String valueToString(java.lang.Object argValue)
          Return a String representing this value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mArgumentName

protected java.lang.String mArgumentName

mArgumentHelpText

protected java.lang.String mArgumentHelpText

mRequired

protected boolean mRequired

mDefaultValue

protected java.lang.Object mDefaultValue

mDisplayName

protected java.lang.String mDisplayName

mIsAdvanced

protected boolean mIsAdvanced
Constructor Detail

BaseArgumentDefinitionImpl

public BaseArgumentDefinitionImpl()

BaseArgumentDefinitionImpl

public BaseArgumentDefinitionImpl(java.lang.String argumentName)

BaseArgumentDefinitionImpl

public BaseArgumentDefinitionImpl(java.lang.String argumentName,
                                  java.lang.String helpText)

BaseArgumentDefinitionImpl

public BaseArgumentDefinitionImpl(java.lang.String argumentName,
                                  boolean required,
                                  java.lang.String helpText)

BaseArgumentDefinitionImpl

public BaseArgumentDefinitionImpl(java.lang.String argumentName,
                                  boolean required,
                                  java.lang.String helpText,
                                  java.lang.Object defaultValue)
Set all the fundamental information about this argument definition, except basic/advanced status

Parameters:
argumentName -
required -
helpText -
defaultValue -
Method Detail

getArgumentName

public java.lang.String getArgumentName()
Specified by:
getArgumentName in interface CommandLineArgumentDefinition
Returns:
the name of the argument

getArgumentDisplayName

public java.lang.String getArgumentDisplayName()
Specified by:
getArgumentDisplayName in interface CommandLineArgumentDefinition
Returns:
the name of the argument for display purposes. For named arguments, this should really be the same as getArgumentName(). But for unnamed arguments or unnamed series arguments, this gives the developer a chance to use a different name in the help. Be careful, though, not to make this return value too long or too confusing -- the user should still be aware that this is an unnamed argument

setArgumentDisplayName

public void setArgumentDisplayName(java.lang.String mDisplayName)
Set the name of the argument for display purposes

Specified by:
setArgumentDisplayName in interface CommandLineArgumentDefinition
Parameters:
mDisplayName -

convertArgumentValue

public abstract java.lang.Object convertArgumentValue(java.lang.String argumentValue)
                                               throws ArgumentValidationException
Convert the argument value to the type of object that the subclass likes to work with. As part of conversion, perform validation

Specified by:
convertArgumentValue in interface CommandLineArgumentDefinition
Parameters:
argumentValue -
Returns:
Throws:
ArgumentValidationException - if the argument doesn't validate

isRequired

public boolean isRequired()
Specified by:
isRequired in interface CommandLineArgumentDefinition
Returns:
whether this argument is required

setRequired

public void setRequired(boolean required)
Description copied from interface: CommandLineArgumentDefinition
Declare whether this is a required argument. This is a convenience method

Specified by:
setRequired in interface CommandLineArgumentDefinition

getHelpText

public java.lang.String getHelpText()
Specified by:
getHelpText in interface CommandLineArgumentDefinition
Returns:
help text for specifying this argument, or null if not specified

setHelpText

public void setHelpText(java.lang.String mArgumentHelpText)
Specified by:
setHelpText in interface CommandLineArgumentDefinition

getValueDescriptor

public java.lang.String getValueDescriptor()
Description copied from interface: CommandLineArgumentDefinition
Return a String that will be used as a generic example for the value to be used for this argument, in auto-generated usage

Specified by:
getValueDescriptor in interface CommandLineArgumentDefinition
Returns:

getDefaultValue

public java.lang.Object getDefaultValue()
Get the default value for this argument, or null if there is none. However, since null is a valid default in some cases, hasDefaultValue() should be used to determine whether there is a useful default value

Specified by:
getDefaultValue in interface CommandLineArgumentDefinition
Returns:

getDefaultValueAsString

public java.lang.String getDefaultValueAsString()
Get the default value, as a String, for the help text. In most cases, this will be equivalent to getDefaultValue().toString();

Specified by:
getDefaultValueAsString in interface CommandLineArgumentDefinition
Returns:

valueToString

public java.lang.String valueToString(java.lang.Object argValue)
Return a String representing this value

Specified by:
valueToString in interface CommandLineArgumentDefinition
Parameters:
argValue -
Returns:

setDefaultValue

public void setDefaultValue(java.lang.Object defaultValue)
Set the default value for this argument

Specified by:
setDefaultValue in interface CommandLineArgumentDefinition
Parameters:
defaultValue -

hasDefaultValue

public boolean hasDefaultValue()
Does this argument definition have a default value? Default implementation is to check getDefaultValue() for nullness. Subclasses can override usefully if null is a valid default

Specified by:
hasDefaultValue in interface CommandLineArgumentDefinition
Returns:

getDisplayName

public java.lang.String getDisplayName()

setDisplayName

public void setDisplayName(java.lang.String mDisplayName)

isAdvanced

public boolean isAdvanced()
Description copied from interface: CommandLineArgumentDefinition
Is this argument "advanced"? That is, can a basic user of the module safely ignore it?

Specified by:
isAdvanced in interface CommandLineArgumentDefinition
Returns:

setAdvanced

public void setAdvanced(boolean mIsAdvanced)
Description copied from interface: CommandLineArgumentDefinition
Specify "advanced" status of this argument

Specified by:
setAdvanced in interface CommandLineArgumentDefinition

addComponentsForGUISeries

public javax.swing.JComponent addComponentsForGUISeries(java.awt.Container parent,
                                                        javax.swing.JDialog parentDialog,
                                                        java.lang.String defaultValue)
Description copied from interface: CommandLineArgumentDefinition
Add GUI components for specifying a series of this type of argument, separated by spaces. Generally this will be a single field, but more complicated components are allowed. The return value should be the component that will actually contain the user's input. The components should be added directly to parent. If a dialog box needs to be opened, parentDialog can be referenced. The initial value of the field, if any, is passed in -- no need for the component to check the default. This is for arguments named UNNAMED_SERIES_ARGUMENT_VALUE

Specified by:
addComponentsForGUISeries in interface CommandLineArgumentDefinition
Returns:

addComponentsForGUI

public javax.swing.JComponent addComponentsForGUI(java.awt.Container parent,
                                                  javax.swing.JDialog parentDialog,
                                                  java.lang.String defaultValue)
Description copied from interface: CommandLineArgumentDefinition
Add GUI components for specifying this argument. Generally this will be a single field, but more complicated components are allowed. The return value should be the component that will actually contain the user's input. The components should be added directly to parent. If a dialog box needs to be opened, parentDialog can be referenced. The initial value of the field, if any, is passed in -- no need for the component to check the default

Specified by:
addComponentsForGUI in interface CommandLineArgumentDefinition
Returns:

getValueFromGUIComponent

public java.lang.String getValueFromGUIComponent(javax.swing.JComponent component)
Description copied from interface: CommandLineArgumentDefinition
Interrogate the GUI component used for this argument, to get its value. Most argument types will use text fields, but not all (e.g., JComboBox for Boolean and Enumerated)

Specified by:
getValueFromGUIComponent in interface CommandLineArgumentDefinition
Returns:


Fred Hutchinson Cancer Research Center