Class DataType
- java.lang.Object
-
- org.apache.derby.iapi.types.DataType
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Comparable,Formatable,Storable,TypedFormat,DataValueDescriptor,Orderable
- Direct Known Subclasses:
GenericConglomerate,HeapRowLocation,NumberDataType,SQLBinary,SQLBoolean,SQLChar,SQLDate,SQLRef,SQLTime,SQLTimestamp,StorableFormatId,UserType,XML
public abstract class DataType extends java.lang.Object implements DataValueDescriptor, java.lang.Comparable
DataType is the superclass for all data types. It provides common behavior for datavalue descriptors -- it throws exceptions for all of the get* and setvalue(*) methods of DataValueDescriptor; the subtypes need only override the one for the type they represent and all types it can also be returned as, and the methods dealing with nulls. Since all types satisfy getString DataType does not define that interfaces of DataValueDescriptor. DataType is a little glue for columns to hold values with.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
UNKNOWN_LOGICAL_LENGTH
-
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
Constructors Constructor Description DataType()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckHostVariable(int declaredLength)Check the value to seem if it conforms to the restrictions imposed by DB2/JCC on host variables for this type.DataValueDescriptorcloneHolder()Default implementation of shallow cloning, which forwards to the deep clone method.DataValueDescriptorcoalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue)The SQL language COALESCE/VALUE function.booleancompare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV)Compare this Orderable with a given Orderable for the purpose of qualification and sorting.booleancompare(int op, DataValueDescriptor other, boolean orderedNulls, boolean nullsOrderedLow, boolean unknownRV)Compare this Orderable with another, with configurable null ordering.intcompare(DataValueDescriptor other, boolean nullsOrderedLow)Compare this Orderable with another, with configurable null ordering.intcompareTo(java.lang.Object otherDVD)Wrapper method for the "compare(DataValueDescriptor)" method of this class.protected StandardExceptiondataTypeConversion(java.lang.String targetType)Return an conversion exception from this type to another.booleanequals(java.lang.Object other)BooleanDataValueequals(DataValueDescriptor left, DataValueDescriptor right)The = operator as called from the language module, as opposed to the storage module.protected static intflip(int operator)Flip the operator used in a comparison (< -> >).(package private) voidgenericSetObject(java.lang.Object theValue)booleangetBoolean()Gets the value in the data value descriptor as a boolean.bytegetByte()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.DategetDate(java.util.Calendar cal)Gets the value in the data value descriptor as a java.sql.Date.doublegetDouble()Gets the value in the data value descriptor as a double.floatgetFloat()Gets the value in the data value descriptor as a float.intgetInt()Gets the value in the data value descriptor as a int.longgetLong()Gets the value in the data value descriptor as a long.java.lang.ObjectgetObject()Gets the value in the data value descriptor as a int.shortgetShort()Gets the value in the data value descriptor as a short.java.io.InputStreamgetStream()Gets the value in the data stream descriptor as an InputStream.java.sql.TimegetTime(java.util.Calendar cal)Gets the value in the data value descriptor as a java.sql.Time.java.sql.TimestampgetTimestamp(java.util.Calendar cal)Gets the value in the data value descriptor as a java.sql.Timestamp.java.lang.StringgetTraceString()Gets the value in the data stream descriptor as a trace string.(package private) java.lang.StringgetTypeName(java.lang.String className)Get the type name of this value, possibly overriding with the passed in class name (for user/java types).BooleanDataValuegreaterOrEquals(DataValueDescriptor left, DataValueDescriptor right)The >= operator as called from the language module, as opposed to the storage module.BooleanDataValuegreaterThan(DataValueDescriptor left, DataValueDescriptor right)The > operator as called from the language module, as opposed to the storage module.booleanhasStream()Tells that the value isn't represented as a stream, which is true for most Derby data types.BooleanDataValuein(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList)The SQL language IN operator.protected StandardExceptioninvalidFormat()Return an out of range exception for this type.BooleanDataValueisNotNull()The is not null operator as called from the language module, as opposed to the storage module.BooleanDataValueisNullOp()The is null operator as called from the language module, as opposed to the storage module.BooleanDataValuelessOrEquals(DataValueDescriptor left, DataValueDescriptor right)The <= operator as called from the language module, as opposed to the storage module.BooleanDataValuelessThan(DataValueDescriptor left, DataValueDescriptor right)The < operator as called from the language module, as opposed to the storage module.voidnormalize(DataTypeDescriptor desiredType, DataValueDescriptor source)Default normalization method.BooleanDataValuenotEquals(DataValueDescriptor left, DataValueDescriptor right)The <> operator as called from the language module, as opposed to the storage module.protected StandardExceptionoutOfRange()Return an out of range exception for this type.voidreadExternalFromArray(ArrayInputStream in)Read the DataValueDescriptor from the stream.DataValueDescriptorrecycle()Recycle this DataType object.voidsetBigDecimal(java.math.BigDecimal bigDecimal)Only to be called when the application sets a value using BigDecimalprotected voidsetFrom(DataValueDescriptor dvd)Set the value of this DataValueDescriptor based on the value of the specified DataValueDescriptor.voidsetInto(java.sql.PreparedStatement ps, int position)Set this value into a PreparedStatement.voidsetInto(java.sql.ResultSet rs, int position)Set this value into a ResultSet for a subsequent ResultSet.insertRow or ResultSet.updateRow.(package private) voidsetObject(java.lang.Object theValue)Set the value from an non-null object.voidsetObjectForCast(java.lang.Object theValue, boolean instanceOfResultType, java.lang.String resultTypeClassName)Set this value from an Object.voidsetToNull()Set the value to SQL null.voidsetValue(boolean theValue)Set the value.voidsetValue(byte theValue)Set the value of this DataValueDescriptor to the given byte value At DataType level just throws an error lower classes will overridevoidsetValue(byte[] theValue)Set the value of this DataValueDescriptor.voidsetValue(double theValue)Set the value of this DataValueDescriptor to the given double value At DataType level just throws an error lower classes will overridevoidsetValue(float theValue)Set the value of this DataValueDescriptor to the given float value At DataType level just throws an error lower classes will overridevoidsetValue(int theValue)Set the value of this DataValueDescriptor to the given int value At DataType level just throws an error lower classes will overridevoidsetValue(long theValue)Set the value of this DataValueDescriptor to the given long value At DataType level just throws an error lower classes will overridevoidsetValue(short theValue)Set the value of this DataValueDescriptor to the given short value At DataType level just throws an error lower classes will overridevoidsetValue(java.io.InputStream theStream, int valueLength)Set the value to be the contents of the stream.voidsetValue(java.lang.Object theValue)Set the value of this DataValueDescriptor.voidsetValue(java.lang.String theValue)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Blob theValue)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Clob theValue)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Date theValue)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Date theValue, java.util.Calendar cal)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Time theValue)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Time theValue, java.util.Calendar cal)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Timestamp theValue)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Timestamp theValue, java.util.Calendar cal)Set the value of this DataValueDescriptor.voidsetValue(DataValueDescriptor dvd)Set the value of this DataValueDescriptor from another.voidthrowLangSetMismatch(java.lang.Object value)(package private) voidthrowLangSetMismatch(java.lang.String argTypeName)inttypePrecedence()Each built-in type in JSQL has a precedence.inttypeToBigDecimal()How should this value be obtained so that it can be converted to a BigDecimal representation.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
cloneValue, compare, estimateMemoryUsage, getLength, getNewNull, getString, getTypeName, setValueFromResultSet
-
Methods inherited from interface org.apache.derby.iapi.services.io.Storable
isNull, restoreToNull
-
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
-
-
-
-
Method Detail
-
getBoolean
public boolean getBoolean() throws StandardExceptionGets the value in the data value descriptor as a boolean. Throws an exception if the data value is not receivable as a boolean.- Specified by:
getBooleanin interfaceDataValueDescriptor- Returns:
- The data value as a boolean.
- Throws:
StandardException- Thrown on error
-
getByte
public byte getByte() throws StandardExceptionGets the value in the data value descriptor as a byte. Throws an exception if the data value is not receivable as a byte.- Specified by:
getBytein interfaceDataValueDescriptor- Returns:
- The data value as a byte.
- Throws:
StandardException- Thrown on error
-
getShort
public short getShort() throws StandardExceptionGets the value in the data value descriptor as a short. Throws an exception if the data value is not receivable as a short.- Specified by:
getShortin interfaceDataValueDescriptor- Returns:
- The data value as a short.
- Throws:
StandardException- Thrown on error
-
getInt
public int getInt() throws StandardExceptionGets the value in the data value descriptor as a int. Throws an exception if the data value is not receivable as a int.- Specified by:
getIntin interfaceDataValueDescriptor- Returns:
- The data value as a int.
- Throws:
StandardException- Thrown on error
-
getLong
public long getLong() throws StandardExceptionGets the value in the data value descriptor as a long. Throws an exception if the data value is not receivable as a long.- Specified by:
getLongin interfaceDataValueDescriptor- Returns:
- The data value as a long.
- Throws:
StandardException- Thrown on error
-
getFloat
public float getFloat() throws StandardExceptionGets the value in the data value descriptor as a float. Throws an exception if the data value is not receivable as a float.- Specified by:
getFloatin interfaceDataValueDescriptor- Returns:
- The data value as a float.
- Throws:
StandardException- Thrown on error
-
getDouble
public double getDouble() throws StandardExceptionGets the value in the data value descriptor as a double. Throws an exception if the data value is not receivable as a double.- Specified by:
getDoublein interfaceDataValueDescriptor- Returns:
- The data value as a double.
- Throws:
StandardException- Thrown on error
-
typeToBigDecimal
public int typeToBigDecimal() throws StandardExceptionDescription copied from interface:DataValueDescriptorHow should this value be obtained so that it can be converted to a BigDecimal representation.- Specified by:
typeToBigDecimalin interfaceDataValueDescriptor- Returns:
- Types.CHAR for String conversion through getString Types.DECIMAL for BigDecimal through getObject or Types.BIGINT for long conversion through getLong
- Throws:
StandardException- Conversion is not possible
-
getBytes
public byte[] getBytes() throws StandardExceptionGets the value in the data value descriptor as a byte[]. Throws an exception if the data value is not receivable as a Binary or Varbinary.- Specified by:
getBytesin interfaceDataValueDescriptor- Returns:
- The Binary value as a byte[].
- Throws:
StandardException- Thrown on error
-
getDate
public java.sql.Date getDate(java.util.Calendar cal) throws StandardExceptionGets the value in the data value descriptor as a java.sql.Date. Throws an exception if the data value is not receivable as a Date.- Specified by:
getDatein interfaceDataValueDescriptor- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Date.
- Throws:
StandardException- Thrown on error
-
getTime
public java.sql.Time getTime(java.util.Calendar cal) throws StandardExceptionGets the value in the data value descriptor as a java.sql.Time. Throws an exception if the data value is not receivable as a Time.- Specified by:
getTimein interfaceDataValueDescriptor- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Time.
- Throws:
StandardException- Thrown on error
-
getTimestamp
public java.sql.Timestamp getTimestamp(java.util.Calendar cal) throws StandardExceptionGets the value in the data value descriptor as a java.sql.Timestamp. Throws an exception if the data value is not receivable as a Timestamp.- Specified by:
getTimestampin interfaceDataValueDescriptor- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Timestamp.
- Throws:
StandardException- Thrown on error
-
getStream
public java.io.InputStream getStream() throws StandardExceptionGets the value in the data stream descriptor as an InputStream. Throws an exception if the data value is not receivable as a stream.- Specified by:
getStreamin interfaceDataValueDescriptor- Returns:
- The data value as an InputStream.
- Throws:
StandardException- Thrown on error- See Also:
DataValueDescriptor.hasStream(),StringDataValue.getStreamWithDescriptor()
-
hasStream
public boolean hasStream()
Tells that the value isn't represented as a stream, which is true for most Derby data types.This method will be overridden by types able to use a stream as the source.
- Specified by:
hasStreamin interfaceDataValueDescriptor- Returns:
false- See Also:
DataValueDescriptor.getStream(),StringDataValue.getStreamWithDescriptor()
-
getTraceString
public java.lang.String getTraceString() throws StandardExceptionGets the value in the data stream descriptor as a trace string. This default implementation simply forwards the call togetString.- Specified by:
getTraceStringin interfaceDataValueDescriptor- Returns:
- The data value in a representation suitable for tracing.
- Throws:
StandardException- if getting the data value fails.- See Also:
DataValueDescriptor.getString()
-
recycle
public DataValueDescriptor recycle()
Recycle this DataType object.- Specified by:
recyclein interfaceDataValueDescriptor- Returns:
- this object with value set to null
-
readExternalFromArray
public void readExternalFromArray(ArrayInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
Read the DataValueDescriptor from the stream. The default implementation callsreadExternal(), which accesses theArrayInputStreamas a generic stream. If sub-classes can implement it more efficiently by accessing the array, they should override this method.- Specified by:
readExternalFromArrayin interfaceDataValueDescriptor- Parameters:
in- The array stream positioned at the beginning of the byte stream to read from.- Throws:
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.- See Also:
DataValueDescriptor.readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream),Externalizable.readExternal(java.io.ObjectInput)
-
isNullOp
public final BooleanDataValue isNullOp()
The is null operator as called from the language module, as opposed to the storage module.- Specified by:
isNullOpin interfaceDataValueDescriptor- Returns:
- A SQL boolean value telling whether the operand is null
-
isNotNull
public final BooleanDataValue isNotNull()
The is not null operator as called from the language module, as opposed to the storage module.- Specified by:
isNotNullin interfaceDataValueDescriptor- Returns:
- A SQL boolean value telling whether the operand is not null
-
setValue
public void setValue(java.sql.Time theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Time value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
public void setValue(java.sql.Time theValue, java.util.Calendar cal) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Time value to set this DataValueDescriptor tocal- The time zone from the calendar is used to construct the database time value- Throws:
StandardException
-
setValue
public void setValue(java.sql.Timestamp theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Timestamp value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
public void setValue(java.sql.Timestamp theValue, java.util.Calendar cal) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Timestamp value to set this DataValueDescriptor tocal- The time zone from the calendar is used to construct the database timestamp value- Throws:
StandardException
-
setValue
public void setValue(java.sql.Date theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Date value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
public void setValue(java.sql.Date theValue, java.util.Calendar cal) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Date value to set this DataValueDescriptor tocal- The time zone from the calendar is used to construct the database date value- Throws:
StandardException
-
setValue
public void setValue(java.lang.Object theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Object value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
public void setValue(java.lang.String theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The BigDecimal value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
public void setValue(java.sql.Blob theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Blob value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
public void setValue(java.sql.Clob theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The Clob value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
public void setValue(int theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given int value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
public void setValue(double theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given double value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
public void setValue(float theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given float value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
public void setValue(short theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given short value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
public void setValue(long theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given long value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
public void setValue(byte theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given byte value At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
public void setValue(boolean theValue) throws StandardExceptionSet the value. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- Contains the boolean value to set this to- Throws:
StandardException
-
setValue
public void setValue(byte[] theValue) throws StandardExceptionSet the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theValue- The byte value to set this DataValueDescriptor to- Throws:
StandardException
-
setBigDecimal
public void setBigDecimal(java.math.BigDecimal bigDecimal) throws StandardExceptionOnly to be called when the application sets a value using BigDecimal- Specified by:
setBigDecimalin interfaceDataValueDescriptor- Parameters:
bigDecimal- required to be a BigDecimal or null.- Throws:
StandardException
-
setValue
public final void setValue(DataValueDescriptor dvd) throws StandardException
Description copied from interface:DataValueDescriptorSet the value of this DataValueDescriptor from another.- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
dvd- The Date value to set this DataValueDescriptor to- Throws:
StandardException
-
setFrom
protected void setFrom(DataValueDescriptor dvd) throws StandardException
Set the value of this DataValueDescriptor based on the value of the specified DataValueDescriptor.- Parameters:
dvd- The DataValueDescriptor that holds the value to which we want to set this DataValueDescriptor's value.- Throws:
StandardException
-
setToNull
public void setToNull()
Description copied from interface:DataValueDescriptorSet the value to SQL null.- Specified by:
setToNullin interfaceDataValueDescriptor- See Also:
DataValueDescriptor.setToNull()
-
setObjectForCast
public void setObjectForCast(java.lang.Object theValue, boolean instanceOfResultType, java.lang.String resultTypeClassName) throws StandardExceptionDescription copied from interface:DataValueDescriptorSet this value from an Object. Used from CAST of a Java type to another type, including SQL types. If the passed instanceOfResultType is false then the object is not an instance of the declared type resultTypeClassName. Usually an exception should be thrown.- Specified by:
setObjectForCastin interfaceDataValueDescriptor- Parameters:
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).- Throws:
StandardException- thrown on failure- See Also:
DataValueDescriptor.setObjectForCast(java.lang.Object, boolean, java.lang.String)
-
setObject
void setObject(java.lang.Object theValue) throws StandardExceptionSet the value from an non-null object. Usually overridden. This implementation throws an exception. The object will have been correctly typed from the call to setObjectForCast.- Throws:
StandardException
-
getTypeName
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).- Parameters:
className-
-
getObject
public java.lang.Object getObject() throws StandardExceptionGets the value in the data value descriptor as a int. Throws an exception if the data value is not receivable as a int.- Specified by:
getObjectin interfaceDataValueDescriptor- Returns:
- The data value as a int.
- Throws:
StandardException- Thrown on error
-
genericSetObject
void genericSetObject(java.lang.Object theValue) throws StandardException- Throws:
StandardException
-
cloneHolder
public DataValueDescriptor cloneHolder()
Default implementation of shallow cloning, which forwards to the deep clone method.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).
- Specified by:
cloneHolderin interfaceDataValueDescriptor- Returns:
- A shallow clone.
-
throwLangSetMismatch
public void throwLangSetMismatch(java.lang.Object value) throws StandardException- Throws:
StandardException
-
throwLangSetMismatch
void throwLangSetMismatch(java.lang.String argTypeName) throws StandardException- Throws:
StandardException
-
setInto
public void setInto(java.sql.PreparedStatement ps, int position) throws java.sql.SQLException, StandardExceptionDescription copied from interface:DataValueDescriptorSet this value into a PreparedStatement. This method must handle setting NULL into the PreparedStatement.- Specified by:
setIntoin interfaceDataValueDescriptor- Throws:
java.sql.SQLException- thrown by the PreparedStatement objectStandardException- thrown by me accessing my value.
-
setInto
public void setInto(java.sql.ResultSet rs, int position) throws java.sql.SQLException, StandardExceptionSet this value into a ResultSet for a subsequent ResultSet.insertRow or ResultSet.updateRow. This method will only be called for non-null values.- Specified by:
setIntoin interfaceDataValueDescriptor- Throws:
java.sql.SQLException- thrown by the ResultSet objectStandardException- thrown by me accessing my value.
-
normalize
public void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source) throws StandardException
Default normalization method. No information needed from DataTypeDescriptor.- Specified by:
normalizein interfaceDataValueDescriptor- Parameters:
desiredType- The type to normalize the source column tosource- The value to normalize- Throws:
StandardException- Thrown normalization error.
-
typePrecedence
public int typePrecedence()
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- Returns:
- The precedence of this type.
-
equals
public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The = operator as called from the language module, as opposed to the storage module. This default implementations uses compare().- Specified by:
equalsin interfaceDataValueDescriptor- Parameters:
left- The value on the left side of the =right- The value on the right side of the =- Returns:
- A SQL boolean value telling whether the two parameters are equal
- Throws:
StandardException- Thrown on error
-
notEquals
public BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The <> operator as called from the language module, as opposed to the storage module. This default implementations uses compare().- Specified by:
notEqualsin interfaceDataValueDescriptor- Parameters:
left- The value on the left side of the <>right- The value on the right side of the <>- Returns:
- A SQL boolean value telling whether the two parameters are not equal
- Throws:
StandardException- Thrown on error
-
lessThan
public BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The < operator as called from the language module, as opposed to the storage module.- Specified by:
lessThanin interfaceDataValueDescriptor- Parameters:
left- The value on the left side of the <right- The value on the right side of the <- Returns:
- A SQL boolean value telling whether the first operand is less than the second operand
- Throws:
StandardException- Thrown on error
-
greaterThan
public BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The > operator as called from the language module, as opposed to the storage module. This default implementations uses compare().- Specified by:
greaterThanin interfaceDataValueDescriptor- Parameters:
left- The value on the left side of the >right- The value on the right side of the >- Returns:
- A SQL boolean value telling whether the first operand is greater than the second operand
- Throws:
StandardException- Thrown on error
-
lessOrEquals
public BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The <= operator as called from the language module, as opposed to the storage module. This default implementations uses compare().- Specified by:
lessOrEqualsin interfaceDataValueDescriptor- Parameters:
left- The value on the left side of the <=right- The value on the right side of the <=- Returns:
- A SQL boolean value telling whether the first operand is less than or equal to the second operand
- Throws:
StandardException- Thrown on error
-
greaterOrEquals
public BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The >= operator as called from the language module, as opposed to the storage module. This default implementation uses compare().- Specified by:
greaterOrEqualsin interfaceDataValueDescriptor- Parameters:
left- The value on the left side of the >=right- The value on the right side of the >=- Returns:
- A SQL boolean value telling whether the first operand is greater than or equal to the second operand
- Throws:
StandardException- Thrown on error
-
compare
public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardExceptionDescription copied from interface:DataValueDescriptorCompare 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- Parameters:
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.- Returns:
- true if the comparison is true (duh!)
- Throws:
StandardException- Thrown on error
-
compare
public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean nullsOrderedLow, boolean unknownRV) throws StandardExceptionCompare this Orderable with another, with configurable null ordering. The caller gets to determine how nulls should be treated - they can either be ordered values or unknown values. The caller also gets to decide, if they are ordered, whether they should be lower than non-NULL values, or higher- Specified by:
comparein interfaceDataValueDescriptor- Parameters:
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.- Returns:
- true if the comparison is true (duh!)
- Throws:
StandardException- Thrown on error
-
compare
public int compare(DataValueDescriptor other, boolean nullsOrderedLow) throws StandardException
Compare this Orderable with another, with configurable null ordering. This method treats nulls as ordered values, but allows the caller to specify whether they should be lower than all non-NULL values, or higher than all non-NULL values.- Specified by:
comparein interfaceDataValueDescriptor- Parameters:
other- The Orderable to compare this one to. % @param nullsOrderedLow True if null should be lower than non-NULL- Returns:
- <0 - this Orderable is less than other. 0 - this Orderable equals other. >0 - this Orderable is greater than other. The code should not explicitly look for -1, or 1.
- Throws:
StandardException- Thrown on error
-
compareTo
public int compareTo(java.lang.Object otherDVD)
Wrapper method for the "compare(DataValueDescriptor)" method of this class. Allows sorting of an array of DataValueDescriptors using the JVMs own sorting algorithm. Currently used for execution-time sorting of IN-list values to allow proper handling (i.e. elimination) of duplicates.- Specified by:
compareToin interfacejava.lang.Comparable- See Also:
Comparable.compareTo(T)
-
flip
protected static int flip(int operator)
Flip the operator used in a comparison (< -> >). This is useful when flipping a comparison due to type precedence.- Parameters:
operator- The operator to flip.- Returns:
- The flipped operator.
-
coalesce
public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue) throws StandardException
Description copied from interface:DataValueDescriptorThe SQL language COALESCE/VALUE function. This method is called from the language module.- Specified by:
coalescein interfaceDataValueDescriptor- Parameters:
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.- Returns:
- A DataValueDescriptor which will be either null or first non-null argument
- Throws:
StandardException- Thrown on error- See Also:
DataValueDescriptor.coalesce(org.apache.derby.iapi.types.DataValueDescriptor[], org.apache.derby.iapi.types.DataValueDescriptor)
-
in
public BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException
Description copied from interface:DataValueDescriptorThe SQL language IN operator. This method is called from the language module. This method allows us to optimize and short circuit the search if the list is ordered.- Specified by:
inin interfaceDataValueDescriptor- Parameters:
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.- Returns:
- A BooleanDataValue telling the result of the comparison
- Throws:
StandardException- Thrown on error- See Also:
DataValueDescriptor.in(org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.types.DataValueDescriptor[], boolean)
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
setValue
public void setValue(java.io.InputStream theStream, int valueLength) throws StandardExceptionDescription copied from interface:DataValueDescriptorSet the value to be the contents of the stream.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_LENGTHshould always leave the system in a functional state. Specifying an incorrect length will cause errors.- Specified by:
setValuein interfaceDataValueDescriptor- Parameters:
theStream- stream of correctly formatted datavalueLength- logical length of the stream's value in units of this type (e.g. chars for string types), orUNKNOWN_LOGICAL_LENGTHif the logical length is unknown- Throws:
StandardException
-
checkHostVariable
public void checkHostVariable(int declaredLength) throws StandardExceptionCheck the value to seem if it conforms to the restrictions imposed by DB2/JCC on host variables for this type.- Specified by:
checkHostVariablein interfaceDataValueDescriptor- Throws:
StandardException- Variable is too big.
-
dataTypeConversion
protected final StandardException dataTypeConversion(java.lang.String targetType)
Return an conversion exception from this type to another.
-
outOfRange
protected final StandardException outOfRange()
Return an out of range exception for this type.
-
invalidFormat
protected final StandardException invalidFormat()
Return an out of range exception for this type.
-
-