org.opensha.commons.param.impl
Class DoubleDiscreteParameter

java.lang.Object
  extended by org.opensha.commons.param.AbstractParameter<Double>
      extended by org.opensha.commons.param.impl.DoubleDiscreteParameter
All Implemented Interfaces:
Serializable, Comparable<Parameter<?>>, Named, XMLSaveable, Parameter<Double>
Direct Known Subclasses:
DampingParam, PeriodParam

public class DoubleDiscreteParameter
extends AbstractParameter<Double>
implements Parameter<Double>

Title: DoubleDiscreteParameter

Description: Identical to the DoubleParameter except the constraints are a finite set of valid Double choices instead of a Min/Max DoubleConstraint with all possible values allowed in between.

Version:
1.0
Author:
Steven W. Rock
See Also:
DoubleParameter, DependentParameter, Parameter, Parameter, Serialized Form

Field Summary
protected static String C
          Class name for debugging.
protected static boolean D
          If true print out debug statements.
 
Fields inherited from class org.opensha.commons.param.AbstractParameter
constraint, defaultValue, editable, independentParameters, info, metadataString, name, units, value, XML_COMPLEX_VAL_EL_NAME, XML_GROUP_METADATA_NAME, XML_METADATA_NAME, XML_NULL_VALUE
 
Fields inherited from interface org.opensha.commons.param.Parameter
XML_INDEPENDENT_PARAMS_NAME
 
Fields inherited from interface org.opensha.commons.metadata.XMLSaveable
XML_METADATA_NAME
 
Constructor Summary
DoubleDiscreteParameter(String name)
          Constructor for the DoubleDiscreteParameter object.
DoubleDiscreteParameter(String name, ArrayList doubles)
          Constructor for the DoubleDiscreteParameter object
DoubleDiscreteParameter(String name, ArrayList doubles, Double value)
          Constructor for the DoubleDiscreteParameter object
DoubleDiscreteParameter(String name, ArrayList doubles, String units)
          Constructor for the DoubleDiscreteParameter object
DoubleDiscreteParameter(String name, ArrayList doubles, String units, Double value)
          Constructor for the DoubleDiscreteParameter object
DoubleDiscreteParameter(String name, Double value)
          No constraints specified, all values allowed *
DoubleDiscreteParameter(String name, DoubleDiscreteConstraint constraint)
          Constructor for the DoubleDiscreteParameter object
DoubleDiscreteParameter(String name, DoubleDiscreteConstraint constraint, Double value)
          Constructor for the DoubleDiscreteParameter object
DoubleDiscreteParameter(String name, DoubleDiscreteConstraint constraint, String units)
          Constructor for the DoubleDiscreteParameter object
DoubleDiscreteParameter(String name, DoubleDiscreteConstraint constraint, String units, Double value)
          This is the main constructor.
DoubleDiscreteParameter(String name, String units)
          Constructor for the DoubleDiscreteParameter object No constraints specified, all values allowed.
DoubleDiscreteParameter(String name, String units, Double value)
          Constructor for the DoubleDiscreteParameter object
 
Method Summary
 Object clone()
          Returns a copy so you can't edit or damage the original.
 List<Double> getAllowedDoubles()
          Returns a clone of all allowed values.
 ParameterEditor<Double> getEditor()
          Returns the Editor for this Parameter.
 String getType()
          Gets the type attribute of the DoubleDiscreteParameter object.
 void setConstraint(ParameterConstraint constraint)
          Sets the constraint if it is a DoubleDiscreteConstraint and the parameter is currently editable.
 boolean setIndividualParamValueFromXML(Element el)
          This should set the value of this individual parameter.
 
Methods inherited from class org.opensha.commons.param.AbstractParameter
addIndependentParameter, addParameterChangeFailListener, addParameterChangeListener, checkEditable, compareTo, containsIndependentParameter, equals, firePropertyChange, firePropertyChangeFailed, getConstraint, getConstraintName, getDefaultValue, getDependentParamMetadataString, getIndependentParameter, getIndependentParameterList, getIndependentParametersKey, getInfo, getMetadataString, getName, getNumIndependentParameters, getUnits, getValue, isAllowed, isEditable, isNullAllowed, removeIndependentParameter, removeParameterChangeFailListener, removeParameterChangeListener, setDefaultValue, setDependentParamMetadataString, setIndependentParameters, setIndepParamsFromXML, setInfo, setName, setNonEditable, setUnits, setValue, setValueAsDefault, setValueFromXMLMetadata, toXMLMetadata, toXMLMetadata, unableToSetValue, valueToXML
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opensha.commons.param.Parameter
addIndependentParameter, addParameterChangeFailListener, addParameterChangeListener, containsIndependentParameter, equals, firePropertyChange, firePropertyChangeFailed, getConstraint, getConstraintName, getDefaultValue, getDependentParamMetadataString, getIndependentParameter, getIndependentParameterList, getIndependentParametersKey, getInfo, getMetadataString, getNumIndependentParameters, getUnits, getValue, isAllowed, isEditable, isNullAllowed, removeIndependentParameter, removeParameterChangeFailListener, removeParameterChangeListener, setDefaultValue, setIndependentParameters, setInfo, setName, setNonEditable, setUnits, setValue, setValueAsDefault, setValueFromXMLMetadata, toXMLMetadata, unableToSetValue
 
Methods inherited from interface org.opensha.commons.data.Named
getName
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.opensha.commons.metadata.XMLSaveable
toXMLMetadata
 

Field Detail

C

protected static final String C
Class name for debugging.

See Also:
Constant Field Values

D

protected static final boolean D
If true print out debug statements.

See Also:
Constant Field Values
Constructor Detail

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name)
Constructor for the DoubleDiscreteParameter object. No constraints specified, all values allowed.

Parameters:
name - Name of this parameter

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               String units)
Constructor for the DoubleDiscreteParameter object No constraints specified, all values allowed.

Parameters:
name - Name of this parameter
units - Units string for this parameter

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               ArrayList doubles)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name of this parameter
doubles - List of allowed doubles
Throws:
ConstraintException - Description of the Exception

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               ArrayList doubles,
                               String units)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name of this parameter
doubles - List of allowed doubles
units - Units string for this parameter
Throws:
ConstraintException - Description of the Exception

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               DoubleDiscreteConstraint constraint)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name of this parameter
constraint - List of allowed doubles
Throws:
ConstraintException - Description of the Exception

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               DoubleDiscreteConstraint constraint,
                               String units)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name of this parameter
constraint - List of allowed doubles
units - Units string for this parameter
Throws:
ConstraintException - Description of the Exception

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               Double value)
No constraints specified, all values allowed *

Parameters:
name - Name for this parameter
value - The value to set this parameter to

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               String units,
                               Double value)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name for this parameter
units - Units for this parameter
value - The value to set this parameter to
Throws:
ConstraintException - Thrown if value not allowed

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               ArrayList doubles,
                               Double value)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name for this parameter
value - The value to set this parameter to
doubles - list of allowed values
Throws:
ConstraintException - Thrown if value not allowed

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               ArrayList doubles,
                               String units,
                               Double value)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name for this parameter
units - Units for this parameter
value - The value to set this parameter to
doubles - list of allowed values
Throws:
ConstraintException - Thrown if value not allowed

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               DoubleDiscreteConstraint constraint,
                               Double value)
                        throws ConstraintException
Constructor for the DoubleDiscreteParameter object

Parameters:
name - Name for this parameter
constraint - List of allowed values
value - The value to set this parameter to
Throws:
ConstraintException - Thrown if value not allowed

DoubleDiscreteParameter

public DoubleDiscreteParameter(String name,
                               DoubleDiscreteConstraint constraint,
                               String units,
                               Double value)
                        throws ConstraintException
This is the main constructor. All other constructors call this one. Constraints must be set first, because the value may not be an allowed one. Null values are always allowed in the constructor

Parameters:
name - Name for this parameter
constraint - List of allowed values
units - Units for this parameter
value - The value to set this parameter to
Throws:
ConstraintException - Thrown if value not allowed
Method Detail

setConstraint

public void setConstraint(ParameterConstraint constraint)
                   throws ParameterException,
                          EditableException
Sets the constraint if it is a DoubleDiscreteConstraint and the parameter is currently editable.

Specified by:
setConstraint in interface Parameter<Double>
Overrides:
setConstraint in class AbstractParameter<Double>
Parameters:
constraint - The new constraint object
Throws:
ParameterException - Thrown if constraint is not a DoubleDiscreteConstraint
EditableException - Thrown if Parameter is currently uneditable.

getType

public String getType()
Gets the type attribute of the DoubleDiscreteParameter object. This is used to determine which gui editor to use for this parameter.

Specified by:
getType in interface Parameter<Double>
Overrides:
getType in class AbstractParameter<Double>

getAllowedDoubles

public List<Double> getAllowedDoubles()
Returns a clone of all allowed values. Proxy to constraint object.


clone

public Object clone()
Returns a copy so you can't edit or damage the original.

Specified by:
clone in interface Parameter<Double>
Specified by:
clone in class AbstractParameter<Double>

setIndividualParamValueFromXML

public boolean setIndividualParamValueFromXML(Element el)
Description copied from class: AbstractParameter
This should set the value of this individual parameter. The values of the independent parameters will be set by the final setValueFromXMLMetadata method

Specified by:
setIndividualParamValueFromXML in class AbstractParameter<Double>
Returns:

getEditor

public ParameterEditor<Double> getEditor()
Description copied from interface: Parameter
Returns the Editor for this Parameter. It is recommended that editors be lazily instantiated.

Specified by:
getEditor in interface Parameter<Double>
Returns:
the Editor