org.opensha.commons.param.constraint.impl
Class EstimateConstraint

java.lang.Object
  extended by org.opensha.commons.param.constraint.AbstractParameterConstraint<Estimate>
      extended by org.opensha.commons.param.constraint.impl.EstimateConstraint
All Implemented Interfaces:
java.io.Serializable, Named, ParameterConstraint<Estimate>

public class EstimateConstraint
extends AbstractParameterConstraint<Estimate>

Title: DoubleEstimateConstraint.java

Description: A DoubleEstimateConstraint represents a range of allowed values between a min and max double value, inclusive and a list of allowed Estimate types. The main purpose of this class is to call isAllowed() which will return true if the value is an object of one of the allowed Estimate types and all the values are within the range specified here. See the DoubleConstraint javadocs for further documentation.

Copyright: Copyright (c) 2002

Company:

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

Field Summary
protected  StringConstraint allowedEstimateList
          It contains a list of Strings specifying the classnames of allowed Estimates
protected static java.lang.String C
          Class name for debugging.
protected static boolean D
          If true print out debug statements.
protected  java.lang.Double max
          The maximum value allowed in this constraint, inclusive
protected  java.lang.Double min
          The minimum value allowed in this constraint, inclusive
 
Fields inherited from class org.opensha.commons.param.constraint.AbstractParameterConstraint
editable, name, nullAllowed
 
Constructor Summary
EstimateConstraint()
          No-Arg Constructor, constraints are null so all values allowed and all estimate objects are allowed
EstimateConstraint(java.util.ArrayList<java.lang.String> allowedEstimateList)
          Accepts a list of classnames of allowed estimate objects.
EstimateConstraint(double min, double max)
          Accepts min/max values.
EstimateConstraint(double min, double max, java.util.ArrayList allowedEstimateList)
          Sets the min and max values, and a list of classnames of allowed estimate types in this constraint.
EstimateConstraint(java.lang.Double min, java.lang.Double max, java.util.ArrayList<java.lang.String> allowedEstimateList)
          Sets the min and max values, and a list of classnames of allowed estimate types in this constraint.
 
Method Summary
 java.lang.Object clone()
          Creates a copy of this object instance so the original cannot be altered.
static java.util.ArrayList createConstraintForAllEstimates()
          create constraint so that all estimates are allowed.
static java.util.ArrayList createConstraintForDateEstimates()
          Return a list of classnames which can be used to specify the date Estimate
static java.util.ArrayList createConstraintForPositiveDoubleValues()
          create constraint so that only postive double values are allowed.
static java.util.ArrayList createConstraintForPositiveIntValues()
          create constraint so that only postive int values are allowed.
 java.util.ArrayList getAllowedEstimateList()
          Get a list of classnames of allowed estimates
 java.lang.Double getMax()
          Gets the max allowed value of this constraint
 java.lang.Double getMin()
          Returns the min allowed value of this constraint.
 boolean isAllowed(Estimate estimate)
          This function first checks that estimate object is one of the allowed estimates.
 void setAllowedEstimateList(java.util.ArrayList<java.lang.String> allowedEstimateList)
          Set list of allowed Estimate classnames.
 java.lang.String toString()
          returns the classname of the constraint, and the min & max as a debug string
 
Methods inherited from class org.opensha.commons.param.constraint.AbstractParameterConstraint
checkEditable, getName, isEditable, isNullAllowed, setName, setNonEditable, setNullAllowed
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, 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

min

protected java.lang.Double min
The minimum value allowed in this constraint, inclusive


max

protected java.lang.Double max
The maximum value allowed in this constraint, inclusive


allowedEstimateList

protected StringConstraint allowedEstimateList
It contains a list of Strings specifying the classnames of allowed Estimates

Constructor Detail

EstimateConstraint

public EstimateConstraint()
No-Arg Constructor, constraints are null so all values allowed and all estimate objects are allowed


EstimateConstraint

public EstimateConstraint(java.util.ArrayList<java.lang.String> allowedEstimateList)
Accepts a list of classnames of allowed estimate objects. There is no constraint on min and max values and there are assumed to be null in this case.

Parameters:
allowedEstimateList - List of classnames of allowed Estimate objects

EstimateConstraint

public EstimateConstraint(double min,
                          double max)
Accepts min/max values. There is no constraint on Estimate type and so all the estimate types are allowed.

Parameters:
min -
max -

EstimateConstraint

public EstimateConstraint(double min,
                          double max,
                          java.util.ArrayList allowedEstimateList)
Sets the min and max values, and a list of classnames of allowed estimate types in this constraint. No checks are performed that min and max are consistant with each other.

Parameters:
min - The min value allowed
max - The max value allowed
allowedEstimateList - List of classnames of allowed Estimate objects

EstimateConstraint

public EstimateConstraint(java.lang.Double min,
                          java.lang.Double max,
                          java.util.ArrayList<java.lang.String> allowedEstimateList)
Sets the min and max values, and a list of classnames of allowed estimate types in this constraint. No checks are performed that min and max are consistant with each other.

Parameters:
min - The min value allowed
max - The max value allowed
allowedEstimateList - List of classnames of allowed Estimate objects
Method Detail

setAllowedEstimateList

public void setAllowedEstimateList(java.util.ArrayList<java.lang.String> allowedEstimateList)
                            throws EditableException
Set list of allowed Estimate classnames.

Parameters:
allowedEstimateList - object containing list of strings specfying classnames of allowed estimates
Throws:
EditableException - This exception is thrown if this constraint is non-editable but user tries to call this function

getAllowedEstimateList

public java.util.ArrayList getAllowedEstimateList()
Get a list of classnames of allowed estimates

Returns:
StringConstraint object containing list of strings specfying classnames of allowed estimates

isAllowed

public boolean isAllowed(Estimate estimate)
This function first checks that estimate object is one of the allowed estimates. Then it compares the min and max value of constraint with the min and max value from the estimate (the latter must be within the former). It also makes sure that both, Estimate object and EstimateParameter have same units

Parameters:
estimate -
Returns:

toString

public java.lang.String toString()
returns the classname of the constraint, and the min & max as a debug string

Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Creates a copy of this object instance so the original cannot be altered.

Specified by:
clone in interface ParameterConstraint<Estimate>
Specified by:
clone in class AbstractParameterConstraint<Estimate>
Returns:
Exact copy of this object's state.

createConstraintForPositiveDoubleValues

public static java.util.ArrayList createConstraintForPositiveDoubleValues()
create constraint so that only postive double values are allowed. This function will automatically exclude normal

Returns:

createConstraintForPositiveIntValues

public static java.util.ArrayList createConstraintForPositiveIntValues()
create constraint so that only postive int values are allowed.

Returns:

createConstraintForAllEstimates

public static java.util.ArrayList createConstraintForAllEstimates()
create constraint so that all estimates are allowed. (It does not include date estimates)

Returns:

createConstraintForDateEstimates

public static java.util.ArrayList createConstraintForDateEstimates()
Return a list of classnames which can be used to specify the date Estimate

Returns:

getMin

public java.lang.Double getMin()
Returns the min allowed value of this constraint.


getMax

public java.lang.Double getMax()
Gets the max allowed value of this constraint