public abstract class DataType extends java.lang.Object implements DataValueDescriptor, java.lang.Comparable
UNKNOWN_LOGICAL_LENGTH
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN
Constructor and Description |
---|
DataType() |
Modifier and Type | Method and 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.
|
int |
compare(DataValueDescriptor other,
boolean nullsOrderedLow)
Compare this Orderable with another, with configurable null ordering.
|
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 |
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.
|
BooleanDataValue |
equals(DataValueDescriptor left,
DataValueDescriptor right)
The = operator as called from the language module, as opposed to
the storage module.
|
boolean |
equals(java.lang.Object other) |
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(java.sql.Blob theValue)
Set the value of this DataValueDescriptor.
|
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(java.sql.Clob theValue)
Set the value of this DataValueDescriptor.
|
void |
setValue(DataValueDescriptor dvd)
Set the value of this DataValueDescriptor from another.
|
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(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(java.io.InputStream theStream,
int valueLength)
Set the value to be the contents of the stream.
|
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(java.lang.Object theValue)
Set the value of this DataValueDescriptor.
|
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.lang.String theValue)
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 |
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.
|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cloneValue, compare, estimateMemoryUsage, getLength, getNewNull, getString, getTypeName, setValueFromResultSet
isNull, restoreToNull
getTypeFormatId
public boolean getBoolean() throws StandardException
getBoolean
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic byte getByte() throws StandardException
getByte
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic short getShort() throws StandardException
getShort
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic int getInt() throws StandardException
getInt
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic long getLong() throws StandardException
getLong
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic float getFloat() throws StandardException
getFloat
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic double getDouble() throws StandardException
getDouble
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic int typeToBigDecimal() throws StandardException
DataValueDescriptor
typeToBigDecimal
in interface DataValueDescriptor
StandardException
- Conversion is not possiblepublic byte[] getBytes() throws StandardException
getBytes
in interface DataValueDescriptor
StandardException
- Thrown on errorpublic java.sql.Date getDate(java.util.Calendar cal) throws StandardException
getDate
in interface DataValueDescriptor
cal
- calendar for object creationStandardException
- Thrown on errorpublic java.sql.Time getTime(java.util.Calendar cal) throws StandardException
getTime
in interface DataValueDescriptor
cal
- calendar for object creationStandardException
- Thrown on errorpublic java.sql.Timestamp getTimestamp(java.util.Calendar cal) throws StandardException
getTimestamp
in interface DataValueDescriptor
cal
- calendar for object creationStandardException
- Thrown on errorpublic java.io.InputStream getStream() throws StandardException
getStream
in interface DataValueDescriptor
StandardException
- 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 DataValueDescriptor
false
DataValueDescriptor.getStream()
,
StringDataValue.getStreamWithDescriptor()
public java.lang.String getTraceString() throws StandardException
getString
.getTraceString
in interface DataValueDescriptor
StandardException
- if getting the data value fails.DataValueDescriptor.getString()
public DataValueDescriptor recycle()
recycle
in interface DataValueDescriptor
public 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 DataValueDescriptor
in
- 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 DataValueDescriptor
public final BooleanDataValue isNotNull()
isNotNull
in interface DataValueDescriptor
public void setValue(java.sql.Time theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Time value to set this DataValueDescriptor toStandardException
public void setValue(java.sql.Time theValue, java.util.Calendar cal) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Time value to set this DataValueDescriptor tocal
- The time zone from the calendar is used to construct the database time valueStandardException
public void setValue(java.sql.Timestamp theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Timestamp value to set this DataValueDescriptor toStandardException
public void setValue(java.sql.Timestamp theValue, java.util.Calendar cal) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Timestamp value to set this DataValueDescriptor tocal
- The time zone from the calendar is used to construct the database timestamp valueStandardException
public void setValue(java.sql.Date theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Date value to set this DataValueDescriptor toStandardException
public void setValue(java.sql.Date theValue, java.util.Calendar cal) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Date value to set this DataValueDescriptor tocal
- The time zone from the calendar is used to construct the database date valueStandardException
public void setValue(java.lang.Object theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Object value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(java.lang.String theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The BigDecimal value to set this DataValueDescriptor toStandardException
public void setValue(java.sql.Blob theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Blob value to set this DataValueDescriptor toStandardException
public void setValue(java.sql.Clob theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The Clob value to set this DataValueDescriptor toStandardException
public void setValue(int theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(double theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(float theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(short theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(long theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(byte theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The value to set this DataValueDescriptor toStandardException
- Thrown on errorpublic void setValue(boolean theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- Contains the boolean value to set this toStandardException
public void setValue(byte[] theValue) throws StandardException
setValue
in interface DataValueDescriptor
theValue
- The byte value to set this DataValueDescriptor toStandardException
public void setBigDecimal(java.math.BigDecimal bigDecimal) throws StandardException
setBigDecimal
in interface DataValueDescriptor
bigDecimal
- required to be a BigDecimal or null.StandardException
public final void setValue(DataValueDescriptor dvd) throws StandardException
DataValueDescriptor
setValue
in interface DataValueDescriptor
dvd
- The Date value to set this DataValueDescriptor toStandardException
protected void setFrom(DataValueDescriptor dvd) throws StandardException
dvd
- The DataValueDescriptor that holds the value to
which we want to set this DataValueDescriptor's value.StandardException
public void setToNull()
DataValueDescriptor
setToNull
in interface DataValueDescriptor
DataValueDescriptor.setToNull()
public void setObjectForCast(java.lang.Object theValue, boolean instanceOfResultType, java.lang.String resultTypeClassName) throws StandardException
DataValueDescriptor
setObjectForCast
in interface DataValueDescriptor
theValue
- 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
StandardException
java.lang.String getTypeName(java.lang.String className)
className
- public java.lang.Object getObject() throws StandardException
getObject
in interface DataValueDescriptor
StandardException
- Thrown on errorvoid genericSetObject(java.lang.Object theValue) throws StandardException
StandardException
public 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 DataValueDescriptor
public void throwLangSetMismatch(java.lang.Object value) throws StandardException
StandardException
void throwLangSetMismatch(java.lang.String argTypeName) throws StandardException
StandardException
public void setInto(java.sql.PreparedStatement ps, int position) throws java.sql.SQLException, StandardException
DataValueDescriptor
setInto
in interface DataValueDescriptor
java.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 DataValueDescriptor
java.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 DataValueDescriptor
desiredType
- The type to normalize the source column tosource
- The value to normalizeStandardException
- Thrown normalization error.public int typePrecedence()
typePrecedence
in interface DataValueDescriptor
public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
equals
in interface DataValueDescriptor
left
- 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 DataValueDescriptor
left
- 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 DataValueDescriptor
left
- 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 DataValueDescriptor
left
- 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 DataValueDescriptor
left
- 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 DataValueDescriptor
left
- 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
DataValueDescriptor
compare
in interface DataValueDescriptor
op
- 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 DataValueDescriptor
op
- 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 DataValueDescriptor
other
- 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.Comparable
Comparable.compareTo(T)
protected static int flip(int operator)
operator
- The operator to flip.public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue) throws StandardException
DataValueDescriptor
coalesce
in interface DataValueDescriptor
argumentsList
- 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
DataValueDescriptor
in
in interface DataValueDescriptor
left
- 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.Object
public void setValue(java.io.InputStream theStream, int valueLength) throws StandardException
DataValueDescriptor
The 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 DataValueDescriptor
theStream
- 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 unknownStandardException
public void checkHostVariable(int declaredLength) throws StandardException
checkHostVariable
in interface DataValueDescriptor
StandardException
- Variable is too big.protected final StandardException dataTypeConversion(java.lang.String targetType)
protected final StandardException outOfRange()
protected final StandardException invalidFormat()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.