|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opensha.commons.param.AbstractParameter<Integer>
org.opensha.commons.param.impl.IntegerParameter
org.opensha.commons.param.impl.WarningIntegerParameter
public class WarningIntegerParameter
Title: WarningIntegerParameter
Description: Concrete implementation of the WarningParameterAPI interface that stores a Integer for it's value object. Maintains a list of listeners and passes them ParameterChangeWarningEvents when the value is attemted to be set beyong the warning constraints.
Typical use case is that there is one listener that also acts as the editor of the value, ( such as the GUI component attempting to update the value ). This listener attempts to change the value outside the warning range. The listener is notified of the attemp, i.e. "warned". This listener then notifies the user via a DialogBox. The user is then given the option to cancel or ignore the warning and set the value. The listener will then set the value ignoring the warning.
The whole reason for using a listener is that any type of situation can be handled. This class doesn't need to know anything about the listener other than it adheres to the ParameterChangeWarningListener interface. The listener can be any class, and can be updated to any new class in the future. This class never has to be changed. This means that this parameter component is not tied to any specific class of editors, a guiding principle in object-oriented programming.
Note: All listeners must implement the ParameterChangeFailListener interface.
Note: Since this class extends from IntegerParameter it also has a second absolute IntegerConstraint that can never be exceeded. It's important that the programmer realizes this and ensures the warning constraints are smaller than the absolute constraints when using this parameter in their program.
ParameterChangeWarningListener,
ParameterChangeWarningEvent,
Serialized Form| Field Summary | |
|---|---|
protected static String |
C
Class name for debugging. |
protected static boolean |
D
If true print out debug statements. |
protected IntegerConstraint |
warningConstraint
The constraint for this Parameter. |
protected ArrayList |
warningListeners
A list of listeners to receive warning events. |
| 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 | |
|---|---|
WarningIntegerParameter(String name)
No warning constraints or absolute constraints specified. |
|
WarningIntegerParameter(String name,
Integer value)
No constraints specified, all values allowed. |
|
WarningIntegerParameter(String name,
IntegerConstraint constraint)
Sets the name and Constraints object. |
|
WarningIntegerParameter(String name,
IntegerConstraint constraint,
Integer value)
Sets the name, value and constraint. |
|
WarningIntegerParameter(String name,
IntegerConstraint constraint,
String units)
Sets the name, constraints, and sets the units. |
|
WarningIntegerParameter(String name,
IntegerConstraint constraint,
String units,
Integer value)
This is the main constructor. |
|
WarningIntegerParameter(String name,
Integer min,
Integer max)
Sets the name, defines the constraints min and max values. |
|
WarningIntegerParameter(String name,
Integer min,
Integer max,
String units)
Sets the name, defines the constraints min and max values, and sets the units. |
|
WarningIntegerParameter(String name,
Integer min,
Integer max,
String units,
Integer value)
Sets all values, and the constraint is created from the min and max values. |
|
WarningIntegerParameter(String name,
int min,
int max)
Sets the name, defines the constraints min and max values. |
|
WarningIntegerParameter(String name,
int min,
int max,
Integer value)
Sets the name, and value. |
|
WarningIntegerParameter(String name,
int min,
int max,
String units)
Sets the name, defines the constraints min and max values, and sets the units. |
|
WarningIntegerParameter(String name,
int min,
int max,
String units,
Integer value)
Sets all values, and the constraint is created from the min and max values. |
|
WarningIntegerParameter(String name,
String units)
No warning constraints or absolute constraints specified. |
|
WarningIntegerParameter(String name,
String units,
Integer value)
Sets the name, units and value. |
|
| Method Summary | |
|---|---|
void |
addParameterChangeWarningListener(ParameterChangeWarningListener listener)
Adds a ParameterChangeFailListener to the list of listeners. |
Object |
clone()
Returns a copy so you can't edit or damage the origial. |
void |
fireParameterChangeWarning(ParameterChangeWarningEvent event)
This is the function that notifies all listeners assigned to this parameter that the warning constraints have been exceeded. |
AbstractParameterConstraint |
getWarningConstraint()
Replaces the warning constraints with a new constraint object. |
Integer |
getWarningMax()
Proxy passthrough method to the IntegerConstraint to get the minimumn value below which warnings will be issued. |
Integer |
getWarningMin()
Proxy passthrough method to the IntegerConstraint to get the minimumn value below which warnings will be issued. |
boolean |
isIgnoreWarning()
Returns warning constraint enabled/disabled. |
boolean |
isRecommended(Integer obj)
Uses the warning constraint object to determine if the new value being set is within recommended range. |
void |
removeParameterChangeWarningListener(ParameterChangeWarningListener listener)
Removes a ParameterChangeFailListener to the list of listeners. |
void |
setIgnoreWarning(boolean ignoreWarning)
Set to true to turn off warnings, will automatically set the value, unless exceeds Absolute contrsints. |
void |
setValue(Integer value)
Attempts to update the value of this parameter with a new Integer. |
void |
setValueIgnoreWarning(Integer value)
Attempts to update the value of this parameter with a new Integer. |
void |
setWarningConstraint(AbstractParameterConstraint warningConstraint)
Replaces the warning constraints with a new constraint object. |
| Methods inherited from class org.opensha.commons.param.impl.IntegerParameter |
|---|
getEditor, getMax, getMin, getType, isAllowed, setConstraint, setIndividualParamValueFromXML |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.opensha.commons.param.WarningParameter |
|---|
equals |
| 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 |
|---|
protected static final String C
protected static final boolean D
protected IntegerConstraint warningConstraint
protected transient ArrayList warningListeners
| Constructor Detail |
|---|
public WarningIntegerParameter(String name)
public WarningIntegerParameter(String name,
String units)
public WarningIntegerParameter(String name,
int min,
int max)
throws ConstraintException
name - Name of the parametermin - defines min of allowed valuesmax - defines max of allowed values
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
int min,
int max,
String units)
throws ConstraintException
name - Name of the parametermin - defines min of allowed valuesmax - defines max of allowed valuesunits - Units of this parameter
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
Integer min,
Integer max)
throws ConstraintException
name - Name of the parametermin - defines min of allowed valuesmax - defines max of allowed values
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
Integer min,
Integer max,
String units)
throws ConstraintException
name - Name of the parametermin - defines min of allowed valuesmax - defines max of allowed valuesunits - Units of this parameter
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
IntegerConstraint constraint)
throws ConstraintException
name - Name of the parameterconstraint - defines min and max range of allowed
values
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
IntegerConstraint constraint,
String units)
throws ConstraintException
name - Name of the parameterconstraint - defines min and max range of allowed
valuesunits - Units of this parameter
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
public WarningIntegerParameter(String name,
Integer value)
name - Name of the parametervalue - Integer value of this parameter
public WarningIntegerParameter(String name,
String units,
Integer value)
throws ConstraintException
name - Name of the parametervalue - Integer value of this parameterunits - Units of this parameter
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
int min,
int max,
Integer value)
throws ConstraintException
name - Name of the parametervalue - Integer value of this parametermin - defines max of allowed valuesmax - defines min of allowed values
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
IntegerConstraint constraint,
Integer value)
throws ConstraintException
name - Name of the parameterconstraint - defines min and max range of allowed
valuesvalue - Integer value of this parameter
ConstraintException - thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
int min,
int max,
String units,
Integer value)
throws ConstraintException
name - Name of the parametervalue - Integer value of this parametermin - defines min of allowed valuesmax - defines max of allowed valuesunits - Units of this parameter
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
Integer min,
Integer max,
String units,
Integer value)
throws ConstraintException
name - Name of the parametervalue - Integer value of this parametermin - defines min of allowed valuesmax - defines max of allowed valuesunits - Units of this parameter
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed
public WarningIntegerParameter(String name,
IntegerConstraint constraint,
String units,
Integer value)
throws ConstraintException
name - Name of the parameterconstraint - defines min and max range of allowed
valuesvalue - Integer value of this parameterunits - Units of this parameter
ConstraintException - Is thrown if the value is not allowed
ConstraintException - Is thrown if the value is not allowed| Method Detail |
|---|
public void addParameterChangeWarningListener(ParameterChangeWarningListener listener)
throws EditableException
addParameterChangeWarningListener in interface WarningParameter<Integer>listener - The feature to be added to the
ParameterChangeFailListener attribute
EditableException
public void removeParameterChangeWarningListener(ParameterChangeWarningListener listener)
throws EditableException
removeParameterChangeWarningListener in interface WarningParameter<Integer>EditableException
public void setWarningConstraint(AbstractParameterConstraint warningConstraint)
throws ParameterException,
EditableException
setWarningConstraint in interface WarningParameter<Integer>ParameterException
EditableException
public AbstractParameterConstraint getWarningConstraint()
throws ParameterException
getWarningConstraint in interface WarningParameter<Integer>ParameterException
public Integer getWarningMin()
throws Exception
getWarningMin in interface WarningParameter<Integer>Exception - Description of the Exceptionpublic Integer getWarningMax()
getWarningMax in interface WarningParameter<Integer>Exception - Description of the Exception
public void setValue(Integer value)
throws ConstraintException,
WarningException
setValue in interface Parameter<Integer>setValue in class AbstractParameter<Integer>value - The new value - must be a Integer
ConstraintException - Thrown if the new value is beyond the constraint
levels or null values not allowed.
WarningException - Thrown if the new value is beyond the warning levels.
public void setValueIgnoreWarning(Integer value)
throws ConstraintException,
ParameterException
setValueIgnoreWarning in interface WarningParameter<Integer>value - The new value - must be a Integer
ConstraintException - Thrown if the new value is beyond the constraint
levels or null values not allowed.
WarningException - Thrown if the new value is beyond the warning levels.
ParameterException - Thrown if the object is currenlty not
editablepublic boolean isRecommended(Integer obj)
isRecommended in interface WarningParameter<Integer>obj - Object to check if allowed via constraints
public void fireParameterChangeWarning(ParameterChangeWarningEvent event)
fireParameterChangeWarning in interface WarningParameter<Integer>event - The event encapsulating the attempted values passed to each listener.public Object clone()
clone in interface Parameter<Integer>clone in class IntegerParameterpublic void setIgnoreWarning(boolean ignoreWarning)
setIgnoreWarning in interface WarningParameter<Integer>public boolean isIgnoreWarning()
isIgnoreWarning in interface WarningParameter<Integer>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||