com.sas.models
Class BoundedLong

com.sas.models.BoundedLong
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.beans.VetoableChangeSource, ComponentInterface, com.sas.lang.LongDataInterface, 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 BoundedLong
implements BoundedNumberInterface, com.sas.PublicClonable, com.sas.lang.LongDataInterface, ValidationInterface

A BoundedLong is an implementation of BoundedNumberInterface. It stores a long value between a range of longs, with a value for the default increment. It replaces IntegerRange.

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
           
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
BoundedLong()
          Default constructor.
BoundedLong(long value, long min, long max)
          Creates an integer range with the specified value, minimum, and maximum amounts.
BoundedLong(long value, long min, long max, long unit, long block)
          Creates an integer range with the specified value, unitIncrement, blockIncrement, minimum, and maximum amounts.
 
Method Summary
 java.lang.Object clone()
          Clone an BoundedLong object
 void createValidationMessages()
           
 boolean equals(BoundedLong otherRange)
          Compare to an BoundedLong object.
 boolean equals(java.lang.Object object)
          Compare to an object.
 long getBlockIncrement()
          Gets the block value increment for the adjustable object.
 java.lang.Number getBlockIncrementNumber()
          Gets the block value increment for the adjustable object.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
           
 long getLongData()
          Get the long data of the currentValue
 long getMaximum()
          Gets the maximum value of the adjustable object.
 java.lang.Number getMaximumNumber()
          Gets the maximum value of the integer range.
 long getMinimum()
          Gets the minimum value of the adjustable object.
 java.lang.Number getMinimumNumber()
          Gets the minimum value of the integer range.
 java.lang.Number getNumberValue()
          Gets the unit value increment for the adjustable object.
 long 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.
 long 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(long 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 setLongData(long newValue)
          Set the long data of the currentValue
 void setMaximum(long 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(long 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(long 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(long newValue)
          Sets the current value of the adjustable object.
 void setValues(long value, long min, long max)
          Set the value, minimum and maximum at the same time.
 void setValues(long value, long min, long max, long unit, long block)
          Set the value, minimum, maximum, unitIncrement, and blockIncrement at the same time.
 java.lang.String toString()
          Return a string representation of an BoundedLong
 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

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

BoundedLong

public BoundedLong()
Default constructor.


BoundedLong

public BoundedLong(long value,
                   long min,
                   long max)
Creates an integer range with the specified value, 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
Throws:
java.lang.IllegalArgumentException - if (min > max), (unit < 0), (block < 0), (unit > range) or (block > range), where range = (max - min)

BoundedLong

public BoundedLong(long value,
                   long min,
                   long max,
                   long unit,
                   long block)
Creates an integer 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 BoundedLong 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 BoundedLong 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(BoundedLong otherRange)
Compare to an BoundedLong object.

Parameters:
otherRange - another BoundedLong 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 BoundedLong

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()

getLongData

public final long getLongData()
Get the long data of the currentValue

Specified by:
getLongData in interface com.sas.lang.LongDataInterface

setLongData

public final void setLongData(long newValue)
Set the long data of the currentValue

Specified by:
setLongData in interface com.sas.lang.LongDataInterface

getMaximum

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

Returns:
the current range maximum

getMinimum

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

Returns:
the current range minimum

getBlockIncrement

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

Returns:
the current block increment

getUnitIncrement

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

Returns:
the current unit increment

getValue

public long 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(long 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(long 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(long 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(long 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(long 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(long value,
                      long min,
                      long 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(long value,
                      long min,
                      long max,
                      long unit,
                      long block)
Set the value, minimum, maximum, unitIncrement, and blockIncrement 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)

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

getMaximumNumber

public final java.lang.Number getMaximumNumber()
Gets the maximum value of the integer 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 integer range.

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

getNumberValue

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

Specified by:
getNumberValue in interface BoundedNumberInterface
Returns:
the current unit 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

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))

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

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)

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))

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.