org.opensha.commons.param.impl
Class StringListParameter

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

public class StringListParameter
extends AbstractParameter<List<String>>

Title: StringListParameter.java

Description: String List Parameter that accepts strings as it's values. It is different from String Parameter because we can only set only one String as the value for StringParameter. However, in this case, multiple Strings can be set as value for this parameter. The editor for this parameter is shown as a JList where multiple selections are allowed. If constraints are present, setting the values must pass the constraint check. Since the Parameter class in an ancestor, all Parameter's fields are inherited.

Copyright: Copyright (c) 2002

Company:

Version:
1.0
Author:
not attributable
See Also:
Serialized Form

Field Summary
protected static String C
          Class name for debugging.
 
Fields inherited from class org.opensha.commons.param.AbstractParameter
constraint, D, 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
StringListParameter(String name)
          Constructor doesn't specify a constraint, all values allowed.
StringListParameter(String name, ArrayList strings, ArrayList values)
          Sets the name, vector of string converted to a constraint, amd value.
StringListParameter(String name, List<String> strings)
          Input vector is turned into StringConstraints object.
StringListParameter(String name, String units, ArrayList values)
          No constraints specified, all values allowed.
StringListParameter(String name, StringListConstraint constraint)
          Constructor that sets the name and Constraint during initialization.
StringListParameter(String name, StringListConstraint constraint, ArrayList values)
          Sets the name, constraint, and value.
StringListParameter(String name, StringListConstraint constraint, String units, List<String> values)
          This is the main constructor.
 
Method Summary
 Object clone()
          Returns a copy so you can't edit or damage the origial.
 AbstractParameterEditorOld getEditor()
          Returns the Editor for this Parameter.
 String getType()
          Gets the type attribute of the StringListParameter object.
 void setConstraint(ParameterConstraint constraint)
          Sets the constraint reference if it is a StringListConstraint and the parameter is currently editable, else throws an exception.
 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
 

Field Detail

C

protected static final String C
Class name for debugging.

See Also:
Constant Field Values
Constructor Detail

StringListParameter

public StringListParameter(String name)
Constructor doesn't specify a constraint, all values allowed. This constructor sets the name of this parameter.


StringListParameter

public StringListParameter(String name,
                           List<String> strings)
                    throws ConstraintException
Input vector is turned into StringConstraints object. If vector contains no elements an exception is thrown. This constructor also sets the name of this parameter.

Parameters:
name - Name of the parametet
strings - Converted to the Constraint object
Throws:
ConstraintException - Thrown if vector of allowed values is empty
ConstraintException - Thrown if vector of allowed values is empty

StringListParameter

public StringListParameter(String name,
                           StringListConstraint constraint)
                    throws ConstraintException
Constructor that sets the name and Constraint during initialization.

Parameters:
name - Name of the parametet
constraint - Constraint object
Throws:
ConstraintException - Description of the Exception
ConstraintException - Is thrown if the value is not allowed

StringListParameter

public StringListParameter(String name,
                           String units,
                           ArrayList values)
                    throws ConstraintException
No constraints specified, all values allowed. Sets the name, units and value.

Parameters:
name - Name of the parameter
units - Units of the parameter
value - value of this parameter
Throws:
ConstraintException - Description of the Exception

StringListParameter

public StringListParameter(String name,
                           ArrayList strings,
                           ArrayList values)
                    throws ConstraintException
Sets the name, vector of string converted to a constraint, amd value.

Parameters:
name - Name of the parametet
strings - vector of allowed values converted to a constraint
value - value of this parameter
Throws:
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

StringListParameter

public StringListParameter(String name,
                           StringListConstraint constraint,
                           ArrayList values)
                    throws ConstraintException
Sets the name, constraint, and value.

Parameters:
name - Name of the parametet
constraint - List of allowed values
value - value of this parameter
Throws:
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed

StringListParameter

public StringListParameter(String name,
                           StringListConstraint constraint,
                           String units,
                           List<String> values)
                    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. All values are set in this constructor; name, value, units, and constructor

Parameters:
name - Name of the parametet
constraint - Lsit of allowed values
value - value object 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 reference if it is a StringListConstraint and the parameter is currently editable, else throws an exception.

Specified by:
setConstraint in interface Parameter<List<String>>
Overrides:
setConstraint in class AbstractParameter<List<String>>
Parameters:
constraint - to set
Throws:
ParameterException
EditableException

getType

public String getType()
Gets the type attribute of the StringListParameter object. Returns the class name if unconstrained, else "Constrained" + classname. This is used to determine which type of GUI editor applies to this parameter.

Specified by:
getType in interface Parameter<List<String>>
Overrides:
getType in class AbstractParameter<List<String>>
Returns:
The GUI editor type

clone

public 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<List<String>>
Specified by:
clone in class AbstractParameter<List<String>>
Returns:
Description of the Return Value

getEditor

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

Returns:
the Editor

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<List<String>>
Returns: