com.sas.models
Class BoundedDouble

com.sas.models.BoundedDouble
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, ComponentInterface, com.sas.lang.DoubleDataInterface, LinkPropertiesInterface, ModelInterface, BoundedNumberInterface, IncrementInterface, RangeInterface, com.sas.PublicClonable, ValidationInterface, ViewInterface, MultipleValueEventSourceInterface, java.beans.PropertyChangeListener, java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.EventListener

public class BoundedDouble
implements BoundedNumberInterface, com.sas.PublicClonable, com.sas.lang.DoubleDataInterface, ValidationInterface

A BoundedDouble is an implementation of BoundedNumberInterface. It stores a double value between a range of doubles, with a value for the default increment.

See Also:
BoundedNumberInterface, Serialized Form

Field Summary
protected static int INVALID_FORMAT
           
static java.lang.String invalidFormat
           
protected static OrderedCollection messages
           
protected static int ONLY_VALIDATE_STRING
           
static java.lang.String onlyValidateString
           
static java.lang.String RB_KEY
           
protected  java.lang.String validationMessageCode
           
protected static int VALUE_ABOVE_MAX
           
protected static int VALUE_BELOW_MIN
           
static java.lang.String valueAboveMax
           
static java.lang.String valueBelowMin
           
 
Fields inherited from interface com.sas.models.IncrementInterface
BLOCK, UNIT
 
Constructor Summary
BoundedDouble()
          Default constructor.
BoundedDouble(double value, double min, double max)
           
BoundedDouble(double value, double min, double max, double unit, double block)
          Creates an double range with the specified value, unitIncrement, blockIncrement, minimum, and maximum amounts.
 
Method Summary
 java.lang.Object clone()
          Clone an BoundedDouble object
 void createValidationMessages()
           
 boolean equals(BoundedDouble otherRange)
          Compare to an BoundedDouble object.
 boolean equals(java.lang.Object object)
          Compare to an object.
 double getBlockIncrement()
          Gets the block value increment for the adjustable object.
 java.lang.Number getBlockIncrementNumber()
          Gets the block value increment for the adjustable object.
 double getDoubleData()
           
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
 double getMaximum()
          Gets the maximum value of the adjustable object.
 java.lang.Number getMaximumNumber()
          Gets the maximum value of the double range.
 double getMinimum()
          Gets the minimum value of the adjustable object.
 java.lang.Number getMinimumNumber()
          Gets the minimum value of the double range.
 java.lang.Number getNumberValue()
          Gets the current value of the adjustable object.
 double getUnitIncrement()
          Gets the unit value increment for the adjustable object.
 java.lang.Number getUnitIncrementNumber()
          Gets the unit value increment for the adjustable object.
 com.sas.text.Message getValidationMessage()
          Returns the validation message set when validateValue() last returned false.
 java.lang.String getValidationMessageCode()
          Returns the validation message code set when validateValue() last returned false.
 double getValue()
          Gets the current value of the adjustable object.
 java.lang.Number incrementBy(int increment, int incrementType)
          Increment, by unit or block increment amount, the current value by the specified number of increments.
 com.sas.text.Message newValidationMessage(java.lang.String template)
           
 java.lang.Object normalizeValue(java.lang.Object component, java.lang.Object value)
          Allows the validator to modify the value after it has been deemed valid.
 void setBlockIncrement(double block)
          Sets the block value increment for the adjustable object.
 void setBlockIncrementNumber(java.lang.Number block)
          Sets the block value increment for the adjustable object.
 void setDefaultValues()
          Set the default values of all the attributes
 void setDoubleData(double newValue)
           
 void setMaximum(double max)
          Sets the maximum value of the adjustable object.
 void setMaximumNumber(java.lang.Number max)
          Sets the maximum value of the adjustable object.
 void setMinimum(double min)
          Sets the minimum value of the adjustable object.
 void setMinimumNumber(java.lang.Number min)
          Sets the minimum value of the adjustable object.
 void setNumberValue(java.lang.Number newValue)
          Sets the current value of the adjustable object.
 void setNumberValues(java.lang.Number newValue, java.lang.Number min, java.lang.Number max)
          Set the value, minimum and maximum at the same time.
 void setNumberValues(java.lang.Number newValue, java.lang.Number min, java.lang.Number max, java.lang.Number unit, java.lang.Number block)
          Set the value, minimum, maximum, unitIncrement, and blockIncrement at the same time.
 void setUnitIncrement(double unit)
          Sets the unit value increment for the adjustable object.
 void setUnitIncrementNumber(java.lang.Number unit)
          Sets the unit value increment for the adjustable object.
 void setValidationMessage(com.sas.text.Message message)
          Sets the validation message which indicates why validateValue() returned false.
 void setValidationMessageCode(java.lang.String code)
           
 void setValue(double newValue)
          Sets the current value of the adjustable object.
 void setValues(double value, double min, double max)
          Set the value, minimum and maximum at the same time.
 void setValues(double value, double min, double max, double unit, double block)
          Set the value, minimum and maximum at the same time.
 java.lang.String toString()
          Return a string representation of an BoundedDouble
 boolean validateValue(java.lang.Object component, java.lang.Object value)
          Validates the value passed in (possibly) based on information from the component passed in.
 
Methods inherited from class com.sas.Component
addLink, addPropertyChangeListener, addVetoableChangeListener, anyPropertyChangeListeners, attachModel, attachView, beansIsDesignTime, beansSetDesignTime, clone, detachModel, detachView, dumpComponent, firePropertyChange, firePropertyChange, fireVetoableChange, getComponentDescription, getComponentSupportInfo, getEventMethod, getEventValues, getLinkInfo, getModelInterface, getRequiredInterfaces, getResources, getStringResource, getViewInterfaceSupportInfo, initialize, initializeComponent, isDesignTime, isLinked, propertyChange, queryLinks, queryLinks, refresh, removeAllLinks, removeInterfaceTraps, removeLink, removePropertyChangeListener, removeVetoableChangeListener, setComponentDescription, setComponentSupportInfo, setLinkInfo, setModelInterface, setRequiredInterfaces, setViewInterfaceSupportInfo, supportsListenerInterface, supportsRequiredInterfaces, trapInterfaceEvents, validateObject
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

validationMessageCode

protected java.lang.String validationMessageCode

messages

protected static OrderedCollection messages

valueBelowMin

public static final java.lang.String valueBelowMin
See Also:
Constant Field Values

valueAboveMax

public static final java.lang.String valueAboveMax
See Also:
Constant Field Values

invalidFormat

public static final java.lang.String invalidFormat
See Also:
Constant Field Values

onlyValidateString

public static final java.lang.String onlyValidateString
See Also:
Constant Field Values

VALUE_BELOW_MIN

protected static final int VALUE_BELOW_MIN
See Also:
Constant Field Values

VALUE_ABOVE_MAX

protected static final int VALUE_ABOVE_MAX
See Also:
Constant Field Values

INVALID_FORMAT

protected static final int INVALID_FORMAT
See Also:
Constant Field Values

ONLY_VALIDATE_STRING

protected static final int ONLY_VALIDATE_STRING
See Also:
Constant Field Values
Constructor Detail

BoundedDouble

public BoundedDouble()
Default constructor.


BoundedDouble

public BoundedDouble(double value,
                     double min,
                     double max)

BoundedDouble

public BoundedDouble(double value,
                     double min,
                     double max,
                     double unit,
                     double block)
Creates an double range with the specified value, unitIncrement, blockIncrement, minimum, and maximum amounts.

Parameters:
value - initial value. If value < min it is set to min; if value > max, it is set to max
min - minimum value
max - maximum value
unit - unit increment
block - block increment
Throws:
java.lang.IllegalArgumentException - if (min > max), (unit < 0), (block < 0), (unit > range) or (block > range), where range = (max - min)
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()

equals

public boolean equals(java.lang.Object object)
Compare to an object.

Overrides:
equals in class java.lang.Object
Parameters:
object - another object
Returns:
true if the other object is an IntegerRange and the minimum, value, maximum, unit increment, and block increment equal; false otherwise.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone an BoundedDouble object

Specified by:
clone in interface com.sas.PublicClonable
Overrides:
clone in class Component
Returns:
a clone of this object.
Throws:
java.lang.CloneNotSupportedException - if there is a clone exception.

equals

public boolean equals(BoundedDouble otherRange)
Compare to an BoundedDouble object.

Parameters:
otherRange - another BoundedDouble object
Returns:
true if the other object is not null and the minimum, value, maximum, unit increment, and block increment equal; false otherwise.

toString

public java.lang.String toString()
Return a string representation of an BoundedDouble

Overrides:
toString in class java.lang.Object
Returns:
the string in the format "[min,value,max],unit,block"

setDefaultValues

public void setDefaultValues()
Set the default values of all the attributes

Specified by:
setDefaultValues in interface ComponentInterface
Overrides:
setDefaultValues in class Component
See Also:
ComponentInterface.setDefaultValues()

getDoubleData

public final double getDoubleData()
Specified by:
getDoubleData in interface com.sas.lang.DoubleDataInterface

setDoubleData

public final void setDoubleData(double newValue)
Specified by:
setDoubleData in interface com.sas.lang.DoubleDataInterface

getMaximum

public double getMaximum()
Gets the maximum value of the adjustable object.

Returns:
the current range maximum

getMinimum

public double getMinimum()
Gets the minimum value of the adjustable object.

Returns:
the current range minimum

getBlockIncrement

public double getBlockIncrement()
Gets the block value increment for the adjustable object.

Returns:
the current block increment

getUnitIncrement

public double getUnitIncrement()
Gets the unit value increment for the adjustable object.

Returns:
the current unit increment

getValue

public double getValue()
Gets the current value of the adjustable object.

Returns:
the current value

incrementBy

public java.lang.Number incrementBy(int increment,
                                    int incrementType)
Increment, by unit or block increment amount, the current value by the specified number of increments. The current value will be incremented( or decremented ) within the bounds of the maximum and minimum values.

Specified by:
incrementBy in interface IncrementInterface
Parameters:
increment - The number of incrementType(unit or block) amounts to increment the current value(can be negative to decrement value).
incrementType - UNIT to increment by the unit amount; BLOCK to increment by the block amount

setMaximum

public void setMaximum(double max)
Sets the maximum value of the adjustable object. The maximum value is included in the range of the value. If the value is currently higher than the new maximum, it will be set to the maximum value.

Parameters:
max - the maximum value
Throws:
java.lang.IllegalArgumentException - if max < minimum

setMinimum

public void setMinimum(double min)
Sets the minimum value of the adjustable object. The minimum value is included in the range of the value. If the value is currently lower than the new minimum, it will be set to the maximum value.

Parameters:
min - the minimum value
Throws:
java.lang.IllegalArgumentException - if min > maximum

setBlockIncrement

public void setBlockIncrement(double block)
Sets the block value increment for the adjustable object.

Parameters:
block - the block increment
Throws:
java.lang.IllegalArgumentException - if (block < 0) or (block > (maximum - minimum))

setUnitIncrement

public void setUnitIncrement(double unit)
Sets the unit value increment for the adjustable object.

Parameters:
unit - the unit increment
Throws:
java.lang.IllegalArgumentException - if (unit < 0) or (unit > (maximum - minimum))

setValue

public void setValue(double newValue)
Sets the current value of the adjustable object. The current value will only be set to within the range of the minimum and maximum values.

Parameters:
value - the current value

setValues

public void setValues(double value,
                      double min,
                      double max)
Set the value, minimum and maximum at the same time.

Parameters:
value - the new value
min - the new minimum
max - the new maximum
Throws:
java.lang.IllegalArgumentException - if (min > max), (unit < 0), (block < 0), (unit > range) or (block > range), where range = (max - min)

setValues

public void setValues(double value,
                      double min,
                      double max,
                      double unit,
                      double block)
Set the value, minimum and maximum at the same time.

Parameters:
value - the new value
min - the new minimum
max - the new maximum
unit - the new unit increment
block - the new block increment
Throws:
java.lang.IllegalArgumentException - if (min > max), (unit < 0), (block < 0), (unit > range) or (block > range), where range = (max - min)

getMaximumNumber

public final java.lang.Number getMaximumNumber()
Gets the maximum value of the double range.

Specified by:
getMaximumNumber in interface RangeInterface
Returns:
the current range maximum

getMinimumNumber

public final java.lang.Number getMinimumNumber()
Gets the minimum value of the double range.

Specified by:
getMinimumNumber in interface RangeInterface
Returns:
the current range minimum

getBlockIncrementNumber

public final java.lang.Number getBlockIncrementNumber()
Gets the block value increment for the adjustable object.

Specified by:
getBlockIncrementNumber in interface IncrementInterface
Returns:
the current block increment

getUnitIncrementNumber

public final java.lang.Number getUnitIncrementNumber()
Gets the unit value increment for the adjustable object.

Specified by:
getUnitIncrementNumber in interface IncrementInterface
Returns:
the current unit increment

getNumberValue

public final java.lang.Number getNumberValue()
Gets the current value of the adjustable object.

Specified by:
getNumberValue in interface BoundedNumberInterface
Returns:
the current unit increment

setMaximumNumber

public final void setMaximumNumber(java.lang.Number max)
Sets the maximum value of the adjustable object. The maximum value is included in the range of the value. If the value is currently higher than the new maximum, it will be set to the maximum value.

Specified by:
setMaximumNumber in interface RangeInterface
Parameters:
max - the maximum value
Throws:
java.lang.IllegalArgumentException - if max < minimum

setMinimumNumber

public final void setMinimumNumber(java.lang.Number min)
Sets the minimum value of the adjustable object. The minimum value is included in the range of the value. If the value is currently lower than the new minimum, it will be set to the maximum value.

Specified by:
setMinimumNumber in interface RangeInterface
Parameters:
min - the minimum value
Throws:
java.lang.IllegalArgumentException - if min > maximum

setBlockIncrementNumber

public final void setBlockIncrementNumber(java.lang.Number block)
Sets the block value increment for the adjustable object.

Specified by:
setBlockIncrementNumber in interface IncrementInterface
Parameters:
block - the block increment
Throws:
java.lang.IllegalArgumentException - if (block < 0) or (block > (maximum - minimum))

setUnitIncrementNumber

public final void setUnitIncrementNumber(java.lang.Number unit)
Sets the unit value increment for the adjustable object.

Specified by:
setUnitIncrementNumber in interface IncrementInterface
Parameters:
unit - the unit increment
Throws:
java.lang.IllegalArgumentException - if (unit < 0) or (unit > (maximum - minimum))

setNumberValue

public final void setNumberValue(java.lang.Number newValue)
Sets the current value of the adjustable object. The current value will only be set to within the range of the minimum and maximum values.

Specified by:
setNumberValue in interface BoundedNumberInterface
Parameters:
value - the current value

setNumberValues

public final void setNumberValues(java.lang.Number newValue,
                                  java.lang.Number min,
                                  java.lang.Number max)
Set the value, minimum and maximum at the same time.

Specified by:
setNumberValues in interface BoundedNumberInterface
Parameters:
value - the new value
min - the new minimum
max - the new maximum
Throws:
java.lang.IllegalArgumentException - if (min > max), (unit < 0), (block < 0), (unit > range) or (block > range), where range = (max - min)

setNumberValues

public final void setNumberValues(java.lang.Number newValue,
                                  java.lang.Number min,
                                  java.lang.Number max,
                                  java.lang.Number unit,
                                  java.lang.Number block)
Set the value, minimum, maximum, unitIncrement, and blockIncrement at the same time.

Specified by:
setNumberValues in interface BoundedNumberInterface
Parameters:
value - the new value
min - the new minimum
max - the new maximum
unit - the new unit increment
block - the new block increment
Throws:
java.lang.IllegalArgumentException - if (min > max), (unit < 0), (block < 0), (unit > range) or (block > range), where range = (max - min)

validateValue

public boolean validateValue(java.lang.Object component,
                             java.lang.Object value)
Description copied from interface: ValidationInterface
Validates the value passed in (possibly) based on information from the component passed in.

Specified by:
validateValue in interface ValidationInterface
Parameters:
component - an object containing the value
value - the value to be validated
Returns:
true if the value us valid, false if not. If false is returned, the validator should call setValidationMessage with a String for a reason.

normalizeValue

public java.lang.Object normalizeValue(java.lang.Object component,
                                       java.lang.Object value)
Description copied from interface: ValidationInterface
Allows the validator to modify the value after it has been deemed valid. The object doing the validation should call validateValue() on the value before passing it to normalizeValue(). Only if validateValue() returns true should normalizeValue() be called.

This might be used to change a valid date such as "5/5/96" into a normalized form such as "May 5, 1996".

Specified by:
normalizeValue in interface ValidationInterface
Parameters:
component - an object containing the value
value - the value to be normalized
Returns:
the normalized value. This can be the input value or a value drived from it.

getValidationMessageCode

public java.lang.String getValidationMessageCode()
Description copied from interface: ValidationInterface
Returns the validation message code set when validateValue() last returned false.

Specified by:
getValidationMessageCode in interface ValidationInterface
Returns:
a validation message code. The validation message code is a non-translatable string which identifies the cause of the last validation error. This will typically be used as a key to a resource bundle.

setValidationMessageCode

public void setValidationMessageCode(java.lang.String code)

getValidationMessage

public com.sas.text.Message getValidationMessage()
Description copied from interface: ValidationInterface
Returns the validation message set when validateValue() last returned false.

Specified by:
getValidationMessage in interface ValidationInterface
Returns:
the Message object, containing a format string and substitution values, which describe why the value passed to validateValue() is invalid.

setValidationMessage

public void setValidationMessage(com.sas.text.Message message)
Description copied from interface: ValidationInterface
Sets the validation message which indicates why validateValue() returned false.

Specified by:
setValidationMessage in interface ValidationInterface
Parameters:
message - a Message object that contains a format string and substitution values, which describe why the value passed to validateValue() is invalid.

createValidationMessages

public void createValidationMessages()

newValidationMessage

public com.sas.text.Message newValidationMessage(java.lang.String template)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.