| org.apache.derby.iapi.types.DataValueDescriptor
All known Subclasses: org.apache.derby.iapi.types.DataType,
DataValueDescriptor | public interface DataValueDescriptor extends Storable,Orderable(Code) | | The DataValueDescriptor interface provides methods to get the data from
a column returned by a statement. This interface has the same methods
as NoCastDataValueDescriptor - the only reason it exists is for purposes
of internal documentation, to make it clear when the different getXXX
methods throw exceptions for illegal conversions.
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()
author: Jeff Lichtman |
Method Summary | |
public 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. | public DataValueDescriptor | coalesce(DataValueDescriptor[] list, DataValueDescriptor returnValue) The SQL language COALESCE/VALUE function. | int | compare(DataValueDescriptor other) Compare this Orderable with a given Orderable for the purpose of
index positioning. | boolean | compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) Compare this Orderable with a given Orderable for the purpose of
qualification and sorting. | public BooleanDataValue | equals(DataValueDescriptor left, DataValueDescriptor right) The SQL language = operator. | int | estimateMemoryUsage() Estimate the memory usage in bytes of the data value and the overhead of the class. | boolean | getBoolean() Gets the value in the data value descriptor as a boolean. | byte | getByte() Gets the value in the data value descriptor as a byte. | byte[] | getBytes() Gets the value in the data value descriptor as a byte array. | public DataValueDescriptor | getClone() Clone this DataValueDescriptor. | Date | getDate(java.util.Calendar cal) Gets the value in the data value descriptor as a java.sql.Date. | double | getDouble() Gets the value in the data value descriptor as a double. | float | getFloat() Gets the value in the data value descriptor as a float. | int | getInt() Gets the value in the data value descriptor as an int. | int | getLength() Gets the length of the data value. | long | getLong() Gets the value in the data value descriptor as a long. | public DataValueDescriptor | getNewNull() Get a new null value of the same type as this data value. | Object | getObject() Gets the value in the data value descriptor as a Java Object.
The type of the Object will be the Java object type corresponding
to the data value's SQL type. | short | getShort() Gets the value in the data value descriptor as a short. | InputStream | getStream() Gets the value in the data value descriptor as a Java InputStream. | String | getString() Gets the value in the data value descriptor as a String. | Time | getTime(java.util.Calendar cal) Gets the value in the data value descriptor as a java.sql.Time. | Timestamp | getTimestamp(java.util.Calendar cal) Gets the value in the data value descriptor as a java.sql.Timestamp. | String | getTraceString() Gets 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. | public String | getTypeName() | public BooleanDataValue | greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) The SQL language >= operator. | public BooleanDataValue | greaterThan(DataValueDescriptor left, DataValueDescriptor right) The SQL language > operator. | public BooleanDataValue | in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) The SQL language IN operator. | public BooleanDataValue | isNotNull() The SQL "IS NOT NULL" operator. | public BooleanDataValue | isNullOp() The SQL "IS NULL" operator. | public BooleanDataValue | lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) The SQL language <= operator. | public BooleanDataValue | lessThan(DataValueDescriptor left, DataValueDescriptor right) The SQL language < operator. | public void | normalize(DataTypeDescriptor dtd, DataValueDescriptor source) Normalize the source value to this type described by this class
and the passed in DataTypeDescriptor. | public BooleanDataValue | notEquals(DataValueDescriptor left, DataValueDescriptor right) The SQL language <> operator. | public void | readExternalFromArray(ArrayInputStream ais) Read the DataValueDescriptor from the stream.
Initialize the data value by reading it's values from the
ArrayInputStream. | public void | setBigDecimal(Number bigDecimal) Set this value from an application supplied java.math.BigDecimal.
This is to support the PreparedStatement.setBigDecimal method and
similar JDBC methods that allow an application to pass in a BigDecimal
to any SQL type.
Parameter is declared as java.lang.Number to allow compilation
under J2ME/CDC/Foundation. | public void | setInto(PreparedStatement ps, int position) Set this value into a PreparedStatement. | public void | setInto(ResultSet rs, int position) Set this value into a ResultSet for a subsequent ResultSet.insertRow
or ResultSet.updateRow. | public void | setObjectForCast(Object value, boolean instanceOfResultType, String resultTypeClassName) Set this value from an Object. | void | setToNull() Set the value to SQL null. | public void | setValue(int theValue) | public void | setValue(double theValue) | public void | setValue(float theValue) Set the value of this DataValueDescriptor to the given double value
Parameters: theValue - A Double containing the value to set thisDataValueDescriptor to. | public void | setValue(short theValue) | public void | setValue(long theValue) | public void | setValue(byte theValue) | public void | setValue(boolean theValue) Set the value. | public void | setValue(byte[] theValue) Set the value of this DataValueDescriptor. | public void | setValue(String theValue) Set the value of this DataValueDescriptor. | public void | setValue(Time theValue) Set the value of this DataValueDescriptor. | public void | setValue(Time theValue, Calendar cal) Set the value of this DataValueDescriptor. | public void | setValue(Timestamp theValue) Set the value of this DataValueDescriptor. | public void | setValue(Timestamp theValue, Calendar cal) Set the value of this DataValueDescriptor. | public void | setValue(Date theValue) Set the value of this DataValueDescriptor. | public void | setValue(Date theValue, Calendar cal) Set the value of this DataValueDescriptor. | public void | setValue(DataValueDescriptor theValue) Set the value of this DataValueDescriptor from another. | public void | setValue(InputStream theStream, int valueLength) Set the value to be the contents of the stream.
The reading of the stream may be delayed until execution time.
The format of the stream is required to be the format of this type.
Parameters: theStream - stream of correctly formatted data Parameters: valueLength - logical length of the stream's value in units of this type (e.g. | public void | setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) Set the value based on the value for the specified DataValueDescriptor
from the specified ResultSet. | 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. |
checkHostVariable | public void checkHostVariable(int declaredLength) throws StandardException(Code) | | Check the value to seem if it conforms to the restrictions
imposed by DB2/JCC on host variables for this type.
exception: StandardException - Variable is too big. |
coalesce | public DataValueDescriptor coalesce(DataValueDescriptor[] list, DataValueDescriptor returnValue) throws StandardException(Code) | | 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. Parameters: returnValue - The return value is the correct datatype for this function.The return value of this method is the type of the 2nd parameter. A DataValueDescriptor which will be either null or first non-null argument exception: StandardException - Thrown on error |
compare | int compare(DataValueDescriptor other) throws StandardException(Code) | | 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 less than all
other values.
Parameters: other - The Orderable to compare this one to. <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. exception: StandardException - Thrown on error |
compare | boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException(Code) | | Compare this Orderable with a given Orderable for the purpose of
qualification and sorting. The caller gets to determine how nulls
should be treated - they can either be ordered values or unknown
values.
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. Parameters: other - The DataValueDescriptor to compare this one to. Parameters: orderedNulls - True means to treat nulls as ordered values,that is, treat SQL null as equal to null, and lessthan all other values.False means to treat nulls as unknown values,that is, the result of any comparison with a nullis the UNKNOWN truth value. Parameters: unknownRV - The return value to use if the result of thecomparison is the UNKNOWN truth value. In otherwords, if orderedNulls is false, and a null isinvolved in the comparison, return unknownRV.This parameter is not used orderedNulls is true. true if the comparison is true (duh!) exception: StandardException - Thrown on error |
equals | public BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | 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 operator Parameters: right - The value on the right side of the operator A BooleanDataValue telling the result of the comparison exception: StandardException - Thrown on error |
estimateMemoryUsage | int estimateMemoryUsage()(Code) | | Estimate the memory usage in bytes of the data value and the overhead of the class.
the estimated memory usage |
getBoolean | boolean getBoolean() throws StandardException(Code) | | Gets the value in the data value descriptor as a boolean.
Throws an exception if the data value is not a boolean.
For DataValueDescriptor, this is the preferred interface
for BIT, but for this no-casting interface, it isn't, because
BIT is stored internally as a Bit, not as a Boolean.
The data value as a boolean. exception: StandardException - Thrown on error |
getByte | byte getByte() throws StandardException(Code) | | Gets the value in the data value descriptor as a byte.
Throws an exception if the data value is not a byte.
The data value as a byte. exception: StandardException - Thrown on error |
getBytes | byte[] getBytes() throws StandardException(Code) | | Gets the value in the data value descriptor as a byte array.
Throws an exception if the data value is not a byte array.
The data value as a byte[]. exception: StandardException - Thrown on error |
getClone | public DataValueDescriptor getClone()(Code) | | Clone this DataValueDescriptor. Results in a new object
that has the same value as this but can be modified independently.
A clone of the DataValueDescriptor with the same initial value as this. |
getDate | Date getDate(java.util.Calendar cal) throws StandardException(Code) | | Gets 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 The data value as a java.sql.Date. exception: StandardException - Thrown on error |
getDouble | double getDouble() throws StandardException(Code) | | Gets the value in the data value descriptor as a double.
Throws an exception if the data value is not a double.
The data value as a double. exception: StandardException - Thrown on error |
getFloat | float getFloat() throws StandardException(Code) | | Gets the value in the data value descriptor as a float.
Throws an exception if the data value is not a float.
The data value as a float. exception: StandardException - Thrown on error |
getInt | int getInt() throws StandardException(Code) | | Gets the value in the data value descriptor as an int.
Throws an exception if the data value is not an int.
The data value as a int. exception: StandardException - Thrown on error |
getLength | int getLength() throws StandardException(Code) | | Gets the length of the data value. The meaning of this is
implementation-dependent. For string types, it is the number of
characters in the string. For numeric types, it is the number of
bytes used to store the number. This is the actual length
of this value, not the length of the type it was defined as.
For example, a VARCHAR value may be shorter than the declared
VARCHAR (maximum) length.
The length of the data value exception: StandardException - On error |
getLong | long getLong() throws StandardException(Code) | | Gets the value in the data value descriptor as a long.
Throws an exception if the data value is not a long.
The data value as a long. exception: StandardException - Thrown on error |
getObject | Object getObject() throws StandardException(Code) | | Gets the value in the data value descriptor as a Java Object.
The type of the Object will be the Java object type corresponding
to the data value's SQL type. JDBC defines a mapping between Java
object types and SQL types - we will allow that to be extended
through user type definitions. Throws an exception if the data
value is not an object (yeah, right).
The data value as an Object. exception: StandardException - Thrown on error |
getShort | short getShort() throws StandardException(Code) | | Gets the value in the data value descriptor as a short.
Throws an exception if the data value is not a short.
The data value as a short. exception: StandardException - Thrown on error |
getStream | InputStream getStream() throws StandardException(Code) | | Gets the value in the data value descriptor as a Java InputStream.
Only data types that implements StreamStorable will have stream states.
The stream state of the data value. exception: StandardException - Throws an exception if the data valuecannot be received as a stream. |
getString | String getString() throws StandardException(Code) | | Gets the value in the data value descriptor as a String.
Throws an exception if the data value is not a string.
The data value as a String. exception: StandardException - Thrown on error |
getTime | Time getTime(java.util.Calendar cal) throws StandardException(Code) | | Gets 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 The data value as a java.sql.Time. exception: StandardException - Thrown on error |
getTimestamp | Timestamp getTimestamp(java.util.Calendar cal) throws StandardException(Code) | | Gets 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 The data value as a java.sql.Timestamp. exception: StandardException - Thrown on error |
getTraceString | String getTraceString() throws StandardException(Code) | | Gets 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.
|
getTypeName | public String getTypeName()(Code) | | Get the SQL name of the datatype
The SQL name of the datatype |
greaterOrEquals | public BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | 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 operator Parameters: right - The value on the right side of the operator A BooleanDataValue telling the result of the comparison exception: StandardException - Thrown on error |
greaterThan | public BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | 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 operator Parameters: right - The value on the right side of the operator A BooleanDataValue telling the result of the comparison exception: StandardException - Thrown on error |
in | public BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList) throws StandardException(Code) | | 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 operator Parameters: inList - The values in the IN list Parameters: orderedList - True means that the values in the IN list are ordered,false means they are not. A BooleanDataValue telling the result of the comparison exception: StandardException - Thrown on error |
isNotNull | public BooleanDataValue isNotNull()(Code) | | The SQL "IS NOT NULL" operator. Returns true if this value
is not null.
True if this value is not null. |
isNullOp | public BooleanDataValue isNullOp()(Code) | | The SQL "IS NULL" operator. Returns true if this value
is null.
True if this value is null. |
lessOrEquals | public BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | 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 operator Parameters: right - The value on the right side of the operator A BooleanDataValue telling the result of the comparison exception: StandardException - Thrown on error |
lessThan | public BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | 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 operator Parameters: right - The value on the right side of the operator A BooleanDataValue telling the result of the comparison exception: StandardException - Thrown on error |
notEquals | public BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right) throws StandardException(Code) | | 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 operator Parameters: right - The value on the right side of the operator A BooleanDataValue telling the result of the comparison exception: StandardException - Thrown on error |
readExternalFromArray | public void readExternalFromArray(ArrayInputStream ais) throws IOException, ClassNotFoundException(Code) | | 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. exception: IOException - Usual error is if you try to read past limit on the stream. exception: ClassNotFoundException - If a necessary class can not be found while reading the object fromthe stream. |
setBigDecimal | public void setBigDecimal(Number bigDecimal) throws StandardException(Code) | | Set this value from an application supplied java.math.BigDecimal.
This is to support the PreparedStatement.setBigDecimal method and
similar JDBC methods that allow an application to pass in a BigDecimal
to any SQL type.
Parameter is declared as java.lang.Number to allow compilation
under J2ME/CDC/Foundation. This method will not be called in
any environment that does not support java.math.BigDecimal.
Parameters: bigDecimal - required to be a BigDecimal or null. |
setInto | public void setInto(ResultSet rs, int position) throws SQLException, StandardException(Code) | | Set this value into a ResultSet for a subsequent ResultSet.insertRow
or ResultSet.updateRow. This method will only be called for non-null values.
exception: SQLException - thrown by the ResultSet object exception: StandardException - thrown by me accessing my value. |
setObjectForCast | public void setObjectForCast(Object value, boolean instanceOfResultType, String resultTypeClassName) throws StandardException(Code) | | Set 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 value Parameters: instanceOfResultType - Whether or not the new value is an instanceof the result type. Parameters: resultTypeClassName - The class name of the resulting (declared) type (for error messages only). exception: StandardException - Thrown on error |
setToNull | void setToNull()(Code) | | Set the value to SQL null.
|
setValue | public void setValue(int theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor to the given int value
Parameters: theValue - The value to set this DataValueDescriptor to exception: StandardException - Thrown on error |
setValue | public void setValue(double theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor to the given double value
Parameters: theValue - The value to set this DataValueDescriptor to exception: StandardException - Thrown on error |
setValue | public void setValue(float theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor to the given double value
Parameters: theValue - A Double containing the value to set thisDataValueDescriptor to. Null means set the valueto SQL null. exception: StandardException - Thrown on error |
setValue | public void setValue(short theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor to the given short value
Parameters: theValue - The value to set this DataValueDescriptor to exception: StandardException - Thrown on error |
setValue | public void setValue(long theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor to the given long value
Parameters: theValue - The value to set this DataValueDescriptor to exception: StandardException - Thrown on error |
setValue | public void setValue(byte theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor to the given byte value
Parameters: theValue - The value to set this DataValueDescriptor to |
setValue | public void setValue(boolean theValue) throws StandardException(Code) | | Set the value.
Parameters: theValue - Contains the boolean value to set this to |
setValue | public void setValue(byte[] theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The byte value to set this DataValueDescriptor to |
setValue | public void setValue(String theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The String value to set this DataValueDescriptor to |
setValue | public void setValue(Time theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The Time value to set this DataValueDescriptor to |
setValue | public void setValue(Time theValue, Calendar cal) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The Time value to set this DataValueDescriptor to Parameters: cal - The time zone from the calendar is used to construct the database time value |
setValue | public void setValue(Timestamp theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The Timestamp value to set this DataValueDescriptor to |
setValue | public void setValue(Timestamp theValue, Calendar cal) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The Timestamp value to set this DataValueDescriptor to Parameters: cal - The time zone from the calendar is used to construct the database timestamp value |
setValue | public void setValue(Date theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The Date value to set this DataValueDescriptor to |
setValue | public void setValue(Date theValue, Calendar cal) throws StandardException(Code) | | Set the value of this DataValueDescriptor.
Parameters: theValue - The Date value to set this DataValueDescriptor to Parameters: cal - The time zone from the calendar is used to construct the database date value |
setValue | public void setValue(DataValueDescriptor theValue) throws StandardException(Code) | | Set the value of this DataValueDescriptor from another.
Parameters: theValue - The Date value to set this DataValueDescriptor to |
setValue | public void setValue(InputStream theStream, int valueLength) throws StandardException(Code) | | Set the value to be the contents of the stream.
The reading of the stream may be delayed until execution time.
The format of the stream is required to be the format of this type.
Parameters: theStream - stream of correctly formatted data Parameters: valueLength - logical length of the stream's value in units of this type (e.g. chars for string types). |
setValueFromResultSet | public void setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable) throws StandardException, SQLException(Code) | | Set the value based on the value for the specified DataValueDescriptor
from the specified ResultSet.
Parameters: resultSet - The specified ResultSet. Parameters: colNumber - The 1-based column # into the resultSet. Parameters: isNullable - Whether or not the column is nullable(No need to call wasNull() if not) exception: StandardException - Thrown on error exception: SQLException - Error accessing the result set |
typePrecedence | int typePrecedence()(Code) | | 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.
The precedence of this type. |
typeToBigDecimal | int typeToBigDecimal() throws StandardException(Code) | | How should this value be obtained so that it can
be converted to a BigDecimal representation.
Types.CHAR for String conversion through getStringTypes.DECIMAL for BigDecimal through getObject or Types.BIGINTfor long conversion through getLong exception: StandardException - Conversion is not possible |
|
|