org.axiondb.types
Class BigDecimalType

java.lang.Object
  extended by org.axiondb.types.BaseDataType
      extended by org.axiondb.types.BaseNumberDataType
          extended by org.axiondb.types.BigDecimalType
All Implemented Interfaces:
Serializable, Comparator, DataType, DataType.ExactNumeric, DataType.NonFixedPrecision, DataTypeFactory

public class BigDecimalType
extends BaseNumberDataType
implements DataType.ExactNumeric

A DataTyperepresenting an number value.

Version:
$Revision: 1.16 $ $Date: 2005/12/22 09:02:31 $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axiondb.DataType
DataType.BinaryRepresentation, DataType.ExactNumeric, DataType.NonFixedPrecision
 
Field Summary
static int DEFAULT_PRECISION
           
static int DEFAULT_SCALE
           
static int MAX_PRECISION
           
static int ROUNDING_RULE
           
 
Constructor Summary
BigDecimalType()
           
BigDecimalType(BigDecimal result)
           
BigDecimalType(int scale)
           
BigDecimalType(int precision, int scale)
           
 
Method Summary
 boolean accepts(Object value)
          Returns true iff value is String that can be convertedwithout exception, null, or a Number.
 int compare(Object a, Object b)
           
 Object convert(Object value)
          Returns a BigDecimal converted from the given value , or throws IllegalArgumentExceptionif the given value isn't acceptable.
 int getColumnDisplaySize()
          Value returned by ResultSetMetaData#getColumnDisplaySizefor this data type.
protected  Comparator getComparator()
          This base implementation simply returns a ComparableComparator.
 int getJdbcType()
          Returns the JDBC type codemost closely matching this type.
 int getPrecision()
          Value returned by ResultSetMetaData#getPrecisionfor this data type.
 String getPreferredValueClassName()
          Returns the "normal" type returned by DataType.convert(java.lang.Object).
 int getScale()
          Value returned by ResultSetMetaData#getScalefor this data type.
 DataType makeNewInstance()
          Creates a new instance of this DataType implementation.
 DataType.ExactNumeric makeNewInstance(int newPrecision, int newScale)
          Creates a new instance of the implementing ExactNumeric type with the given precision and scale.
 Object read(DataInput in)
          Instantiate an object of my type from the given DataInput.
 boolean requiresRounding(BigDecimal value)
           
 void setPrecision(int newPrecision)
          Overrides the default precision with the given value.
 void setScale(int newScale)
          Overrides the default scale with the given value.
 Object successor(Object value)
          Returns the successor for the given value.
 boolean supportsSuccessor()
          false
 String toString()
          Returns "BigDecimal"
 void write(Object value, DataOutput out)
          Write an object of my type to the given DataOutput.
 
Methods inherited from class org.axiondb.types.BaseNumberDataType
toNumber
 
Methods inherited from class org.axiondb.types.BaseDataType
getLiteralPrefix, getLiteralSuffix, getNullableCode, getPrecisionRadix, getSearchableCode, isCaseSensitive, isCurrency, isUnsigned, toBigDecimal, toBigInteger, toBlob, toBoolean, toByte, toByteArray, toClob, toDate, toDouble, toFloat, toInt, toLong, toShort, toString, toTime, toTimestamp, toURL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.axiondb.DataType
getLiteralPrefix, getLiteralSuffix, getNullableCode, getPrecisionRadix, getSearchableCode, isCaseSensitive, isCurrency, isUnsigned, toBigDecimal, toBigInteger, toBlob, toBoolean, toByte, toByteArray, toClob, toDate, toDouble, toFloat, toInt, toLong, toShort, toString, toTime, toTimestamp, toURL
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

ROUNDING_RULE

public static final int ROUNDING_RULE
See Also:
Constant Field Values

DEFAULT_PRECISION

public static final int DEFAULT_PRECISION
See Also:
Constant Field Values

DEFAULT_SCALE

public static final int DEFAULT_SCALE
See Also:
Constant Field Values

MAX_PRECISION

public static final int MAX_PRECISION
See Also:
Constant Field Values
Constructor Detail

BigDecimalType

public BigDecimalType()

BigDecimalType

public BigDecimalType(int scale)

BigDecimalType

public BigDecimalType(int precision,
                      int scale)

BigDecimalType

public BigDecimalType(BigDecimal result)
Method Detail

getColumnDisplaySize

public int getColumnDisplaySize()
Description copied from interface: DataType
Value returned by ResultSetMetaData#getColumnDisplaySizefor this data type.

Specified by:
getColumnDisplaySize in interface DataType
Overrides:
getColumnDisplaySize in class BaseDataType
See Also:
ResultSetMetaData.getColumnDisplaySize(int)

getPrecision

public int getPrecision()
Description copied from interface: DataType
Value returned by ResultSetMetaData#getPrecisionfor this data type.

Specified by:
getPrecision in interface DataType
Overrides:
getPrecision in class BaseDataType
See Also:
ResultSetMetaData.getPrecision(int)

getJdbcType

public int getJdbcType()
Description copied from interface: DataType
Returns the JDBC type codemost closely matching this type.

Specified by:
getJdbcType in interface DataType
Specified by:
getJdbcType in class BaseDataType

getPreferredValueClassName

public String getPreferredValueClassName()
Description copied from interface: DataType
Returns the "normal" type returned by DataType.convert(java.lang.Object). Returns java.lang.Object if unknown.

Specified by:
getPreferredValueClassName in interface DataType
Overrides:
getPreferredValueClassName in class BaseDataType
See Also:
AxionResultSetMetaData.getColumnClassName(int)

getScale

public int getScale()
Description copied from interface: DataType
Value returned by ResultSetMetaData#getScalefor this data type.

Specified by:
getScale in interface DataType
Overrides:
getScale in class BaseDataType
See Also:
ResultSetMetaData.getScale(int)

setPrecision

public void setPrecision(int newPrecision)
Description copied from interface: DataType.NonFixedPrecision
Overrides the default precision with the given value.

Specified by:
setPrecision in interface DataType.NonFixedPrecision
Parameters:
newPrecision - new precision value. The appropriate value depends on the precision radix, which is fixed for each implementing type.

setScale

public void setScale(int newScale)
Description copied from interface: DataType.ExactNumeric
Overrides the default scale with the given value.

Specified by:
setScale in interface DataType.ExactNumeric
Parameters:
newScale - new scale value. The appropriate value depends on the current precision and radix - precision can be modified by the user, but the radix is fixed for each implementing type.

toString

public String toString()
Returns "BigDecimal"

Overrides:
toString in class Object
Returns:
"BigDecimal"

accepts

public boolean accepts(Object value)
Description copied from class: BaseNumberDataType
Returns true iff value is String that can be convertedwithout exception, null, or a Number.

Specified by:
accepts in interface DataType
Overrides:
accepts in class BaseNumberDataType
Parameters:
value - non- null value

requiresRounding

public boolean requiresRounding(BigDecimal value)

convert

public Object convert(Object value)
               throws AxionException
Returns a BigDecimal converted from the given value , or throws IllegalArgumentExceptionif the given value isn't acceptable.

Specified by:
convert in interface DataType
Overrides:
convert in class BaseNumberDataType
Throws:
AxionException

read

public Object read(DataInput in)
            throws IOException
Description copied from interface: DataType
Instantiate an object of my type from the given DataInput. The next sequence of bytes to be read from the DataInput will have been written by DataType.write(java.lang.Object, java.io.DataOutput).

Specified by:
read in interface DataType
Specified by:
read in class BaseDataType
Throws:
IOException
See Also:
write(java.lang.Object, java.io.DataOutput)

supportsSuccessor

public boolean supportsSuccessor()
false

Specified by:
supportsSuccessor in interface DataType
Overrides:
supportsSuccessor in class BaseNumberDataType

successor

public Object successor(Object value)
                 throws IllegalArgumentException
Description copied from interface: DataType
Returns the successor for the given value. For example, the successor of the integer 1 is 2.

Specified by:
successor in interface DataType
Overrides:
successor in class BaseDataType
Throws:
IllegalArgumentException

write

public void write(Object value,
                  DataOutput out)
           throws IOException
Description copied from interface: DataType
Write an object of my type to the given DataOutput.

Specified by:
write in interface DataType
Specified by:
write in class BaseDataType
Parameters:
value - the value to write, which must be acceptableto this DataType
Throws:
IOException

makeNewInstance

public DataType makeNewInstance()
Description copied from interface: DataType
Creates a new instance of this DataType implementation.

Specified by:
makeNewInstance in interface DataType
Specified by:
makeNewInstance in interface DataTypeFactory
Specified by:
makeNewInstance in class BaseDataType
Returns:
new instance of this DataType implementation.

compare

public int compare(Object a,
                   Object b)
Specified by:
compare in interface Comparator
Overrides:
compare in class BaseDataType

makeNewInstance

public DataType.ExactNumeric makeNewInstance(int newPrecision,
                                             int newScale)
Description copied from interface: DataType.ExactNumeric
Creates a new instance of the implementing ExactNumeric type with the given precision and scale.

Specified by:
makeNewInstance in interface DataType.ExactNumeric
Parameters:
newPrecision - precision of the new instance
newScale - scale of the new instance
Returns:
new instance of ExactNumeric implementation with the given precision and scale

getComparator

protected Comparator getComparator()
Description copied from class: BaseDataType
This base implementation simply returns a ComparableComparator.

Overrides:
getComparator in class BaseDataType