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

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

public class DoubleValueWeightConstraint
extends AbstractParameterConstraint

DoubleValueWeightConstraint : This class accepts a ValueWeight object and checks whether both value and weight are within the allowed range of values.

Author:
vipingupta
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.
protected  DoubleConstraint valueConstraint
          The value constraint
protected  DoubleConstraint weightConstraint
          The value constraint
 
Fields inherited from class org.opensha.commons.param.constraint.AbstractParameterConstraint
editable, name, nullAllowed
 
Constructor Summary
DoubleValueWeightConstraint()
          No-Arg Constructor, constraints are null so all values allowed
DoubleValueWeightConstraint(double minVal, double maxVal, double minWt, double maxWt)
          Constructor for the DoubleValueWeightConstraint object.
DoubleValueWeightConstraint(java.lang.Double minVal, java.lang.Double maxVal, java.lang.Double minWt, java.lang.Double maxWt)
          Constructor for the DoubleValueWeightConstraint object.
 
Method Summary
 java.lang.Object clone()
          Creates a copy of this object instance so the original cannot be altered.
 java.lang.Double getMaxVal()
          Gets the max allowed value of this constraint
 java.lang.Double getMaxWt()
          Gets the max allowed weight of this constraint
 java.lang.Double getMinVal()
          Returns the min allowed value of this constraint.
 java.lang.Double getMinWt()
          Returns the min allowed weight of this constraint.
 boolean isAllowed(double val, double wt)
          Checks if the passed in value and weight are within the min and max, inclusive of the end points.
 boolean isAllowed(java.lang.Object obj)
          Checks if the passed in value is within the min and max value and min and max weight, inclusive of the end points.
 boolean isAllowed(ValueWeight valueWt)
          Checks if the passed in value is within the min and max, inclusive of the end points.
 void setMinMax(double minVal, double maxVal, double minWt, double maxWt)
          Sets the min and max values and min and max weights allowed in this constraint.
 void setMinMax(java.lang.Double minVal, java.lang.Double maxVal, java.lang.Double minWt, java.lang.Double maxWt)
          Sets the min and max values and min and max weights allowed in this constraint.
 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

valueConstraint

protected DoubleConstraint valueConstraint
The value constraint


weightConstraint

protected DoubleConstraint weightConstraint
The value constraint

Constructor Detail

DoubleValueWeightConstraint

public DoubleValueWeightConstraint()
No-Arg Constructor, constraints are null so all values allowed


DoubleValueWeightConstraint

public DoubleValueWeightConstraint(double minVal,
                                   double maxVal,
                                   double minWt,
                                   double maxWt)
Constructor for the DoubleValueWeightConstraint object. Sets the min/max values and min/max weights allowed in this constraint. No checks are performed that min and max are consistant with each other.

Parameters:
minVal - The min value allowed
maxVal - The max value allowed
minWt - The min weight allowed
maxWt - The max weight allowed

DoubleValueWeightConstraint

public DoubleValueWeightConstraint(java.lang.Double minVal,
                                   java.lang.Double maxVal,
                                   java.lang.Double minWt,
                                   java.lang.Double maxWt)
Constructor for the DoubleValueWeightConstraint object. Sets the min/max values and min/max wts allowed in this constraint. No checks are performed that min and max are consistant with each other.

Parameters:
minVal - The min value allowed
maxVal - The max value allowed
minWt - The min weight allowed
maxWt - The max weight allowed
Method Detail

setMinMax

public void setMinMax(double minVal,
                      double maxVal,
                      double minWt,
                      double maxWt)
               throws EditableException
Sets the min and max values and min and max weights allowed in this constraint. No checks are performed that min and max are consistant with each other.

Parameters:
minVal - The new min value
maxVal - The new max value
minWt - The new min weight
maxWt - The new max weight
Throws:
EditableException - Thrown when the constraint or parameter containing this constraint has been made non-editable.

setMinMax

public void setMinMax(java.lang.Double minVal,
                      java.lang.Double maxVal,
                      java.lang.Double minWt,
                      java.lang.Double maxWt)
               throws EditableException
Sets the min and max values and min and max weights allowed in this constraint. No checks are performed that min and max are consistant with each other.

Parameters:
minVal - The new min value
maxVal - The new max value
minWt - The new min weight
maxWt - The new max weight
Throws:
EditableException - Thrown when the constraint or parameter containing this constraint has been made non-editable.

getMinVal

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


getMaxVal

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


getMinWt

public java.lang.Double getMinWt()
Returns the min allowed weight of this constraint.


getMaxWt

public java.lang.Double getMaxWt()
Gets the max allowed weight of this constraint


isAllowed

public boolean isAllowed(java.lang.Object obj)
Checks if the passed in value is within the min and max value and min and max weight, inclusive of the end points. First the value is chekced if it's null and null values are allowed. Then it checks the passed in object is a ValueWeight object. If the constraint min and max values are null, true is returned, else the value is compared against the min and max values. If any of these checks fails false is returned. Otherwise true is returned.

Parameters:
obj - The object to check if allowed.
Returns:
True if this is a ValueWeight object and one of the allowed values.

isAllowed

public boolean isAllowed(ValueWeight valueWt)
Checks if the passed in value is within the min and max, inclusive of the end points. First the value is chekced if it's null and null values are allowed. Then it checks the passed in object is a ValueWeight. If the constraint min and max values are null, true is returned, else the value is compared against the min and max values. If any of these checks fails false is returned. Otherwise true is returned.

Parameters:
obj - The object to check if allowed.
Returns:
True if this is a ValueWeight and one of the allowed values.

isAllowed

public boolean isAllowed(double val,
                         double wt)
Checks if the passed in value and weight are within the min and max, inclusive of the end points. First i is checked if it's null and null values are allowed. If the constraint min and max values are null, true is returned, else the value is compared against the min and max values. If any of these checks fails false is returned. Otherwise true is returned.

Parameters:
obj - The object to check if allowed.
Returns:
True if this is one of the allowed values.

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
Specified by:
clone in class AbstractParameterConstraint
Returns:
Exact copy of this object's state.