java.io.Externalizable, java.io.Serializable, java.lang.Comparable, Formatable, Storable, TypedFormat, DataValueDescriptor, OrderableGenericConglomerate, HeapRowLocation, NumberDataType, SQLBinary, SQLBoolean, SQLChar, SQLDate, SQLRef, SQLTime, SQLTimestamp, StorableFormatId, UserType, XMLpublic abstract class DataType extends java.lang.Object implements DataValueDescriptor, java.lang.Comparable
UNKNOWN_LOGICAL_LENGTHORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN| Constructor | Description |
|---|---|
DataType() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
checkHostVariable(int declaredLength) |
Check the value to seem if it conforms to the restrictions
imposed by DB2/JCC on host variables for this type.
|
DataValueDescriptor |
cloneHolder() |
Default implementation of shallow cloning, which forwards to the deep
clone method.
|
DataValueDescriptor |
coalesce(DataValueDescriptor[] argumentsList,
DataValueDescriptor returnValue) |
The SQL language COALESCE/VALUE function.
|
boolean |
compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV) |
Compare this Orderable with a given Orderable for the purpose of
qualification and sorting.
|
boolean |
compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean nullsOrderedLow,
boolean unknownRV) |
Compare this Orderable with another, with configurable null ordering.
|
int |
compare(DataValueDescriptor other,
boolean nullsOrderedLow) |
Compare this Orderable with another, with configurable null ordering.
|
int |
compareTo(java.lang.Object otherDVD) |
Wrapper method for the "compare(DataValueDescriptor)" method of
this class.
|
protected StandardException |
dataTypeConversion(java.lang.String targetType) |
Return an conversion exception from this type to another.
|
boolean |
equals(java.lang.Object other) |
|
BooleanDataValue |
equals(DataValueDescriptor left,
DataValueDescriptor right) |
The = operator as called from the language module, as opposed to
the storage module.
|
protected static int |
flip(int operator) |
Flip the operator used in a comparison (< -> >).
|
(package private) void |
genericSetObject(java.lang.Object theValue) |
|
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[].
|
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 a int.
|
long |
getLong() |
Gets the value in the data value descriptor as a long.
|
java.lang.Object |
getObject() |
Gets the value in the data value descriptor as a int.
|
short |
getShort() |
Gets the value in the data value descriptor as a short.
|
java.io.InputStream |
getStream() |
Gets the value in the data stream descriptor as an InputStream.
|
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.
|
java.lang.String |
getTraceString() |
Gets the value in the data stream descriptor as a trace string.
|
(package private) java.lang.String |
getTypeName(java.lang.String className) |
Get the type name of this value, possibly overriding
with the passed in class name (for user/java types).
|
BooleanDataValue |
greaterOrEquals(DataValueDescriptor left,
DataValueDescriptor right) |
The >= operator as called from the language module, as opposed to
the storage module.
|
BooleanDataValue |
greaterThan(DataValueDescriptor left,
DataValueDescriptor right) |
The > operator as called from the language module, as opposed to
the storage module.
|
boolean |
hasStream() |
Tells that the value isn't represented as a stream, which is true for
most Derby data types.
|
BooleanDataValue |
in(DataValueDescriptor left,
DataValueDescriptor[] inList,
boolean orderedList) |
The SQL language IN operator.
|
protected StandardException |
invalidFormat() |
Return an out of range exception for this type.
|
BooleanDataValue |
isNotNull() |
The is not null operator as called from the language module, as opposed to
the storage module.
|
BooleanDataValue |
isNullOp() |
The is null operator as called from the language module, as opposed to
the storage module.
|
BooleanDataValue |
lessOrEquals(DataValueDescriptor left,
DataValueDescriptor right) |
The <= operator as called from the language module, as opposed to
the storage module.
|
BooleanDataValue |
lessThan(DataValueDescriptor left,
DataValueDescriptor right) |
The < operator as called from the language module, as opposed to
the storage module.
|
void |
normalize(DataTypeDescriptor desiredType,
DataValueDescriptor source) |
Default normalization method.
|
BooleanDataValue |
notEquals(DataValueDescriptor left,
DataValueDescriptor right) |
The <> operator as called from the language module, as opposed to
the storage module.
|
protected StandardException |
outOfRange() |
Return an out of range exception for this type.
|
void |
readExternalFromArray(ArrayInputStream in) |
Read the DataValueDescriptor from the stream.
|
DataValueDescriptor |
recycle() |
Recycle this DataType object.
|
void |
setBigDecimal(java.math.BigDecimal bigDecimal) |
Only to be called when the application sets a value using BigDecimal
|
protected void |
setFrom(DataValueDescriptor dvd) |
Set the value of this DataValueDescriptor based on the value
of the specified DataValueDescriptor.
|
void |
setInto(java.sql.PreparedStatement ps,
int position) |
Set this value into a PreparedStatement.
|
void |
setInto(java.sql.ResultSet rs,
int position) |
Set this value into a ResultSet for a subsequent ResultSet.insertRow
or ResultSet.updateRow.
|
(package private) void |
setObject(java.lang.Object theValue) |
Set the value from an non-null object.
|
void |
setObjectForCast(java.lang.Object theValue,
boolean instanceOfResultType,
java.lang.String resultTypeClassName) |
Set this value from an Object.
|
void |
setToNull() |
Set the value to SQL null.
|
void |
setValue(boolean theValue) |
Set the value.
|
void |
setValue(byte theValue) |
Set the value of this DataValueDescriptor to the given byte value
At DataType level just throws an error lower classes will override
|
void |
setValue(byte[] theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(double theValue) |
Set the value of this DataValueDescriptor to the given double value
At DataType level just throws an error lower classes will override
|
void |
setValue(float theValue) |
Set the value of this DataValueDescriptor to the given float value
At DataType level just throws an error lower classes will override
|
void |
setValue(int theValue) |
Set the value of this DataValueDescriptor to the given int value
At DataType level just throws an error lower classes will override
|
void |
setValue(long theValue) |
Set the value of this DataValueDescriptor to the given long value
At DataType level just throws an error lower classes will override
|
void |
setValue(short theValue) |
Set the value of this DataValueDescriptor to the given short value
At DataType level just throws an error lower classes will override
|
void |
setValue(java.io.InputStream theStream,
int valueLength) |
Set the value to be the contents of the stream.
|
void |
setValue(java.lang.Object theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.lang.String theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Blob theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Clob theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Date theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Date theValue,
java.util.Calendar cal) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Time theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Time theValue,
java.util.Calendar cal) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Timestamp theValue) |
Set the value of this DataValueDescriptor.
|
void |
setValue(java.sql.Timestamp theValue,
java.util.Calendar cal) |
Set the value of this DataValueDescriptor.
|
void |
setValue(DataValueDescriptor dvd) |
Set the value of this DataValueDescriptor from another.
|
void |
throwLangSetMismatch(java.lang.Object value) |
|
(package private) void |
throwLangSetMismatch(java.lang.String argTypeName) |
|
int |
typePrecedence() |
Each built-in type in JSQL has a precedence.
|
int |
typeToBigDecimal() |
How should this value be obtained so that it can
be converted to a BigDecimal representation.
|
cloneValue, compare, estimateMemoryUsage, getLength, getNewNull, getString, getTypeName, setValueFromResultSetclone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisNull, restoreToNullgetTypeFormatIdpublic boolean getBoolean()
throws StandardException
getBoolean in interface DataValueDescriptorStandardException - Thrown on errorpublic byte getByte()
throws StandardException
getByte in interface DataValueDescriptorStandardException - Thrown on errorpublic short getShort()
throws StandardException
getShort in interface DataValueDescriptorStandardException - Thrown on errorpublic int getInt()
throws StandardException
getInt in interface DataValueDescriptorStandardException - Thrown on errorpublic long getLong()
throws StandardException
getLong in interface DataValueDescriptorStandardException - Thrown on errorpublic float getFloat()
throws StandardException
getFloat in interface DataValueDescriptorStandardException - Thrown on errorpublic double getDouble()
throws StandardException
getDouble in interface DataValueDescriptorStandardException - Thrown on errorpublic int typeToBigDecimal()
throws StandardException
DataValueDescriptortypeToBigDecimal in interface DataValueDescriptorStandardException - Conversion is not possiblepublic byte[] getBytes()
throws StandardException
getBytes in interface DataValueDescriptorStandardException - Thrown on errorpublic java.sql.Date getDate(java.util.Calendar cal)
throws StandardException
getDate in interface DataValueDescriptorcal - calendar for object creationStandardException - Thrown on errorpublic java.sql.Time getTime(java.util.Calendar cal)
throws StandardException
getTime in interface DataValueDescriptorcal - calendar for object creationStandardException - Thrown on errorpublic java.sql.Timestamp getTimestamp(java.util.Calendar cal)
throws StandardException
getTimestamp in interface DataValueDescriptorcal - calendar for object creationStandardException - Thrown on errorpublic java.io.InputStream getStream()
throws StandardException
getStream in interface DataValueDescriptorStandardException - Thrown on errorDataValueDescriptor.hasStream(),
StringDataValue.getStreamWithDescriptor()public boolean hasStream()
This method will be overridden by types able to use a stream as the source.
hasStream in interface DataValueDescriptorfalseDataValueDescriptor.getStream(),
StringDataValue.getStreamWithDescriptor()public java.lang.String getTraceString()
throws StandardException
getString.getTraceString in interface DataValueDescriptorStandardException - if getting the data value fails.DataValueDescriptor.getString()public DataValueDescriptor recycle()
recycle in interface DataValueDescriptorpublic void readExternalFromArray(ArrayInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal(), which accesses the ArrayInputStream
as a generic stream. If sub-classes can implement it more efficiently
by accessing the array, they should override this method.readExternalFromArray in interface DataValueDescriptorin - The array stream positioned at the beginning of the
byte stream to read from.java.io.IOException - Usual error is if you try to read
past limit on the stream.java.lang.ClassNotFoundException - If a necessary class can not be
found while reading the object from
the stream.DataValueDescriptor.readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream),
Externalizable.readExternal(java.io.ObjectInput)public final BooleanDataValue isNullOp()
isNullOp in interface DataValueDescriptorpublic final BooleanDataValue isNotNull()
isNotNull in interface DataValueDescriptorpublic void setValue(java.sql.Time theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Time value to set this DataValueDescriptor toStandardExceptionpublic void setValue(java.sql.Time theValue,
java.util.Calendar cal)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Time value to set this DataValueDescriptor tocal - The time zone from the calendar is used to construct the database time valueStandardExceptionpublic void setValue(java.sql.Timestamp theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Timestamp value to set this DataValueDescriptor toStandardExceptionpublic void setValue(java.sql.Timestamp theValue,
java.util.Calendar cal)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Timestamp value to set this DataValueDescriptor tocal - The time zone from the calendar is used to construct the database timestamp valueStandardExceptionpublic void setValue(java.sql.Date theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Date value to set this DataValueDescriptor toStandardExceptionpublic void setValue(java.sql.Date theValue,
java.util.Calendar cal)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Date value to set this DataValueDescriptor tocal - The time zone from the calendar is used to construct the database date valueStandardExceptionpublic void setValue(java.lang.Object theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Object value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(java.lang.String theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The BigDecimal value to set this DataValueDescriptor toStandardExceptionpublic void setValue(java.sql.Blob theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Blob value to set this DataValueDescriptor toStandardExceptionpublic void setValue(java.sql.Clob theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The Clob value to set this DataValueDescriptor toStandardExceptionpublic void setValue(int theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(double theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(float theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(short theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(long theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(byte theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorpublic void setValue(boolean theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - Contains the boolean value to set this toStandardExceptionpublic void setValue(byte[] theValue)
throws StandardException
setValue in interface DataValueDescriptortheValue - The byte value to set this DataValueDescriptor toStandardExceptionpublic void setBigDecimal(java.math.BigDecimal bigDecimal)
throws StandardException
setBigDecimal in interface DataValueDescriptorbigDecimal - required to be a BigDecimal or null.StandardExceptionpublic final void setValue(DataValueDescriptor dvd) throws StandardException
DataValueDescriptorsetValue in interface DataValueDescriptordvd - The Date value to set this DataValueDescriptor toStandardExceptionprotected void setFrom(DataValueDescriptor dvd) throws StandardException
dvd - The DataValueDescriptor that holds the value to
which we want to set this DataValueDescriptor's value.StandardExceptionpublic void setToNull()
DataValueDescriptorsetToNull in interface DataValueDescriptorDataValueDescriptor.setToNull()public void setObjectForCast(java.lang.Object theValue,
boolean instanceOfResultType,
java.lang.String resultTypeClassName)
throws StandardException
DataValueDescriptorsetObjectForCast in interface DataValueDescriptortheValue - The new valueinstanceOfResultType - Whether or not the new value
is an instanceof the result type.resultTypeClassName - The class name of the resulting (declared) type
(for error messages only).StandardException - thrown on failureDataValueDescriptor.setObjectForCast(java.lang.Object, boolean, java.lang.String)void setObject(java.lang.Object theValue)
throws StandardException
StandardExceptionjava.lang.String getTypeName(java.lang.String className)
className - public java.lang.Object getObject()
throws StandardException
getObject in interface DataValueDescriptorStandardException - Thrown on errorvoid genericSetObject(java.lang.Object theValue)
throws StandardException
StandardExceptionpublic DataValueDescriptor cloneHolder()
For many of the data types, a shallow clone will be the same as a deep clone. The data types requiring special handling of shallow clones have to override this method (for instance types whose value can be represented as a stream).
cloneHolder in interface DataValueDescriptorpublic void throwLangSetMismatch(java.lang.Object value)
throws StandardException
StandardExceptionvoid throwLangSetMismatch(java.lang.String argTypeName)
throws StandardException
StandardExceptionpublic void setInto(java.sql.PreparedStatement ps,
int position)
throws java.sql.SQLException,
StandardException
DataValueDescriptorsetInto in interface DataValueDescriptorjava.sql.SQLException - thrown by the PreparedStatement objectStandardException - thrown by me accessing my value.public void setInto(java.sql.ResultSet rs,
int position)
throws java.sql.SQLException,
StandardException
setInto in interface DataValueDescriptorjava.sql.SQLException - thrown by the ResultSet objectStandardException - thrown by me accessing my value.public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException
normalize in interface DataValueDescriptordesiredType - The type to normalize the source column tosource - The value to normalizeStandardException - Thrown normalization error.public int typePrecedence()
typePrecedence in interface DataValueDescriptorpublic BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
equals in interface DataValueDescriptorleft - The value on the left side of the =right - The value on the right side of the =StandardException - Thrown on errorpublic BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
notEquals in interface DataValueDescriptorleft - The value on the left side of the <>right - The value on the right side of the <>StandardException - Thrown on errorpublic BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
lessThan in interface DataValueDescriptorleft - The value on the left side of the <right - The value on the right side of the <StandardException - Thrown on errorpublic BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
greaterThan in interface DataValueDescriptorleft - The value on the left side of the >right - The value on the right side of the >StandardException - Thrown on errorpublic BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
lessOrEquals in interface DataValueDescriptorleft - The value on the left side of the <=right - The value on the right side of the <=StandardException - Thrown on errorpublic BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
greaterOrEquals in interface DataValueDescriptorleft - The value on the left side of the >=right - The value on the right side of the >=StandardException - Thrown on errorpublic boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
throws StandardException
DataValueDescriptorcompare in interface DataValueDescriptorop - Orderable.ORDER_OP_EQUALS means do an = comparison.
Orderable.ORDER_OP_LESSTHAN means compare this < other.
Orderable.ORDER_OP_LESSOREQUALS means compare this <= other.other - The DataValueDescriptor to compare this one to.orderedNulls - True means to treat nulls as ordered values,
that is, treat SQL null as equal to null, and less
than all other values.
False means to treat nulls as unknown values,
that is, the result of any comparison with a null
is the UNKNOWN truth value.unknownRV - The return value to use if the result of the
comparison is the UNKNOWN truth value. In other
words, if orderedNulls is false, and a null is
involved in the comparison, return unknownRV.
This parameter is not used orderedNulls is true.StandardException - Thrown on errorpublic boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean nullsOrderedLow,
boolean unknownRV)
throws StandardException
compare in interface DataValueDescriptorop - Orderable.ORDER_OP_EQUALS means do an = comparison.
Orderable.ORDER_OP_LESSTHAN means compare this < other.
Orderable.ORDER_OP_LESSOREQUALS means compare this <= other.other - The DataValueDescriptor to compare this one to.orderedNulls - True means to treat nulls as ordered values,
that is, treat SQL null as equal to null, and either greater or less
than all other values.
False means to treat nulls as unknown values,
that is, the result of any comparison with a null
is the UNKNOWN truth value.nullsOrderedLow - True means NULL less than non-NULL,
false means NULL greater than non-NULL.
Only relevant if orderedNulls is true.unknownRV - The return value to use if the result of the
comparison is the UNKNOWN truth value. In other
words, if orderedNulls is false, and a null is
involved in the comparison, return unknownRV.
This parameter is not used orderedNulls is true.StandardException - Thrown on errorpublic int compare(DataValueDescriptor other, boolean nullsOrderedLow) throws StandardException
compare in interface DataValueDescriptorother - The Orderable to compare this one to.
% @param nullsOrderedLow True if null should be lower than non-NULLStandardException - Thrown on errorpublic int compareTo(java.lang.Object otherDVD)
compareTo in interface java.lang.ComparableComparable.compareTo(T)protected static int flip(int operator)
operator - The operator to flip.public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue) throws StandardException
DataValueDescriptorcoalesce in interface DataValueDescriptorargumentsList - The list of the arguments. Function will return the first non-nullable argument if any.returnValue - The return value is the correct datatype for this function.
The return value of this method is the type of the 2nd parameter.StandardException - Thrown on errorDataValueDescriptor.coalesce(org.apache.derby.iapi.types.DataValueDescriptor[], org.apache.derby.iapi.types.DataValueDescriptor)public BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException
DataValueDescriptorin in interface DataValueDescriptorleft - The value on the left side of the operatorinList - The values in the IN listorderedList - True means that the values in the IN list are ordered,
false means they are not.StandardException - Thrown on errorDataValueDescriptor.in(org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.types.DataValueDescriptor[], boolean)public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic void setValue(java.io.InputStream theStream,
int valueLength)
throws StandardException
DataValueDescriptorThe reading of the stream may be delayed until execution time, and the format of the stream is required to be the format of this type.
Note that the logical length excludes any header bytes and marker bytes
(for instance the Derby specific EOF stream marker). Specifying the
logical length may improve performance in some cases, but specifying
that the length is unknown (UNKNOWN_LOGICAL_LENGTH should
always leave the system in a functional state. Specifying an incorrect
length will cause errors.
setValue in interface DataValueDescriptortheStream - stream of correctly formatted datavalueLength - logical length of the stream's value in units of this
type (e.g. chars for string types), or
UNKNOWN_LOGICAL_LENGTH if the logical length is unknownStandardExceptionpublic void checkHostVariable(int declaredLength)
throws StandardException
checkHostVariable in interface DataValueDescriptorStandardException - Variable is too big.protected final StandardException dataTypeConversion(java.lang.String targetType)
protected final StandardException outOfRange()
protected final StandardException invalidFormat()
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.