Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.types
Interface DataValueDescriptor  view DataValueDescriptor download DataValueDescriptor.java

All Superinterfaces:
java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, Orderable, java.io.Serializable, org.apache.derby.iapi.services.io.Storable, org.apache.derby.iapi.services.io.TypedFormat
All Known Subinterfaces:
BitDataValue, BooleanDataValue, ConcatableDataValue, DateTimeDataValue, NumberDataValue, RefDataValue, RowLocation, StringDataValue, UserDataValue, XMLDataValue
All Known Implementing Classes:
DataType, NumberDataType, SQLBinary, SQLBoolean, SQLChar, SQLDate, SQLRef, SQLTime, SQLTimestamp, UserType, XML

public interface DataValueDescriptor
extends org.apache.derby.iapi.services.io.Storable, Orderable

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()


Field Summary
 
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
 void checkHostVariable(int declaredLength)
          Check the value to seem if it conforms to the restrictions imposed by DB2/JCC on host variables for this type.
 DataValueDescriptor 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.
 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.
 DataValueDescriptor getClone()
          Clone this DataValueDescriptor.
 java.sql.Date getDate(java.util.Calendar cal)
          Gets the value in the data value descriptor as a java.sql.Date.
 double getDouble()
          Gets the value in the data value descriptor as a double.
 float getFloat()
          Gets the value in the data value descriptor as a float.
 int getInt()
          Gets the value in the data value descriptor as an int.
 int getLength()
          Gets the length of the data value.
 long getLong()
          Gets the value in the data value descriptor as a long.
 DataValueDescriptor getNewNull()
          Get a new null value of the same type as this data value.
 java.lang.Object getObject()
          Gets the value in the data value descriptor as a Java Object.
 short getShort()
          Gets the value in the data value descriptor as a short.
 java.io.InputStream getStream()
          Gets the value in the data value descriptor as a Java InputStream.
 java.lang.String getString()
          Gets the value in the data value descriptor as a String.
 java.sql.Time getTime(java.util.Calendar cal)
          Gets the value in the data value descriptor as a java.sql.Time.
 java.sql.Timestamp getTimestamp(java.util.Calendar cal)
          Gets the value in the data value descriptor as a java.sql.Timestamp.
 java.lang.String getTypeName()
          Get the SQL name of the datatype
 BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right)
          The SQL language >= operator.
 BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right)
          The SQL language > operator.
 BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList)
          The SQL language IN operator.
 BooleanDataValue isNotNull()
          The SQL "IS NOT NULL" operator.
 BooleanDataValue isNullOp()
          The SQL "IS NULL" operator.
 BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right)
          The SQL language <= operator.
 BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right)
          The SQL language < operator.
 void normalize(DataTypeDescriptor dtd, DataValueDescriptor source)
          Normalize the source value to this type described by this class and the passed in DataTypeDescriptor.
 BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right)
          The SQL language <> operator.
 void readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream ais)
          Read the DataValueDescriptor from the stream.
 void setBigDecimal(java.lang.Number bigDecimal)
          Set this value from an application supplied java.math.BigDecimal.
 void setInto(java.sql.PreparedStatement ps, int position)
          Set this value into a PreparedStatement.
 void setInto(java.sql.ResultSet rs, int position)
          Set this value into a ResultSet for a subsequent ResultSet.insertRow or ResultSet.updateRow.
 void setObjectForCast(java.lang.Object value, boolean instanceOfResultType, java.lang.String resultTypeClassName)
          Set the Object that this Data Type contains (for an explicit cast).
 void setToNull()
          Set the value to SQL null.
 void setValue(boolean theValue)
          Set the value.
 void setValue(byte theValue)
          Set the value of this DataValueDescriptor to the given byte value
 void setValue(byte[] theValue)
          Set the value of this DataValueDescriptor.
 void setValue(DataValueDescriptor theValue)
          Set the value of this DataValueDescriptor from another.
 void setValue(java.sql.Date theValue)
          Set the value of this DataValueDescriptor.
 void setValue(java.sql.Date theValue, java.util.Calendar cal)
          Set the value of this DataValueDescriptor.
 void setValue(double theValue)
          Set the value of this DataValueDescriptor to the given double value
 void setValue(float theValue)
          Set the value of this DataValueDescriptor to the given double value
 void setValue(java.io.InputStream theStream, int streamLength)
          Set the value to be the contents of the stream.
 void setValue(int theValue)
          Set the value of this DataValueDescriptor to the given int value
 void setValue(long theValue)
          Set the value of this DataValueDescriptor to the given long value
 void setValue(java.lang.Object theValue)
          Set the value of this DataValueDescriptor to the given value
 void setValue(short theValue)
          Set the value of this DataValueDescriptor to the given short value
 void setValue(java.lang.String theValue)
          Set the value of this DataValueDescriptor.
 void setValue(java.sql.Time theValue)
          Set the value of this DataValueDescriptor.
 void setValue(java.sql.Time theValue, java.util.Calendar cal)
          Set the value of this DataValueDescriptor.
 void setValue(java.sql.Timestamp theValue)
          Set the value of this DataValueDescriptor.
 void setValue(java.sql.Timestamp theValue, java.util.Calendar cal)
          Set the value of this DataValueDescriptor.
 void setValueFromResultSet(java.sql.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.
 
Methods inherited from interface org.apache.derby.iapi.services.io.Storable
isNull, restoreToNull
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
 

Method Detail

getLength

public int getLength()
              throws org.apache.derby.iapi.error.StandardException
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.


getString

public java.lang.String getString()
                           throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a String. Throws an exception if the data value is not a string.


getBoolean

public boolean getBoolean()
                   throws org.apache.derby.iapi.error.StandardException
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.


getByte

public byte getByte()
             throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a byte. Throws an exception if the data value is not a byte.


getShort

public short getShort()
               throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a short. Throws an exception if the data value is not a short.


getInt

public int getInt()
           throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as an int. Throws an exception if the data value is not an int.


getLong

public long getLong()
             throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a long. Throws an exception if the data value is not a long.


getFloat

public float getFloat()
               throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a float. Throws an exception if the data value is not a float.


getDouble

public double getDouble()
                 throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a double. Throws an exception if the data value is not a double.


typeToBigDecimal

public int typeToBigDecimal()
                     throws org.apache.derby.iapi.error.StandardException
How should this value be obtained so that it can be converted to a BigDecimal representation.


getBytes

public byte[] getBytes()
                throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a byte array. Throws an exception if the data value is not a byte array.


getDate

public java.sql.Date getDate(java.util.Calendar cal)
                      throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a java.sql.Date. Throws an exception if the data value is not a Date.


getTime

public java.sql.Time getTime(java.util.Calendar cal)
                      throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a java.sql.Time. Throws an exception if the data value is not a Time.


getTimestamp

public java.sql.Timestamp getTimestamp(java.util.Calendar cal)
                                throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a java.sql.Timestamp. Throws an exception if the data value is not a Timestamp.


getObject

public java.lang.Object getObject()
                           throws org.apache.derby.iapi.error.StandardException
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).


getStream

public java.io.InputStream getStream()
                              throws org.apache.derby.iapi.error.StandardException
Gets the value in the data value descriptor as a Java InputStream. Only data types that implements StreamStorable will have stream states.


getClone

public DataValueDescriptor getClone()
Clone this DataValueDescriptor. Results in a new object that has the same value as this but can be modified independently.


getNewNull

public DataValueDescriptor getNewNull()
Get a new null value of the same type as this data value.


setValueFromResultSet

public void setValueFromResultSet(java.sql.ResultSet resultSet,
                                  int colNumber,
                                  boolean isNullable)
                           throws org.apache.derby.iapi.error.StandardException,
                                  java.sql.SQLException
Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet.


setInto

public void setInto(java.sql.PreparedStatement ps,
                    int position)
             throws java.sql.SQLException,
                    org.apache.derby.iapi.error.StandardException
Set this value into a PreparedStatement. This method must handle setting NULL into the PreparedStatement.


setInto

public void setInto(java.sql.ResultSet rs,
                    int position)
             throws java.sql.SQLException,
                    org.apache.derby.iapi.error.StandardException
Set this value into a ResultSet for a subsequent ResultSet.insertRow or ResultSet.updateRow. This method will only be called for non-null values.


setValue

public void setValue(java.lang.Object theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor to the given value


setValue

public void setValue(int theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor to the given int value


setValue

public void setValue(double theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor to the given double value


setValue

public void setValue(float theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor to the given double value


setValue

public void setValue(short theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor to the given short value


setValue

public void setValue(long theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor to the given long value


setValue

public void setValue(byte theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor to the given byte value


setValue

public void setValue(boolean theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value.


setValue

public void setValue(byte[] theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setBigDecimal

public void setBigDecimal(java.lang.Number bigDecimal)
                   throws org.apache.derby.iapi.error.StandardException
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.


setValue

public void setValue(java.lang.String theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setValue

public void setValue(java.sql.Time theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setValue

public void setValue(java.sql.Time theValue,
                     java.util.Calendar cal)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setValue

public void setValue(java.sql.Timestamp theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setValue

public void setValue(java.sql.Timestamp theValue,
                     java.util.Calendar cal)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setValue

public void setValue(java.sql.Date theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setValue

public void setValue(java.sql.Date theValue,
                     java.util.Calendar cal)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor.


setValue

public void setValue(DataValueDescriptor theValue)
              throws org.apache.derby.iapi.error.StandardException
Set the value of this DataValueDescriptor from another.


setToNull

public void setToNull()
Set the value to SQL null.


normalize

public void normalize(DataTypeDescriptor dtd,
                      DataValueDescriptor source)
               throws org.apache.derby.iapi.error.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.


isNullOp

public BooleanDataValue isNullOp()
The SQL "IS NULL" operator. Returns true if this value is null. *


isNotNull

public BooleanDataValue isNotNull()
The SQL "IS NOT NULL" operator. Returns true if this value is not null.


getTypeName

public java.lang.String getTypeName()
Get the SQL name of the datatype


setObjectForCast

public void setObjectForCast(java.lang.Object value,
                             boolean instanceOfResultType,
                             java.lang.String resultTypeClassName)
                      throws org.apache.derby.iapi.error.StandardException
Set the Object that this Data Type contains (for an explicit cast).


readExternalFromArray

public void readExternalFromArray(org.apache.derby.iapi.services.io.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().


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.


equals

public BooleanDataValue equals(DataValueDescriptor left,
                               DataValueDescriptor right)
                        throws org.apache.derby.iapi.error.StandardException
The SQL language = operator. This method is called from the language module. The storage module uses the compare method in Orderable.


notEquals

public BooleanDataValue notEquals(DataValueDescriptor left,
                                  DataValueDescriptor right)
                           throws org.apache.derby.iapi.error.StandardException
The SQL language <> operator. This method is called from the language module. The storage module uses the compare method in Orderable.


lessThan

public BooleanDataValue lessThan(DataValueDescriptor left,
                                 DataValueDescriptor right)
                          throws org.apache.derby.iapi.error.StandardException
The SQL language < operator. This method is called from the language module. The storage module uses the compare method in Orderable.


greaterThan

public BooleanDataValue greaterThan(DataValueDescriptor left,
                                    DataValueDescriptor right)
                             throws org.apache.derby.iapi.error.StandardException
The SQL language > operator. This method is called from the language module. The storage module uses the compare method in Orderable.


lessOrEquals

public BooleanDataValue lessOrEquals(DataValueDescriptor left,
                                     DataValueDescriptor right)
                              throws org.apache.derby.iapi.error.StandardException
The SQL language <= operator. This method is called from the language module. The storage module uses the compare method in Orderable.


greaterOrEquals

public BooleanDataValue greaterOrEquals(DataValueDescriptor left,
                                        DataValueDescriptor right)
                                 throws org.apache.derby.iapi.error.StandardException
The SQL language >= operator. This method is called from the language module. The storage module uses the compare method in Orderable.


coalesce

public DataValueDescriptor coalesce(DataValueDescriptor[] list,
                                    DataValueDescriptor returnValue)
                             throws org.apache.derby.iapi.error.StandardException
The SQL language COALESCE/VALUE function. This method is called from the language module.


in

public BooleanDataValue in(DataValueDescriptor left,
                           DataValueDescriptor[] inList,
                           boolean orderedList)
                    throws org.apache.derby.iapi.error.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.


compare

public int compare(DataValueDescriptor other)
            throws org.apache.derby.iapi.error.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 less than all other values.


compare

public boolean compare(int op,
                       DataValueDescriptor other,
                       boolean orderedNulls,
                       boolean unknownRV)
                throws org.apache.derby.iapi.error.StandardException
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.


setValue

public void setValue(java.io.InputStream theStream,
                     int streamLength)
              throws org.apache.derby.iapi.error.StandardException
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.


checkHostVariable

public void checkHostVariable(int declaredLength)
                       throws org.apache.derby.iapi.error.StandardException
Check the value to seem if it conforms to the restrictions imposed by DB2/JCC on host variables for this type.


estimateMemoryUsage

public int estimateMemoryUsage()
Estimate the memory usage in bytes of the data value and the overhead of the class.