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

Quick Search    Search Deep

org.apache.derby.iapi.types
Class SQLRef  view SQLRef download SQLRef.java

java.lang.Object
  extended byorg.apache.derby.iapi.types.DataType
      extended byorg.apache.derby.iapi.types.SQLRef
All Implemented Interfaces:
CloneableObject, DataValueDescriptor, java.io.Externalizable, org.apache.derby.iapi.services.io.Formatable, Orderable, RefDataValue, java.io.Serializable, org.apache.derby.iapi.services.io.Storable, org.apache.derby.iapi.services.io.TypedFormat

public class SQLRef
extends DataType
implements RefDataValue


Field Summary
private static int BASE_MEMORY_USAGE
           
protected  RowLocation value
           
 
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
SQLRef()
           
SQLRef(RowLocation rowLocation)
           
 
Method Summary
 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.
 int estimateMemoryUsage()
          Estimate the memory usage in bytes of the data value and the overhead of the class.
 DataValueDescriptor getClone()
          Clone this DataValueDescriptor.
 int getLength()
          Gets the length of the data value.
 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.
 java.lang.String getString()
          Gets the value in the data value descriptor as a String.
 int getTypeFormatId()
          Return my format identifier.
 java.lang.String getTypeName()
          Get the SQL name of the datatype
 boolean isNull()
          Return whether the value is null or not.
 void readExternal(java.io.ObjectInput in)
          This method restores an object's state by reading in the instance data for the object from the passed in stream.
 void readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream in)
          Read the DataValueDescriptor from the stream.
 void restoreToNull()
          Restore this object to its (SQL)null value.
protected  void setFrom(DataValueDescriptor theValue)
           
 void setInto(java.sql.PreparedStatement ps, int position)
          Set this value into a PreparedStatement.
 void setValue(java.lang.Object theValue)
          Set the value of this DataValueDescriptor to the given value
 void setValue(RowLocation rowLocation)
          Set the value of this RefDataValue.
 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.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 void writeExternal(java.io.ObjectOutput out)
          This method is responsible for writing the instance data of an object to the passed in stream.
 
Methods inherited from class org.apache.derby.iapi.types.DataType
checkHostVariable, cloneObject, coalesce, dataTypeConversion, equals, equals, flip, genericSetObject, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getNationalString, getShort, getStream, getTime, getTimestamp, greaterOrEquals, greaterThan, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, outOfRange, setBigDecimal, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch, typePrecedence, typeToBigDecimal
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
checkHostVariable, coalesce, equals, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getShort, getStream, getTime, getTimestamp, greaterOrEquals, greaterThan, in, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, setBigDecimal, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, typePrecedence, typeToBigDecimal
 

Field Detail

value

protected RowLocation value

BASE_MEMORY_USAGE

private static final int BASE_MEMORY_USAGE
Constructor Detail

SQLRef

public SQLRef()

SQLRef

public SQLRef(RowLocation rowLocation)
Method Detail

estimateMemoryUsage

public int estimateMemoryUsage()
Description copied from interface: DataValueDescriptor
Estimate the memory usage in bytes of the data value and the overhead of the class.

Specified by:
estimateMemoryUsage in interface DataValueDescriptor

getString

public java.lang.String getString()
Description copied from interface: DataValueDescriptor
Gets the value in the data value descriptor as a String. Throws an exception if the data value is not a string.

Specified by:
getString in interface DataValueDescriptor

getObject

public java.lang.Object getObject()
Description copied from interface: DataValueDescriptor
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).

Specified by:
getObject in interface DataValueDescriptor
Overrides:
getObject in class DataType

setValue

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

Specified by:
setValue in interface DataValueDescriptor
Overrides:
setValue in class DataType

setFrom

protected void setFrom(DataValueDescriptor theValue)
                throws org.apache.derby.iapi.error.StandardException
Overrides:
setFrom in class DataType

getLength

public int getLength()
Description copied from interface: DataValueDescriptor
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.

Specified by:
getLength in interface DataValueDescriptor

getTypeName

public java.lang.String getTypeName()
Description copied from interface: DataValueDescriptor
Get the SQL name of the datatype

Specified by:
getTypeName in interface DataValueDescriptor

getTypeFormatId

public int getTypeFormatId()
Return my format identifier.

Specified by:
getTypeFormatId in interface org.apache.derby.iapi.services.io.TypedFormat

isNull

public boolean isNull()
Description copied from interface: org.apache.derby.iapi.services.io.Storable
Return whether the value is null or not.

Specified by:
isNull in interface org.apache.derby.iapi.services.io.Storable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Description copied from interface: java.io.Externalizable
This method is responsible for writing the instance data of an object to the passed in stream. Note that this stream is not a subclass of OutputStream, but rather is a class that implements the ObjectOutput interface. That interface provides a number of methods for writing Java data values to a stream.

Not that the implementation of this method must be coordinated with the implementation of readExternal.

Specified by:
writeExternal in interface java.io.Externalizable

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Description copied from interface: java.io.Externalizable
This method restores an object's state by reading in the instance data for the object from the passed in stream. Note that this stream is not a subclass of InputStream, but rather is a class that implements the ObjectInput interface. That interface provides a mechanism for reading in Java data types from a stream.

Note that this method must be compatible with writeExternal. It must read back the exact same types that were written by that method in the exact order they were written.

If this method needs to read back an object instance, then the class for that object must be found and loaded. If that operation fails, then this method throws a ClassNotFoundException

Specified by:
readExternal in interface java.io.Externalizable

readExternalFromArray

public void readExternalFromArray(org.apache.derby.iapi.services.io.ArrayInputStream in)
                           throws java.io.IOException,
                                  java.lang.ClassNotFoundException
Description copied from interface: DataValueDescriptor
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().

Specified by:
readExternalFromArray in interface DataValueDescriptor

restoreToNull

public void restoreToNull()
Description copied from interface: org.apache.derby.iapi.services.io.Storable
Restore this object to its (SQL)null value.

Specified by:
restoreToNull in interface org.apache.derby.iapi.services.io.Storable

compare

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

Specified by:
compare in interface DataValueDescriptor
Overrides:
compare in class DataType

compare

public int compare(DataValueDescriptor other)
            throws org.apache.derby.iapi.error.StandardException
Description copied from interface: DataValueDescriptor
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.

Specified by:
compare in interface DataValueDescriptor

getClone

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

Specified by:
getClone in interface DataValueDescriptor

getNewNull

public DataValueDescriptor getNewNull()
Description copied from interface: DataValueDescriptor
Get a new null value of the same type as this data value.

Specified by:
getNewNull in interface DataValueDescriptor

setValueFromResultSet

public void setValueFromResultSet(java.sql.ResultSet resultSet,
                                  int colNumber,
                                  boolean isNullable)
Description copied from interface: DataValueDescriptor
Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet.

Specified by:
setValueFromResultSet in interface DataValueDescriptor

setInto

public void setInto(java.sql.PreparedStatement ps,
                    int position)
Description copied from interface: DataValueDescriptor
Set this value into a PreparedStatement. This method must handle setting NULL into the PreparedStatement.

Specified by:
setInto in interface DataValueDescriptor
Overrides:
setInto in class DataType

setValue

public void setValue(RowLocation rowLocation)
Description copied from interface: RefDataValue
Set the value of this RefDataValue.

Specified by:
setValue in interface RefDataValue

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).