com.davisor.data
Class IntegerRangeType

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.data.LocaleType
              extended bycom.davisor.data.FormatType
                  extended bycom.davisor.data.SimpleNumberType
                      extended bycom.davisor.data.IntegerType
                          extended bycom.davisor.data.IntegerRangeType
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, NumberType, java.io.Serializable

public class IntegerRangeType
extends IntegerType

IntegerRangeType extends the IntegerType class with the capability to constrain integer values within the given value range.

Since:
JDK1.1
See Also:
IntegerData, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
static java.lang.String TYPENAME
          Type name ("INTRANGE").
 
Fields inherited from class com.davisor.data.IntegerType
DEFAULT
 
Fields inherited from class com.davisor.data.FormatType
M_pattern, M_sample
 
Fields inherited from class com.davisor.data.LocaleType
DEFAULT_LOCALE, M_locale
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS
 
Constructor Summary
  IntegerRangeType()
          Default constructor.
  IntegerRangeType(IntegerRangeType irt)
          Copy constructor.
  IntegerRangeType(java.lang.String dataName)
          Creates a new default type with no identity.
  IntegerRangeType(java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.util.Locale locale, java.lang.String pattern, java.lang.Object sample, java.lang.Integer lower, java.lang.Integer upper)
          Creates a new integer range type.
  IntegerRangeType(java.lang.String dataName, java.lang.String id, java.lang.String format)
          Constructs a new restricted range integer data type.
protected IntegerRangeType(java.lang.String typeName, java.lang.String dataName, java.lang.String id, java.util.Map metaData, java.util.Locale locale, java.lang.String pattern, java.lang.Object sample, java.lang.Integer lower, java.lang.Integer upper)
          Creates a new integer range type.
 
Method Summary
 int check(int value)
          Checks an integer value with the current restricted range.
 com.davisor.core.Dupable dup()
          Makes a deep copy of this object.
 java.lang.String getFormat()
          Gets the type specification string.
 int intValue(java.lang.String value, java.text.ParsePosition status)
          Converts a string to an integer value while enforcing the current range constraints.
 void setFormat(java.lang.String format)
          Sets the integer value a restricted range.
 java.lang.String stringValue(int value)
          Converts an int value to a string while enforcing the current range constraints.
 
Methods inherited from class com.davisor.data.IntegerType
decode, encode, equals, getSQLCode, getValueClass, toData, toData, toData, toData
 
Methods inherited from class com.davisor.data.SimpleNumberType
byteValue, byteValue, createFormatter, doubleValue, doubleValue, floatValue, floatValue, intValue, longValue, longValue, numberValue, shortValue, shortValue, stringValue, stringValue, stringValue, stringValue, stringValue, stringValue, zero
 
Methods inherited from class com.davisor.data.FormatType
clearFormatter, getFormatter, getPattern, getSample, hashCode, setFormat, setLocale, setPattern, setSample
 
Methods inherited from class com.davisor.data.LocaleType
getLocale, setLocale
 
Methods inherited from class com.davisor.data.Type
ceil, check, check, compare, create, create, create, create, create, dup, floor, format, getCompatibility, getDataName, getId, getID, getMetaData, getMetaData, getSpecs, getSQLName, getSQLName, getTypeName, isNull, parseObject, register, register, setDataName, setId, setID, setMetaData, setMetaData, setSpecs, toString, toXML, xmlEnd, xmlStart
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPENAME

public static final java.lang.String TYPENAME
Type name ("INTRANGE").

See Also:
Constant Field Values
Constructor Detail

IntegerRangeType

public IntegerRangeType()
Default constructor.


IntegerRangeType

public IntegerRangeType(IntegerRangeType irt)
Copy constructor.


IntegerRangeType

public IntegerRangeType(java.lang.String dataName)
Creates a new default type with no identity.

Parameters:
dataName - data name (may be null)

IntegerRangeType

public IntegerRangeType(java.lang.String dataName,
                        java.lang.String id,
                        java.lang.String format)
Constructs a new restricted range integer data type.

This is the constructor the SQL type mapper Type.create(Integer,String,String,String) method will call to create a type that matches given SQL type.

Parameters:
dataName - data name (may be null)
id - type identity (may be null)
format - integer value range specification (may be null)
See Also:
setFormat(java.lang.String)

IntegerRangeType

public IntegerRangeType(java.lang.String dataName,
                        java.lang.String id,
                        java.util.Map metaData,
                        java.util.Locale locale,
                        java.lang.String pattern,
                        java.lang.Object sample,
                        java.lang.Integer lower,
                        java.lang.Integer upper)
Creates a new integer range type.

Parameters:
dataName - data name
id - type identity
metaData - type meta data map (may be null)
locale - type locale (may be null)
pattern - format pattern (may be null)
sample - format sample (may be null)
lower - range lower bound, inclusive (may be null)
upper - range upper bound, inclusive (may be null)

IntegerRangeType

protected IntegerRangeType(java.lang.String typeName,
                           java.lang.String dataName,
                           java.lang.String id,
                           java.util.Map metaData,
                           java.util.Locale locale,
                           java.lang.String pattern,
                           java.lang.Object sample,
                           java.lang.Integer lower,
                           java.lang.Integer upper)
Creates a new integer range type.

Parameters:
typeName - type name
dataName - data name
id - type identity
metaData - type meta data map (may be null)
locale - type locale (may be null)
pattern - format pattern (may be null)
sample - format sample (may be null)
lower - range lower bound, inclusive (may be null)
upper - range upper bound, inclusive (may be null)
Method Detail

dup

public com.davisor.core.Dupable dup()
Makes a deep copy of this object.

Specified by:
dup in interface com.davisor.core.Dupable
Overrides:
dup in class IntegerType

check

public int check(int value)
          throws InvalidDataException
Checks an integer value with the current restricted range.

Parameters:
value - integer value
Returns:
'value'
Throws:
InvalidDataException - if the value is invalid with respect to current integer value range

intValue

public int intValue(java.lang.String value,
                    java.text.ParsePosition status)
             throws InvalidDataException
Converts a string to an integer value while enforcing the current range constraints.

Specified by:
intValue in interface NumberType
Overrides:
intValue in class SimpleNumberType
Parameters:
value - the string to be converted
status - parse status (may be null)
Throws:
InvalidDataException - if the value is invalid with respect to current integer value range
See Also:
check(int), SimpleNumberType.intValue(String,ParsePosition)

stringValue

public java.lang.String stringValue(int value)
                             throws InvalidDataException
Converts an int value to a string while enforcing the current range constraints.

Specified by:
stringValue in interface NumberType
Overrides:
stringValue in class SimpleNumberType
Parameters:
value - the string to be converted
Throws:
InvalidDataException - if the value is invalid with respect to current integer value range
See Also:
FormatType.getFormatter()

getFormat

public java.lang.String getFormat()
Gets the type specification string.

Overrides:
getFormat in class FormatType
See Also:
setFormat(java.lang.String)

setFormat

public void setFormat(java.lang.String format)
Sets the integer value a restricted range. The range is defined by a specification string that has the format "a:b", where 'a' and 'b' give the lower and upper bounds of the range, inclusive. Omitting a boundary value indicates that the range is not limited in that direction.

Overrides:
setFormat in class FormatType
Parameters:
format - type specification string (may be null)
See Also:
getFormat()


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.