org.opensha.sha.param
Class MagDistStringParameter

java.lang.Object
  extended by org.opensha.commons.param.AbstractParameter<java.lang.String>
      extended by org.opensha.commons.param.impl.StringParameter
          extended by org.opensha.sha.param.MagDistStringParameter
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Parameter<?>>, Named, XMLSaveable, Parameter<java.lang.String>

public class MagDistStringParameter
extends StringParameter

Author:
nitingupta
See Also:
Serialized Form

Field Summary
protected static java.lang.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
MagDistStringParameter(java.lang.String name, java.util.ArrayList strings)
           
MagDistStringParameter(java.lang.String name, java.util.ArrayList strings, java.lang.String value)
           
MagDistStringParameter(java.lang.String name, StringConstraint constraint)
           
MagDistStringParameter(java.lang.String name, StringConstraint constraint, java.lang.String value)
           
MagDistStringParameter(java.lang.String name, StringConstraint constraint, java.lang.String units, java.lang.String value)
           
 
Method Summary
 java.lang.Object clone()
          Returns a copy so you can't edit or damage the origial.
 int compareTo(Parameter<?> param)
          Compares the values to if this is less than, equal to, or greater than the comparing objects.
 boolean equals(java.lang.Object obj)
          Compares the passed in MagDistStringParameter to see if it has the same name and value.
 java.util.ArrayList getAllowedStrings()
          Returns a clone of the allowed strings of the constraint.
 ParameterEditor<java.lang.String> getEditor()
          Returns the Editor for this Parameter.
 java.lang.String getType()
          Gets the type attribute of the MagDistStringParameter object.
 void setConstraint(ParameterConstraint constraint)
          Sets the constraint reference if it is a StringConstraint and the parameter is currently editable, else throws an exception.
 
Methods inherited from class org.opensha.commons.param.impl.StringParameter
setIndividualParamValueFromXML
 
Methods inherited from class org.opensha.commons.param.AbstractParameter
addIndependentParameter, addParameterChangeFailListener, addParameterChangeListener, checkEditable, containsIndependentParameter, 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
 

Field Detail

C

protected static final java.lang.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

MagDistStringParameter

public MagDistStringParameter(java.lang.String name,
                              java.util.ArrayList strings)
                       throws ConstraintException
Parameters:
name -
strings -
Throws:
ConstraintException

MagDistStringParameter

public MagDistStringParameter(java.lang.String name,
                              StringConstraint constraint)
                       throws ConstraintException
Parameters:
name -
constraint -
Throws:
ConstraintException

MagDistStringParameter

public MagDistStringParameter(java.lang.String name,
                              java.util.ArrayList strings,
                              java.lang.String value)
                       throws ConstraintException
Parameters:
name -
strings -
value -
Throws:
ConstraintException

MagDistStringParameter

public MagDistStringParameter(java.lang.String name,
                              StringConstraint constraint,
                              java.lang.String value)
                       throws ConstraintException
Parameters:
name -
constraint -
value -
Throws:
ConstraintException

MagDistStringParameter

public MagDistStringParameter(java.lang.String name,
                              StringConstraint constraint,
                              java.lang.String units,
                              java.lang.String value)
                       throws ConstraintException
Parameters:
name -
constraint -
units -
value -
Throws:
ConstraintException
Method Detail

setConstraint

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

Specified by:
setConstraint in interface Parameter<java.lang.String>
Overrides:
setConstraint in class StringParameter
Parameters:
constraint - to set
Throws:
ParameterException
EditableException

getType

public java.lang.String getType()
Gets the type attribute of the MagDistStringParameter object. This is used to determine which type of GUI editor applies to this parameter.

Specified by:
getType in interface Parameter<java.lang.String>
Overrides:
getType in class StringParameter
Returns:
The GUI editor type

getAllowedStrings

public java.util.ArrayList getAllowedStrings()
Returns a clone of the allowed strings of the constraint. Useful for presenting in a picklist

Overrides:
getAllowedStrings in class StringParameter
Returns:
The allowedStrings vector

compareTo

public int compareTo(Parameter<?> param)
Compares the values to if this is less than, equal to, or greater than the comparing objects. Implementation of comparable interface. Helps with sorting a list of parameters.

Specified by:
compareTo in interface java.lang.Comparable<Parameter<?>>
Overrides:
compareTo in class AbstractParameter<java.lang.String>
Parameters:
obj - The object to compare this to
Returns:
-1 if this value < obj value, 0 if equal, +1 if this value > obj value
Throws:
java.lang.ClassCastException - Is thrown if the comparing object is not a MagDistStringParameter *
See Also:
Comparable

equals

public boolean equals(java.lang.Object obj)
Compares the passed in MagDistStringParameter to see if it has the same name and value. If the object is not a MagDistStringParameter an exception is thrown. If the values and names are equal true is returned, otherwise false is returned.

Specified by:
equals in interface Parameter<java.lang.String>
Overrides:
equals in class AbstractParameter<java.lang.String>
Parameters:
obj - The object to compare this to
Returns:
True if the values are identical
Throws:
java.lang.ClassCastException - Is thrown if the comparing object is not a MagDistStringParameter

clone

public java.lang.Object clone()
Returns a copy so you can't edit or damage the origial. Clones this object's value and all fields. The constraints are also cloned.

Specified by:
clone in interface Parameter<java.lang.String>
Overrides:
clone in class StringParameter
Returns:
Description of the Return Value

getEditor

public ParameterEditor<java.lang.String> 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<java.lang.String>
Overrides:
getEditor in class StringParameter
Returns:
the Editor