Interface DataValueDescriptor
-
- All Superinterfaces:
java.io.Externalizable,Formatable,Orderable,java.io.Serializable,Storable,TypedFormat
- All Known Subinterfaces:
BitDataValue,BooleanDataValue,ConcatableDataValue,Conglomerate,DateTimeDataValue,NumberDataValue,RefDataValue,RowLocation,StringDataValue,UserDataValue,XMLDataValue
- All Known Implementing Classes:
B2I,B2I_10_3,B2I_v10_2,BTree,CollatorSQLChar,CollatorSQLClob,CollatorSQLLongvarchar,CollatorSQLVarchar,DataType,GenericConglomerate,Heap,Heap_v10_2,HeapRowLocation,NumberDataType,SQLBinary,SQLBit,SQLBlob,SQLBoolean,SQLChar,SQLClob,SQLDate,SQLDecimal,SQLDouble,SQLInteger,SQLLongint,SQLLongVarbit,SQLLongvarchar,SQLReal,SQLRef,SQLSmallint,SQLTime,SQLTimestamp,SQLTinyint,SQLVarbit,SQLVarchar,StorableFormatId,UserType,UTF,XML
public interface DataValueDescriptor extends Storable, Orderable
The DataValueDescriptor interface provides methods to get the data from a column returned by a statement.This interface matches the getXXX methods on java.sql.ResultSet. This means everyone satisfies getString and getObject; all of the numeric types, within the limits of representation, satisfy all of the numeric getXXX methods; all of the character types satisfy all of the getXXX methods except getBytes and getBinaryStream; all of the binary types satisfy getBytes and all of the getXXXStream methods; Date satisfies getDate and getTimestamp; Time satisfies getTime; and Timestamp satisfies all of the date/time getXXX methods. The "preferred" method (one that will always work, I presume) is the one that matches the type most closely. See the comments below for "preferences". See the JDBC guide for details.
This interface does not include the getXXXStream methods.
The preferred methods for JDBC are:
CHAR and VARCHAR - getString()
BIT - getBoolean()
TINYINT - getByte()
SMALLINT - getShort()
INTEGER - getInt()
BIGINT - getLong()
REAL - getFloat()
FLOAT and DOUBLE - getDouble()
DECIMAL and NUMERIC - getBigDecimal()
BINARY and VARBINARY - getBytes()
DATE - getDate()
TIME - getTime()
TIMESTAMP - getTimestamp()
No JDBC type corresponds to getObject(). Use this for user-defined types or to get the JDBC types as java Objects. All primitive types will be wrapped in their corresponding Object type, i.e. int will be wrapped in an Integer.
getStream()
-
-
Field Summary
Fields Modifier and Type Field Description static intUNKNOWN_LOGICAL_LENGTHConstant indicating that the logical length of a value (i.e. chars for string types or bytes for binary types) is unknown.-
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
-
-
Method Summary
All Methods Instance Methods Abstract 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()Get a shallow copy of thiscodeDataValueDescriptor(DVD).DataValueDescriptorcloneValue(boolean forceMaterialization)Clone this DataValueDescriptor.DataValueDescriptorcoalesce(DataValueDescriptor[] list, 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)Compare this Orderable with a given Orderable for the purpose of index positioning.intcompare(DataValueDescriptor other, boolean nullsOrderedLow)Compare this Orderable with another, with configurable null ordering.BooleanDataValueequals(DataValueDescriptor left, DataValueDescriptor right)The SQL language = operator.intestimateMemoryUsage()Estimate the memory usage in bytes of the data value and the overhead of the class.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 array.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 an int.intgetLength()Gets the length of the data value.longgetLong()Gets the value in the data value descriptor as a long.DataValueDescriptorgetNewNull()Get a new null value of the same type as this data value.java.lang.ObjectgetObject()Gets the value in the data value descriptor as a Java Object.shortgetShort()Gets the value in the data value descriptor as a short.java.io.InputStreamgetStream()Gets the value in the data value descriptor as a stream of bytes.java.lang.StringgetString()Gets the value in the data value descriptor as a String.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 value descriptor as a trace string.java.lang.StringgetTypeName()Get the SQL name of the datatypeBooleanDataValuegreaterOrEquals(DataValueDescriptor left, DataValueDescriptor right)The SQL language >= operator.BooleanDataValuegreaterThan(DataValueDescriptor left, DataValueDescriptor right)The SQL language > operator.booleanhasStream()Tells if this data value is, or will be, represented by a stream.BooleanDataValuein(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList)The SQL language IN operator.BooleanDataValueisNotNull()The SQL "IS NOT NULL" operator.BooleanDataValueisNullOp()The SQL "IS NULL" operator.BooleanDataValuelessOrEquals(DataValueDescriptor left, DataValueDescriptor right)The SQL language <= operator.BooleanDataValuelessThan(DataValueDescriptor left, DataValueDescriptor right)The SQL language < operator.voidnormalize(DataTypeDescriptor dtd, DataValueDescriptor source)Normalize the source value to this type described by this class and the passed in DataTypeDescriptor.BooleanDataValuenotEquals(DataValueDescriptor left, DataValueDescriptor right)The SQL language <> operator.voidreadExternalFromArray(ArrayInputStream ais)Read the DataValueDescriptor from the stream.DataValueDescriptorrecycle()Recycle this DataValueDescriptor if possible.voidsetBigDecimal(java.math.BigDecimal bigDecimal)Set this value from an application supplied java.math.BigDecimal.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.voidsetObjectForCast(java.lang.Object value, 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 valuevoidsetValue(byte[] theValue)Set the value of this DataValueDescriptor.voidsetValue(double theValue)Set the value of this DataValueDescriptor to the given double valuevoidsetValue(float theValue)Set the value of this DataValueDescriptor to the given double valuevoidsetValue(int theValue)Set the value of this DataValueDescriptor to the given int valuevoidsetValue(long theValue)Set the value of this DataValueDescriptor to the given long valuevoidsetValue(short theValue)Set the value of this DataValueDescriptor to the given short valuevoidsetValue(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 to the given Object valuevoidsetValue(java.lang.String theValue)Set the value of this DataValueDescriptor.voidsetValue(java.sql.Blob theValue)Set the value of this DataValueDescriptor from a Blob.voidsetValue(java.sql.Clob theValue)Set the value of this DataValueDescriptor from a Clob.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 theValue)Set the value of this DataValueDescriptor from another.voidsetValueFromResultSet(java.sql.ResultSet resultSet, int colNumber, boolean isNullable)Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet.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 interface org.apache.derby.iapi.services.io.Storable
isNull, restoreToNull
-
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
-
-
-
-
Field Detail
-
UNKNOWN_LOGICAL_LENGTH
static final int UNKNOWN_LOGICAL_LENGTH
Constant indicating that the logical length of a value (i.e. chars for string types or bytes for binary types) is unknown.- See Also:
- Constant Field Values
-
-
Method Detail
-
getLength
int getLength() throws StandardExceptionGets the length of the data value. The meaning of this is implementation-dependent. For string types, it is the number of characters in the string. For numeric types, it is the number of bytes used to store the number. This is the actual length of this value, not the length of the type it was defined as. For example, a VARCHAR value may be shorter than the declared VARCHAR (maximum) length.- Returns:
- The length of the data value
- Throws:
StandardException- On error
-
getString
java.lang.String getString() throws StandardExceptionGets the value in the data value descriptor as a String. Throws an exception if the data value is not a string.- Returns:
- The data value as a String.
- Throws:
StandardException- Thrown on error
-
getTraceString
java.lang.String getTraceString() throws StandardExceptionGets the value in the data value descriptor as a trace string. If the value itself is not suitable for tracing purposes, a more suitable representation is returned. For instance, data values represented as streams are not materialized. Instead, information about the associated stream is given.- Throws:
StandardException
-
getBoolean
boolean getBoolean() throws StandardExceptionGets the value in the data value descriptor as a boolean. Throws an exception if the data value is not a boolean. For DataValueDescriptor, this is the preferred interface for BIT, but for this no-casting interface, it isn't, because BIT is stored internally as a Bit, not as a Boolean.- Returns:
- The data value as a boolean.
- Throws:
StandardException- Thrown on error
-
getByte
byte getByte() throws StandardExceptionGets the value in the data value descriptor as a byte. Throws an exception if the data value is not a byte.- Returns:
- The data value as a byte.
- Throws:
StandardException- Thrown on error
-
getShort
short getShort() throws StandardExceptionGets the value in the data value descriptor as a short. Throws an exception if the data value is not a short.- Returns:
- The data value as a short.
- Throws:
StandardException- Thrown on error
-
getInt
int getInt() throws StandardExceptionGets the value in the data value descriptor as an int. Throws an exception if the data value is not an int.- Returns:
- The data value as a int.
- Throws:
StandardException- Thrown on error
-
getLong
long getLong() throws StandardExceptionGets the value in the data value descriptor as a long. Throws an exception if the data value is not a long.- Returns:
- The data value as a long.
- Throws:
StandardException- Thrown on error
-
getFloat
float getFloat() throws StandardExceptionGets the value in the data value descriptor as a float. Throws an exception if the data value is not a float.- Returns:
- The data value as a float.
- Throws:
StandardException- Thrown on error
-
getDouble
double getDouble() throws StandardExceptionGets the value in the data value descriptor as a double. Throws an exception if the data value is not a double.- Returns:
- The data value as a double.
- Throws:
StandardException- Thrown on error
-
typeToBigDecimal
int typeToBigDecimal() throws StandardExceptionHow should this value be obtained so that it can be converted to a BigDecimal representation.- 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
byte[] getBytes() throws StandardExceptionGets the value in the data value descriptor as a byte array. Throws an exception if the data value is not a byte array.- Returns:
- The data value as a byte[].
- Throws:
StandardException- Thrown on error
-
getDate
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 a Date.- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Date.
- Throws:
StandardException- Thrown on error
-
getTime
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 a Time.- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Time.
- Throws:
StandardException- Thrown on error
-
getTimestamp
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 a Timestamp.- Parameters:
cal- calendar for object creation- Returns:
- The data value as a java.sql.Timestamp.
- Throws:
StandardException- Thrown on error
-
getObject
java.lang.Object getObject() throws StandardExceptionGets the value in the data value descriptor as a Java Object. The type of the Object will be the Java object type corresponding to the data value's SQL type. JDBC defines a mapping between Java object types and SQL types - we will allow that to be extended through user type definitions. Throws an exception if the data value is not an object (yeah, right).- Returns:
- The data value as an Object.
- Throws:
StandardException- Thrown on error
-
getStream
java.io.InputStream getStream() throws StandardExceptionGets the value in the data value descriptor as a stream of bytes.Only data types that implement
StreamStorablewill have stream states, and the methodhasStreamshould be called to determine if the value in question is, or will be, represented by a stream.- Returns:
- The stream state of the data value.
- Throws:
StandardException- Throws an exception if the data value cannot be received as a stream.- See Also:
hasStream(),StringDataValue.getStreamWithDescriptor()
-
hasStream
boolean hasStream()
Tells if this data value is, or will be, represented by a stream.This method should be called to determine if the methods
getStreamorDataValueDescriptor.getStreamWithDescriptorcan be invoked.- Returns:
trueif the value will be a stream,falseotherwise.- See Also:
getStream(),StringDataValue.getStreamWithDescriptor()
-
cloneHolder
DataValueDescriptor cloneHolder()
Get a shallow copy of thiscodeDataValueDescriptor(DVD).The primary use of this method is to avoid materializing streams for data types like BLOB and CLOB.
In general the orginal DVD should be recycled or discarded when this method is invoked to ensure that changes to the original DVD don't affect the clone (or the other way around). Note that it is not safe to assume that a number of these clones can be used for read-only access to the same value.
Implementation note: The reason why the clones can't be guaranteed to work as "read clones" is that if the value is represented as a stream, the state of the stream will change on read operations. Since all the clones share the same stream, this may lead to wrong results, data corruption or crashes.
- Returns:
- A clone of this descriptor, which shares the internal state.
-
cloneValue
DataValueDescriptor cloneValue(boolean forceMaterialization)
Clone this DataValueDescriptor. Results in a new object that has the same value as this but can be modified independently.Even though the objects can be modified independently regardless of the value of
forceMaterialization, both the clone and the original may be dependent on the store state ifforceMaterializationis set tofalse. An example is if you need to access the value you just read usingcloneValueafter the current transaction has ended, or after the source result set has been closed.- Parameters:
forceMaterialization- any streams representing the data value will be materialized iftrue, the data value will be kept as a stream if possible iffalse- Returns:
- A clone of the
DataValueDescriptorwith the same initial value as this.
-
recycle
DataValueDescriptor recycle()
Recycle this DataValueDescriptor if possible. Create and return a new object if it cannot be recycled.- Returns:
- this object with the value set to null, or a new DataValueDescriptor of the same type as this
-
getNewNull
DataValueDescriptor getNewNull()
Get a new null value of the same type as this data value.
-
setValueFromResultSet
void setValueFromResultSet(java.sql.ResultSet resultSet, int colNumber, boolean isNullable) throws StandardException, java.sql.SQLExceptionSet the value based on the value for the specified DataValueDescriptor from the specified ResultSet.- Parameters:
resultSet- The specified ResultSet.colNumber- The 1-based column # into the resultSet.isNullable- Whether or not the column is nullable (No need to call wasNull() if not)- Throws:
StandardException- Thrown on errorjava.sql.SQLException- Error accessing the result set
-
setInto
void setInto(java.sql.PreparedStatement ps, int position) throws java.sql.SQLException, StandardExceptionSet this value into a PreparedStatement. This method must handle setting NULL into the PreparedStatement.- Throws:
java.sql.SQLException- thrown by the PreparedStatement objectStandardException- thrown by me accessing my value.
-
setInto
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.- Throws:
java.sql.SQLException- thrown by the ResultSet objectStandardException- thrown by me accessing my value.
-
setValue
void setValue(int theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given int value- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
void setValue(double theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given double value- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
void setValue(float theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given double value- Parameters:
theValue- A Double containing the value to set this DataValueDescriptor to. Null means set the value to SQL null.- Throws:
StandardException- Thrown on error
-
setValue
void setValue(short theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given short value- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
void setValue(long theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given long value- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
void setValue(byte theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given byte value- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
void setValue(boolean theValue) throws StandardExceptionSet the value.- Parameters:
theValue- Contains the boolean value to set this to- Throws:
StandardException
-
setValue
void setValue(java.lang.Object theValue) throws StandardExceptionSet the value of this DataValueDescriptor to the given Object value- Parameters:
theValue- The value to set this DataValueDescriptor to- Throws:
StandardException- Thrown on error
-
setValue
void setValue(byte[] theValue) throws StandardExceptionSet the value of this DataValueDescriptor.- Parameters:
theValue- The byte value to set this DataValueDescriptor to- Throws:
StandardException
-
setBigDecimal
void setBigDecimal(java.math.BigDecimal bigDecimal) throws StandardExceptionSet this value from an application supplied java.math.BigDecimal. This is to support the PreparedStatement.setBigDecimal method and similar JDBC methods that allow an application to pass in a BigDecimal to any SQL type.- Parameters:
bigDecimal- required to be a BigDecimal or null.- Throws:
StandardException
-
setValue
void setValue(java.lang.String theValue) throws StandardExceptionSet the value of this DataValueDescriptor.- Parameters:
theValue- The String value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
void setValue(java.sql.Blob theValue) throws StandardExceptionSet the value of this DataValueDescriptor from a Blob.- Parameters:
theValue- The Blob value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
void setValue(java.sql.Clob theValue) throws StandardExceptionSet the value of this DataValueDescriptor from a Clob.- Parameters:
theValue- The Clob value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
void setValue(java.sql.Time theValue) throws StandardExceptionSet the value of this DataValueDescriptor.- Parameters:
theValue- The Time value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
void setValue(java.sql.Time theValue, java.util.Calendar cal) throws StandardExceptionSet the value of this DataValueDescriptor.- 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
void setValue(java.sql.Timestamp theValue) throws StandardExceptionSet the value of this DataValueDescriptor.- Parameters:
theValue- The Timestamp value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
void setValue(java.sql.Timestamp theValue, java.util.Calendar cal) throws StandardExceptionSet the value of this DataValueDescriptor.- 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
void setValue(java.sql.Date theValue) throws StandardExceptionSet the value of this DataValueDescriptor.- Parameters:
theValue- The Date value to set this DataValueDescriptor to- Throws:
StandardException
-
setValue
void setValue(java.sql.Date theValue, java.util.Calendar cal) throws StandardExceptionSet the value of this DataValueDescriptor.- 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
void setValue(DataValueDescriptor theValue) throws StandardException
Set the value of this DataValueDescriptor from another.- Parameters:
theValue- The Date value to set this DataValueDescriptor to- Throws:
StandardException
-
setToNull
void setToNull()
Set the value to SQL null.
-
normalize
void normalize(DataTypeDescriptor dtd, DataValueDescriptor source) throws StandardException
Normalize the source value to this type described by this class and the passed in DataTypeDescriptor. The type of the DataTypeDescriptor must match this class.- Throws:
StandardException
-
isNullOp
BooleanDataValue isNullOp()
The SQL "IS NULL" operator. Returns true if this value is null. *- Returns:
- True if this value is null.
-
isNotNull
BooleanDataValue isNotNull()
The SQL "IS NOT NULL" operator. Returns true if this value is not null.- Returns:
- True if this value is not null.
-
getTypeName
java.lang.String getTypeName()
Get the SQL name of the datatype- Returns:
- The SQL name of the datatype
-
setObjectForCast
void setObjectForCast(java.lang.Object value, boolean instanceOfResultType, java.lang.String resultTypeClassName) throws StandardExceptionSet 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.- Parameters:
value- 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 error
-
readExternalFromArray
void readExternalFromArray(ArrayInputStream ais) throws java.io.IOException, java.lang.ClassNotFoundException
Read the DataValueDescriptor from the stream.Initialize the data value by reading it's values from the ArrayInputStream. This interface is provided as a way to achieve possible performance enhancement when reading an array can be optimized over reading from a generic stream from readExternal().
- Parameters:
ais- 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.
-
typePrecedence
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.- Returns:
- The precedence of this type.
-
equals
BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The SQL language = operator. This method is called from the language module. The storage module uses the compare method in Orderable.- Parameters:
left- The value on the left side of the operatorright- The value on the right side of the operator- Returns:
- A BooleanDataValue telling the result of the comparison
- Throws:
StandardException- Thrown on error
-
notEquals
BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The SQL language <> operator. This method is called from the language module. The storage module uses the compare method in Orderable.- Parameters:
left- The value on the left side of the operatorright- The value on the right side of the operator- Returns:
- A BooleanDataValue telling the result of the comparison
- Throws:
StandardException- Thrown on error
-
lessThan
BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The SQL language < operator. This method is called from the language module. The storage module uses the compare method in Orderable.- Parameters:
left- The value on the left side of the operatorright- The value on the right side of the operator- Returns:
- A BooleanDataValue telling the result of the comparison
- Throws:
StandardException- Thrown on error
-
greaterThan
BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The SQL language > operator. This method is called from the language module. The storage module uses the compare method in Orderable.- Parameters:
left- The value on the left side of the operatorright- The value on the right side of the operator- Returns:
- A BooleanDataValue telling the result of the comparison
- Throws:
StandardException- Thrown on error
-
lessOrEquals
BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The SQL language <= operator. This method is called from the language module. The storage module uses the compare method in Orderable.- Parameters:
left- The value on the left side of the operatorright- The value on the right side of the operator- Returns:
- A BooleanDataValue telling the result of the comparison
- Throws:
StandardException- Thrown on error
-
greaterOrEquals
BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException
The SQL language >= operator. This method is called from the language module. The storage module uses the compare method in Orderable.- Parameters:
left- The value on the left side of the operatorright- The value on the right side of the operator- Returns:
- A BooleanDataValue telling the result of the comparison
- Throws:
StandardException- Thrown on error
-
coalesce
DataValueDescriptor coalesce(DataValueDescriptor[] list, DataValueDescriptor returnValue) throws StandardException
The SQL language COALESCE/VALUE function. This method is called from the language module.- Parameters:
list- 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
-
in
BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException
The 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.- 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
-
compare
int compare(DataValueDescriptor other) throws StandardException
Compare this Orderable with a given Orderable for the purpose of index positioning. This method treats nulls as ordered values - that is, it treats SQL null as equal to null and greater than all other values.- Parameters:
other- The Orderable to compare this one to.- 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
-
compare
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.- 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
-
compare
boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardExceptionCompare 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.- 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
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- 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
-
setValue
void setValue(java.io.InputStream theStream, int valueLength) throws StandardExceptionSet 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.- 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
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.- Throws:
StandardException- Variable is too big.
-
estimateMemoryUsage
int estimateMemoryUsage()
Estimate the memory usage in bytes of the data value and the overhead of the class.- Returns:
- the estimated memory usage
-
-