|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> [ types overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.iapi.types
Class UserType

java.lang.Objectorg.apache.derby.iapi.types.DataType
org.apache.derby.iapi.types.UserType
- All Implemented Interfaces:
- CloneableObject, DataValueDescriptor, java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, Orderable, java.io.Serializable, org.apache.derby.iapi.services.io.Storable, org.apache.derby.iapi.services.io.TypedFormat, UserDataValue
- public class UserType
- extends DataType
- implements UserDataValue
- extends DataType
This contains an instance of a user-defined type, that is, a java object.
| Field Summary | |
private static int |
BASE_MEMORY_USAGE
|
private java.lang.Object |
value
|
| Fields inherited from interface org.apache.derby.iapi.types.Orderable |
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN |
| Constructor Summary | |
UserType()
no-arg constructor required by Formattable |
|
UserType(java.lang.Object value)
|
|
| Method Summary | |
int |
compare(DataValueDescriptor other)
Orderable interface |
boolean |
compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
Compare this Orderable with a given Orderable for the purpose of qualification and sorting. |
BooleanDataValue |
equals(DataValueDescriptor left,
DataValueDescriptor right)
The = operator as called from the language module, as opposed to the storage module. |
int |
estimateMemoryUsage()
Estimate the memory usage in bytes of the data value and the overhead of the class. |
boolean |
getBoolean()
Gets the value in the data value descriptor as a boolean. |
byte |
getByte()
Gets the value in the data value descriptor as a byte. |
byte[] |
getBytes()
Gets the value in the data value descriptor as a byte array. |
DataValueDescriptor |
getClone()
Clone this DataValueDescriptor. |
java.sql.Date |
getDate(java.util.Calendar cal)
Gets the value in the data value descriptor as a java.sql.Date. |
double |
getDouble()
Gets the value in the data value descriptor as a double. |
float |
getFloat()
Gets the value in the data value descriptor as a float. |
int |
getInt()
Gets the value in the data value descriptor as an int. |
int |
getLength()
Gets the length of the data value. |
long |
getLong()
Gets the value in the data value descriptor as a long. |
DataValueDescriptor |
getNewNull()
Get a new null value of the same type as this data value. |
java.lang.Object |
getObject()
Gets the value in the data value descriptor as a Java Object. |
short |
getShort()
Gets the value in the data value descriptor as a short. |
java.lang.String |
getString()
Gets the value in the data value descriptor as a String. |
java.sql.Time |
getTime(java.util.Calendar cal)
Gets the value in the data value descriptor as a java.sql.Time. |
java.sql.Timestamp |
getTimestamp(java.util.Calendar cal)
Gets the value in the data value descriptor as a java.sql.Timestamp. |
int |
getTypeFormatId()
Return my format identifier. |
java.lang.String |
getTypeName()
Get the SQL name of the datatype |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
boolean |
isNull()
Check if the value is null. |
BooleanDataValue |
notEquals(DataValueDescriptor left,
DataValueDescriptor right)
The <> operator as called from the language module, as opposed to the storage module. |
void |
readExternal(java.io.ObjectInput in)
This method restores an object's state by reading in the instance data for the object from the passed in stream. |
void |
readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream in)
Read the DataValueDescriptor from the stream. |
void |
restoreToNull()
Restore this object to its (SQL)null value. |
void |
setBigDecimal(java.lang.Number theValue)
Set this value from an application supplied java.math.BigDecimal. |
protected void |
setFrom(DataValueDescriptor theValue)
|
void |
setObjectForCast(java.lang.Object theValue,
boolean instanceOfResultType,
java.lang.String resultTypeClassName)
Set the Object that this Data Type contains (for an explicit cast). |
void |
setValue(java.lang.Object value)
Set the value of this UserDataValue to the given Object |
void |
setValue(java.lang.String theValue)
Set the value of this DataValueDescriptor. |
void |
setValueFromResultSet(java.sql.ResultSet resultSet,
int colNumber,
boolean isNullable)
Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet. |
java.lang.String |
toString()
Convert this Object to a human-readable String. |
int |
typePrecedence()
Each built-in type in JSQL has a precedence. |
void |
writeExternal(java.io.ObjectOutput out)
This method is responsible for writing the instance data of an object to the passed in stream. |
| Methods inherited from class org.apache.derby.iapi.types.DataType |
checkHostVariable, cloneObject, coalesce, dataTypeConversion, equals, flip, genericSetObject, getNationalString, getStream, greaterOrEquals, greaterThan, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, outOfRange, setInto, setInto, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch, typeToBigDecimal |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor |
checkHostVariable, coalesce, getStream, greaterOrEquals, greaterThan, in, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, setInto, setInto, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, typeToBigDecimal |
| Field Detail |
value
private java.lang.Object value
BASE_MEMORY_USAGE
private static final int BASE_MEMORY_USAGE
| Constructor Detail |
UserType
public UserType()
- no-arg constructor required by Formattable
UserType
public UserType(java.lang.Object value)
| Method Detail |
estimateMemoryUsage
public int estimateMemoryUsage()
- Description copied from interface:
DataValueDescriptor - Estimate the memory usage in bytes of the data value and the overhead of the class.
- Specified by:
estimateMemoryUsagein interfaceDataValueDescriptor
getString
public java.lang.String getString()
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a String.
Throws an exception if the data value is not a string.
- Specified by:
getStringin interfaceDataValueDescriptor
getBoolean
public boolean getBoolean()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a boolean.
Throws an exception if the data value is not a boolean.
For DataValueDescriptor, this is the preferred interface
for BIT, but for this no-casting interface, it isn't, because
BIT is stored internally as a Bit, not as a Boolean.
- Specified by:
getBooleanin interfaceDataValueDescriptor- Overrides:
getBooleanin classDataType
getByte
public byte getByte()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a byte.
Throws an exception if the data value is not a byte.
- Specified by:
getBytein interfaceDataValueDescriptor- Overrides:
getBytein classDataType
getShort
public short getShort()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a short.
Throws an exception if the data value is not a short.
- Specified by:
getShortin interfaceDataValueDescriptor- Overrides:
getShortin classDataType
getInt
public int getInt()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as an int.
Throws an exception if the data value is not an int.
- Specified by:
getIntin interfaceDataValueDescriptor- Overrides:
getIntin classDataType
getLong
public long getLong()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a long.
Throws an exception if the data value is not a long.
- Specified by:
getLongin interfaceDataValueDescriptor- Overrides:
getLongin classDataType
getFloat
public float getFloat()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a float.
Throws an exception if the data value is not a float.
- Specified by:
getFloatin interfaceDataValueDescriptor- Overrides:
getFloatin classDataType
getDouble
public double getDouble()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a double.
Throws an exception if the data value is not a double.
- Specified by:
getDoublein interfaceDataValueDescriptor- Overrides:
getDoublein classDataType
getBytes
public byte[] getBytes()
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a byte array.
Throws an exception if the data value is not a byte array.
- Specified by:
getBytesin interfaceDataValueDescriptor- Overrides:
getBytesin classDataType
getDate
public java.sql.Date getDate(java.util.Calendar cal) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a java.sql.Date.
Throws an exception if the data value is not a Date.
- Specified by:
getDatein interfaceDataValueDescriptor- Overrides:
getDatein classDataType
getTime
public java.sql.Time getTime(java.util.Calendar cal) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a java.sql.Time.
Throws an exception if the data value is not a Time.
- Specified by:
getTimein interfaceDataValueDescriptor- Overrides:
getTimein classDataType
getTimestamp
public java.sql.Timestamp getTimestamp(java.util.Calendar cal) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a java.sql.Timestamp.
Throws an exception if the data value is not a Timestamp.
- Specified by:
getTimestampin interfaceDataValueDescriptor- Overrides:
getTimestampin classDataType
getObject
public java.lang.Object getObject()
- Description copied from interface:
DataValueDescriptor - Gets the value in the data value descriptor as a Java Object.
The type of the Object will be the Java object type corresponding
to the data value's SQL type. JDBC defines a mapping between Java
object types and SQL types - we will allow that to be extended
through user type definitions. Throws an exception if the data
value is not an object (yeah, right).
- Specified by:
getObjectin interfaceDataValueDescriptor- Overrides:
getObjectin classDataType
setObjectForCast
public void setObjectForCast(java.lang.Object theValue, boolean instanceOfResultType, java.lang.String resultTypeClassName) throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Set the Object that this Data Type contains (for an explicit cast).
- Specified by:
setObjectForCastin interfaceDataValueDescriptor- Overrides:
setObjectForCastin classDataType
getLength
public int getLength()
- Description copied from interface:
DataValueDescriptor - Gets the length of the data value. The meaning of this is
implementation-dependent. For string types, it is the number of
characters in the string. For numeric types, it is the number of
bytes used to store the number. This is the actual length
of this value, not the length of the type it was defined as.
For example, a VARCHAR value may be shorter than the declared
VARCHAR (maximum) length.
- Specified by:
getLengthin interfaceDataValueDescriptor
getTypeName
public java.lang.String getTypeName()
- Description copied from interface:
DataValueDescriptor - Get the SQL name of the datatype
- Specified by:
getTypeNamein interfaceDataValueDescriptor
getTypeFormatId
public int getTypeFormatId()
- Return my format identifier.
- Specified by:
getTypeFormatIdin interfaceorg.apache.derby.iapi.services.io.TypedFormat
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Description copied from interface:
java.io.Externalizable - This method is responsible for writing the instance data of an object
to the passed in stream. Note that this stream is not a subclass of
OutputStream, but rather is a class that implements theObjectOutputinterface. That interface provides a number of methods for writing Java data values to a stream.Not that the implementation of this method must be coordinated with the implementation of
readExternal.- Specified by:
writeExternalin interfacejava.io.Externalizable
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Description copied from interface:
java.io.Externalizable - This method restores an object's state by reading in the instance data
for the object from the passed in stream. Note that this stream is not
a subclass of
InputStream, but rather is a class that implements theObjectInputinterface. That interface provides a mechanism for reading in Java data types from a stream.Note that this method must be compatible with
writeExternal. It must read back the exact same types that were written by that method in the exact order they were written.If this method needs to read back an object instance, then the class for that object must be found and loaded. If that operation fails, then this method throws a
ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable
readExternalFromArray
public void readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Description copied from interface:
DataValueDescriptor - Read the DataValueDescriptor from the stream.
Initialize the data value by reading it's values from the ArrayInputStream. This interface is provided as a way to achieve possible performance enhancement when reading an array can be optimized over reading from a generic stream from readExternal().
- Specified by:
readExternalFromArrayin interfaceDataValueDescriptor
getClone
public DataValueDescriptor getClone()
- Description copied from interface:
DataValueDescriptor - Clone this DataValueDescriptor. Results in a new object
that has the same value as this but can be modified independently.
- Specified by:
getClonein interfaceDataValueDescriptor
getNewNull
public DataValueDescriptor getNewNull()
- Description copied from interface:
DataValueDescriptor - Get a new null value of the same type as this data value.
- Specified by:
getNewNullin interfaceDataValueDescriptor
restoreToNull
public void restoreToNull()
- Description copied from interface:
org.apache.derby.iapi.services.io.Storable - Restore this object to its (SQL)null value.
- Specified by:
restoreToNullin interfaceorg.apache.derby.iapi.services.io.Storable
setValueFromResultSet
public void setValueFromResultSet(java.sql.ResultSet resultSet, int colNumber, boolean isNullable) throws java.sql.SQLException
- Description copied from interface:
DataValueDescriptor - Set the value based on the value for the specified DataValueDescriptor
from the specified ResultSet.
- Specified by:
setValueFromResultSetin interfaceDataValueDescriptor
compare
public int compare(DataValueDescriptor other) throws org.apache.derby.iapi.error.StandardException
- Orderable interface
- Specified by:
comparein interfaceDataValueDescriptor
compare
public boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
throws org.apache.derby.iapi.error.StandardException
- Description copied from interface:
DataValueDescriptor - Compare this Orderable with a given Orderable for the purpose of
qualification and sorting. The caller gets to determine how nulls
should be treated - they can either be ordered values or unknown
values.
- Specified by:
comparein interfaceDataValueDescriptor- Overrides:
comparein classDataType
setValue
public void setValue(java.lang.Object value)
- Description copied from interface:
UserDataValue - Set the value of this UserDataValue to the given Object
- Specified by:
setValuein interfaceUserDataValue- Overrides:
setValuein classDataType
setFrom
protected void setFrom(DataValueDescriptor theValue) throws org.apache.derby.iapi.error.StandardException
setBigDecimal
public void setBigDecimal(java.lang.Number theValue)
- Description copied from interface:
DataValueDescriptor - Set this value from an application supplied java.math.BigDecimal.
This is to support the PreparedStatement.setBigDecimal method and
similar JDBC methods that allow an application to pass in a BigDecimal
to any SQL type.
Parameter is declared as java.lang.Number to allow compilation
under J2ME/CDC/Foundation. This method will not be called in
any environment that does not support java.math.BigDecimal.
- Specified by:
setBigDecimalin interfaceDataValueDescriptor- Overrides:
setBigDecimalin classDataType
setValue
public void setValue(java.lang.String theValue)
- Description copied from interface:
DataValueDescriptor - Set the value of this DataValueDescriptor.
- Specified by:
setValuein interfaceDataValueDescriptor- Overrides:
setValuein classDataType
equals
public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws org.apache.derby.iapi.error.StandardException
- The = operator as called from the language module, as opposed to
the storage module.
- Specified by:
equalsin interfaceDataValueDescriptor- Overrides:
equalsin classDataType
notEquals
public BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws org.apache.derby.iapi.error.StandardException
- The <> operator as called from the language module, as opposed to
the storage module.
- Specified by:
notEqualsin interfaceDataValueDescriptor- Overrides:
notEqualsin classDataType
toString
public java.lang.String toString()
- Description copied from class:
java.lang.Object - Convert this Object to a human-readable String.
There are no limits placed on how long this String
should be or what it should contain. We suggest you
make it as intuitive as possible to be able to place
it into System.out.println() 55
and such.
It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.
This method will be called when performing string concatenation with this object. If the result is
null, string concatenation will instead use"null".The default implementation returns
getClass().getName() + "@" + Integer.toHexString(hashCode()).
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
typePrecedence
public int typePrecedence()
- Description copied from interface:
DataValueDescriptor - Each built-in type in JSQL has a precedence. This precedence determines
how to do type promotion when using binary operators. For example, float
has a higher precedence than int, so when adding an int to a float, the
result type is float.
The precedence for some types is arbitrary. For example, it doesn't
matter what the precedence of the boolean type is, since it can't be
mixed with other types. But the precedence for the number types is
critical. The SQL standard requires that exact numeric types be
promoted to approximate numeric when one operator uses both. Also,
the precedence is arranged so that one will not lose precision when
promoting a type.
- Specified by:
typePrecedencein interfaceDataValueDescriptor- Overrides:
typePrecedencein classDataType
isNull
public final boolean isNull()
- Check if the value is null.
- Specified by:
isNullin interfaceorg.apache.derby.iapi.services.io.Storable
|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> [ types overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC