org.axiondb.types
Class CharacterType

java.lang.Object
  extended by org.axiondb.types.BaseDataType
      extended by org.axiondb.types.CharacterType
All Implemented Interfaces:
Serializable, Comparator, DataType, DataType.NonFixedPrecision, DataTypeFactory
Direct Known Subclasses:
CharacterVaryingType

public class CharacterType
extends BaseDataType
implements DataType.NonFixedPrecision

A DataTyperepresenting a single char value.

Version:
$Revision: 1.14 $ $Date: 2005/12/20 18:32:42 $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axiondb.DataType
DataType.BinaryRepresentation, DataType.ExactNumeric, DataType.NonFixedPrecision
 
Constructor Summary
CharacterType()
           
CharacterType(int size)
           
 
Method Summary
 boolean accepts(Object value)
          Returns true iff value is null, a Character, or a single character String.
 int compare(Object a, Object b)
           
 Object convert(Object value)
          Returns an String 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.
 String getLiteralPrefix()
          Prefix used to quote a literal to delimit value for this type when in SQL syntax or result display
 String getLiteralSuffix()
          Suffix used to quote a literal to delimit value for this type when in SQL syntax or result display
 int getPrecision()
          Value returned by ResultSetMetaData#getPrecisionfor this data type.
 String getPreferredValueClassName()
          Returns the "normal" type returned by DataType.convert(java.lang.Object).
 short getSearchableCode()
          Code indicating how much WHERE ...
 boolean isCaseSensitive()
          For character and string-related types, indicates whether type acknowledges case when storing and retrieving values
 DataType makeNewInstance()
          Creates a new instance of this DataType implementation.
protected  String process(String value)
           
 Object read(DataInput in)
          Instantiate an object of my type from the given DataInput.
protected  String rightTrim(String source)
           
 void setPrecision(int newSize)
          Overrides the default precision with the given value.
 Object successor(Object value)
          Returns the successor for the given value.
 boolean supportsSuccessor()
          Returns true if the DataType.successor(java.lang.Object)method is supported, false otherwise.
 byte[] toByteArray(Object value)
          Convert the given non- null value to a byte[], or throw a AxionException.
 String toString()
          Returns "character"
protected  String truncateIfLegal(String source)
           
 void write(Object value, DataOutput out)
          Writes the given value to the given DataOutput.Null values are written as Character.MIN_VALUE,false.
 
Methods inherited from class org.axiondb.types.BaseDataType
getNullableCode, getPrecisionRadix, getScale, isCurrency, isUnsigned, toBigDecimal, toBigInteger, toBlob, toBoolean, toByte, toClob, toDate, toDouble, toFloat, toInt, toLong, toNumber, 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
getNullableCode, getPrecisionRadix, getScale, isCurrency, isUnsigned, toBigDecimal, toBigInteger, toBlob, toBoolean, toByte, toClob, toDate, toDouble, toFloat, toInt, toLong, toShort, toString, toTime, toTimestamp, toURL
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

CharacterType

public CharacterType()

CharacterType

public CharacterType(int size)
Method Detail

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
Returns:
Types.CHAR

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)

getPrecision

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

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)

isCaseSensitive

public boolean isCaseSensitive()
Description copied from interface: DataType
For character and string-related types, indicates whether type acknowledges case when storing and retrieving values

Specified by:
isCaseSensitive in interface DataType
Overrides:
isCaseSensitive in class BaseDataType
See Also:
DatabaseMetaData.getTypeInfo(), ResultSetMetaData.isCaseSensitive(int)

toString

public String toString()
Returns "character"

Overrides:
toString in class Object
Returns:
"character"

toByteArray

public byte[] toByteArray(Object value)
                   throws AxionException
Description copied from interface: DataType
Convert the given non- null value to a byte[], or throw a AxionException.

Specified by:
toByteArray in interface DataType
Overrides:
toByteArray in class BaseDataType
Throws:
AxionException
See Also:
ResultSet.getBytes(int)

accepts

public boolean accepts(Object value)
Returns true iff value is null, a Character, or a single character String.

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

supportsSuccessor

public boolean supportsSuccessor()
Description copied from interface: DataType
Returns true if the DataType.successor(java.lang.Object)method is supported, false otherwise.

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

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

convert

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

Specified by:
convert in interface DataType
Specified by:
convert in class BaseDataType
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)

write

public void write(Object value,
                  DataOutput out)
           throws IOException
Writes the given value to the given DataOutput.Null values are written as Character.MIN_VALUE,false. Character.MIN_VALUE values are written as Character.MIN_VALUE,true. All other values are written directly.

Specified by:
write in interface DataType
Specified by:
write in class BaseDataType
Parameters:
value - the value to write, which must be acceptable
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

setPrecision

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

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

getLiteralPrefix

public String getLiteralPrefix()
Description copied from interface: DataType
Prefix used to quote a literal to delimit value for this type when in SQL syntax or result display

Specified by:
getLiteralPrefix in interface DataType
Overrides:
getLiteralPrefix in class BaseDataType
See Also:
DatabaseMetaData.getTypeInfo()

getLiteralSuffix

public String getLiteralSuffix()
Description copied from interface: DataType
Suffix used to quote a literal to delimit value for this type when in SQL syntax or result display

Specified by:
getLiteralSuffix in interface DataType
Overrides:
getLiteralSuffix in class BaseDataType
See Also:
DatabaseMetaData.getTypeInfo()

getSearchableCode

public short getSearchableCode()
Description copied from interface: DataType
Code indicating how much WHERE ... LIKE support is available across a column of this type

Specified by:
getSearchableCode in interface DataType
Overrides:
getSearchableCode in class BaseDataType
See Also:
DatabaseMetaData.getTypeInfo()

getComparator

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

Overrides:
getComparator in class BaseDataType

process

protected String process(String value)
                  throws AxionException
Throws:
AxionException

truncateIfLegal

protected final String truncateIfLegal(String source)
                                throws AxionException
Throws:
AxionException

rightTrim

protected final String rightTrim(String source)