org.opensha.commons.param.impl
Class DoubleParameter

java.lang.Object
  extended by org.opensha.commons.param.AbstractParameter<Double>
      extended by org.opensha.commons.param.impl.DoubleParameter
All Implemented Interfaces:
Serializable, Comparable<Parameter<?>>, Named, XMLSaveable, Parameter<Double>
Direct Known Subclasses:
AleatoryMagAreaStdDevParam, BPT_AperiodicityParam, DistRupMinusDistX_OverRupParam, FaultGridSpacingParam, HistoricOpenIntervalParam, MaxDistanceParam, MMI_Param, PeriodInterpolatedParam, RakeParam, SigmaTruncLevelParam, WarningDoubleParameter

public class DoubleParameter
extends AbstractParameter<Double>

Title: DoubleParameter

Description: Generic Data Object that contains a Double and optionally a min and max allowed values stored in a constraint object. If no constraint object is present then all values should be permitted.

Version:
1.0
Author:
Sid Hellman, Steven W. Rock
See Also:
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
 
Constructor Summary
DoubleParameter(String name)
          No constraints specified, all values allowed.
DoubleParameter(String name, Double value)
          No constraints specified, all values allowed.
DoubleParameter(String name, DoubleConstraint constraint)
          Sets the name and Constraints object.
DoubleParameter(String name, DoubleConstraint constraint, Double value)
          Sets the name, value and constraint.
DoubleParameter(String name, DoubleConstraint constraint, String units)
          Sets the name, constraints, and sets the units.
DoubleParameter(String name, DoubleConstraint constraint, String units, Double value)
          This is the main constructor.
DoubleParameter(String name, double min, double max)
          Sets the name, defines the constraints min and max values.
DoubleParameter(String name, Double min, Double max)
          Sets the name, defines the constraints min and max values.
DoubleParameter(String name, double min, double max, Double value)
          Sets the name, and value.
DoubleParameter(String name, Double min, Double max, Double value)
          Sets the name, and value.
DoubleParameter(String name, double min, double max, String units)
          Sets the name, defines the constraints min and max values, and sets the units.
DoubleParameter(String name, Double min, Double max, String units)
          Sets the name, defines the constraints min and max values, and sets the units.
DoubleParameter(String name, double min, double max, String units, Double value)
          Sets all values, and the constraint is created from the min and max values.
DoubleParameter(String name, Double min, Double max, String units, Double value)
          Sets all values, and the constraint is created from the min and max values.
DoubleParameter(String name, String units)
          No constraints specified, all values allowed.
DoubleParameter(String name, String units, Double value)
          Sets the name, units and value.
 
Method Summary
 Object clone()
          Returns a copy so you can't edit or damage the origial.
 ParameterEditor<Double> getEditor()
          Returns the Editor for this Parameter.
 Double getMax()
          Returns the maximum allowed values.
 Double getMin()
          Gets the min value of the constraint object.
 String getType()
          Gets the type of this parameter.
 boolean isAllowed(Double d)
          Uses the constraint object to determine if the new value being set is allowed.
 void setConstraint(ParameterConstraint constraint)
          Sets the constraint if it is a StringConstraint and the parameter is currently editable.
 boolean setIndividualParamValueFromXML(Element el)
          Parses the given XML element for a double value and sets it
 void setValue(double value)
          Set's the parameter's value.
 
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, 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
 

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

DoubleParameter

public DoubleParameter(String name)
No constraints specified, all values allowed. Sets the name of this parameter.

Parameters:
name - Name of the parameter

DoubleParameter

public DoubleParameter(String name,
                       String units)
No constraints specified, all values allowed. Sets the name and untis of this parameter.

Parameters:
name - Name of the parameter
units - Units of this parameter

DoubleParameter

public DoubleParameter(String name,
                       double min,
                       double max)
                throws ConstraintException
Sets the name, defines the constraints min and max values. Creates the constraint object from these values.

Parameters:
name - Name of the parameter
min - defines min of allowed values
max - defines max of allowed values
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       double min,
                       double max,
                       String units)
                throws ConstraintException
Sets the name, defines the constraints min and max values, and sets the units. Creates the constraint object from these values.

Parameters:
name - Name of the parameter
min - defines min of allowed values
max - defines max of allowed values
units - Units of this parameter
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       Double min,
                       Double max)
                throws ConstraintException
Sets the name, defines the constraints min and max values. Creates the constraint object from these values.

Parameters:
name - Name of the parameter
min - defines min of allowed values
max - defines max of allowed values
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       Double min,
                       Double max,
                       String units)
                throws ConstraintException
Sets the name, defines the constraints min and max values, and sets the units. Creates the constraint object from these values.

Parameters:
name - Name of the parameter
min - defines min of allowed values
max - defines max of allowed values
units - Units of this parameter
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       DoubleConstraint constraint)
                throws ConstraintException
Sets the name and Constraints object.

Parameters:
name - Name of the parameter
constraint - defines min and max range of allowed values
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       DoubleConstraint constraint,
                       String units)
                throws ConstraintException
Sets the name, constraints, and sets the units.

Parameters:
name - Name of the parameter
constraint - defines min and max range of allowed values
units - Units of this parameter
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowedallowed one. Null values are always allowed in the constructors

DoubleParameter

public DoubleParameter(String name,
                       Double value)
No constraints specified, all values allowed. Sets the name and value.

Parameters:
name - Name of the parameter
value - Double value of this parameter

DoubleParameter

public DoubleParameter(String name,
                       String units,
                       Double value)
                throws ConstraintException
Sets the name, units and value. All values allowed because constraints. not set.

Parameters:
name - Name of the parameter
value - Double value of this parameter
units - Units of this parameter
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       double min,
                       double max,
                       Double value)
                throws ConstraintException
Sets the name, and value. Also defines the min and max from which the constraint is constructed.

Parameters:
name - Name of the parameter
value - Double value of this parameter
min - defines max of allowed values
max - defines min of allowed values
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       Double min,
                       Double max,
                       Double value)
                throws ConstraintException
Sets the name, and value. Also defines the min and max from which the constraint is constructed.

Parameters:
name - Name of the parameter
value - Double value of this parameter
min - defines max of allowed values
max - defines min of allowed values
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       DoubleConstraint constraint,
                       Double value)
                throws ConstraintException
Sets the name, value and constraint. The value is checked if it is within constraints.

Parameters:
name - Name of the parameter
constraint - defines min and max range of allowed values
value - Double value of this parameter
Throws:
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       double min,
                       double max,
                       String units,
                       Double value)
                throws ConstraintException
Sets all values, and the constraint is created from the min and max values. The value is checked if it is within constraints.

Parameters:
name - Name of the parameter
value - Double value of this parameter
min - defines min of allowed values
max - defines max of allowed values
units - Units of this parameter
Throws:
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       Double min,
                       Double max,
                       String units,
                       Double value)
                throws ConstraintException
Sets all values, and the constraint is created from the min and max values. The value is checked if it is within constraints.

Parameters:
name - Name of the parameter
value - Double value of this parameter
min - defines min of allowed values
max - defines max of allowed values
units - Units of this parameter
Throws:
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

DoubleParameter

public DoubleParameter(String name,
                       DoubleConstraint 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. If the constraints are null, all values are allowed.

Parameters:
name - Name of the parameter
constraint - defines min and max range of allowed values
value - Double value of this parameter
units - Units of this parameter
Throws:
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
Method Detail

setConstraint

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

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

getMin

public Double getMin()
              throws Exception
Gets the min value of the constraint object.

Throws:
Exception

getMax

public Double getMax()
Returns the maximum allowed values.


getType

public String getType()
Gets the type of this parameter. Used by the Editor framework to decide what type of editor to create for this parameter.

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

setValue

public void setValue(double value)
              throws ConstraintException,
                     ParameterException
Set's the parameter's value.

Parameters:
value - The new value for this Parameter
Throws:
ParameterException - Thrown if the object is currenlty not editable.
ConstraintException - Thrown if the object value is not allowed.

isAllowed

public boolean isAllowed(Double d)
Uses the constraint object to determine if the new value being set is allowed. If no Constraints are present all values are allowed. This function is now available to all subclasses, since any type of constraint object follows the same api.

Specified by:
isAllowed in interface Parameter<Double>
Overrides:
isAllowed in class AbstractParameter<Double>
Parameters:
obj - Object to check if allowed via constraints
Returns:
True if the value is allowed

clone

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

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

setIndividualParamValueFromXML

public boolean setIndividualParamValueFromXML(Element el)
Parses the given XML element for a double value and sets it

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.

Returns:
the Editor