Top Fields Constructors Methods
org.apache.derby.iapi.types

public Class SQLRef

extends DataType
implements RefDataValue
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.types.RefDataValue, org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.types.Orderable, org.apache.derby.iapi.services.io.Storable, org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.services.io.TypedFormat, java.io.Externalizable, java.io.Serializable
Imports
org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.io.StoredFormatIds, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.catalog.TypeDescriptor, org.apache.derby.iapi.services.cache.ClassSize, java.io.ObjectOutput, .ObjectInput, .IOException, java.sql.ResultSet, .PreparedStatement

Field Summary

Modifier and TypeField and Description
private static final int
protected RowLocation

Constructor Summary

AccessConstructor and Description
public
public
SQLRef(RowLocation rowLocation)

Method Summary

Modifier and TypeMethod and Description
public DataValueDescriptor
cloneValue(boolean
any streams representing the data value will be materialized if true, the data value will be kept as a stream if possible if false
forceMaterialization
)

Implements org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

Clone this DataValueDescriptor.

public boolean
compare(int
Orderable.ORDER_OP_EQUALS means do an = comparison. Orderable.ORDER_OP_LESSTHAN means compare this < other. Orderable.ORDER_OP_LESSOREQUALS means compare this <= other.
op
,
DataValueDescriptor
The DataValueDescriptor to compare this one to.
other
,
boolean
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.
orderedNulls
,
boolean
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.
unknownRV
)

Overrides org.apache.derby.iapi.types.DataType.compare.

Implements org.apache.derby.iapi.types.DataValueDescriptor.compare.

Compare this Orderable with a given Orderable for the purpose of qualification and sorting.

public int
compare(DataValueDescriptor
The Orderable to compare this one to.
other
)

Implements org.apache.derby.iapi.types.DataValueDescriptor.compare.

Compare this Orderable with a given Orderable for the purpose of index positioning.

public int
estimateMemoryUsage()

Implements org.apache.derby.iapi.types.DataValueDescriptor.estimateMemoryUsage.

Estimate the memory usage in bytes of the data value and the overhead of the class.

public int
getLength()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getLength.

Gets the length of the data value.

public DataValueDescriptor
getNewNull()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Get a new null value of the same type as this data value.

public Object
getObject()

Overrides org.apache.derby.iapi.types.DataType.getObject.

Implements org.apache.derby.iapi.types.DataValueDescriptor.getObject.

Gets the value in the data value descriptor as a Java Object.

public String
getString()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getString.

Gets the value in the data value descriptor as a String.

public int
public String
getTypeName()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Get the SQL name of the datatype

public int
hashCode()

Overrides java.lang.Object.hashCode.

Adding this overload makes it possible to use SQLRefs as keys in HashMaps.

public boolean
isNull()

Implements org.apache.derby.iapi.services.io.Storable.isNull.

Return whether the value is null or not.

public void
readExternal(ObjectInput
the stream to read data from in order to restore the object
in
)

Implements java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.

public void
restoreToNull()

Implements org.apache.derby.iapi.services.io.Storable.restoreToNull.

Restore this object to its (SQL)null value.

protected void
setFrom(DataValueDescriptor
The DataValueDescriptor that holds the value to which we want to set this DataValueDescriptor's value.
theValue
)

Overrides org.apache.derby.iapi.types.DataType.setFrom.

Set the value of this DataValueDescriptor based on the value of the specified DataValueDescriptor.

public void
setInto(PreparedStatement ps, int position)

Overrides org.apache.derby.iapi.types.DataType.setInto.

Implements org.apache.derby.iapi.types.DataValueDescriptor.setInto.

Set this value into a PreparedStatement.

public void
setValue(RowLocation
Contains the boolean value to set this RefDataValue to. Null means set this RefDataValue to null.
rowLocation
)

Implements org.apache.derby.iapi.types.RefDataValue.setValue.

Set the value of this RefDataValue.

public void
setValueFromResultSet(ResultSet
The specified ResultSet.
resultSet
,
int
The 1-based column # into the resultSet.
colNumber
,
boolean
Whether or not the column is nullable (No need to call wasNull() if not)
isNullable
)

Implements org.apache.derby.iapi.types.DataValueDescriptor.setValueFromResultSet.

Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
writeExternal(ObjectOutput
the stream to write the object to
out
)

Implements java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Inherited from org.apache.derby.iapi.types.DataType:
checkHostVariablecloneHoldercoalescecomparecomparecompareTodataTypeConversionequalsequalsflipgenericSetObjectgetBooleangetBytegetBytesgetDategetDoublegetFloatgetIntgetLonggetShortgetStreamgetTimegetTimestampgetTraceStringgetTypeNamegreaterOrEqualsgreaterThanhasStreamininvalidFormatisNotNullisNullOplessOrEqualslessThannormalizenotEqualsoutOfRangereadExternalFromArrayrecyclesetBigDecimalsetIntosetObjectsetObjectForCastsetToNullsetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuesetValuethrowLangSetMismatchthrowLangSetMismatchtypePrecedencetypeToBigDecimal

Field Detail

BASE_MEMORY_USAGEback to summary
private static final int BASE_MEMORY_USAGE
valueback to summary
protected RowLocation value

Constructor Detail

SQLRefback to summary
public SQLRef()
SQLRefback to summary
public SQLRef(RowLocation rowLocation)

Method Detail

cloneValueback to summary
public DataValueDescriptor cloneValue(boolean forceMaterialization)

Implements org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.cloneValue.

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 if forceMaterialization is set to false. An example is if you need to access the value you just read using cloneValue after the current transaction has ended, or after the source result set has been closed.

Parameters
forceMaterialization:boolean

any streams representing the data value will be materialized if true, the data value will be kept as a stream if possible if false

Returns:DataValueDescriptor

A clone of the DataValueDescriptor with the same initial value as this.

See Also
DataValueDescriptor#cloneValue
compareback to summary
public boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV) throws StandardException

Overrides org.apache.derby.iapi.types.DataType.compare.

Implements org.apache.derby.iapi.types.DataValueDescriptor.compare.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.compare.

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:int

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:DataValueDescriptor

The DataValueDescriptor to compare this one to.

orderedNulls:boolean

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:boolean

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:boolean

true if the comparison is true (duh!)

Exceptions
StandardException:
Thrown on error
compareback to summary
public int compare(DataValueDescriptor other) throws StandardException

Implements org.apache.derby.iapi.types.DataValueDescriptor.compare.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.compare.

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:DataValueDescriptor

The Orderable to compare this one to.

Returns:int

<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.

Exceptions
StandardException:
Thrown on error
estimateMemoryUsageback to summary
public int estimateMemoryUsage()

Implements org.apache.derby.iapi.types.DataValueDescriptor.estimateMemoryUsage.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.estimateMemoryUsage.

Estimate the memory usage in bytes of the data value and the overhead of the class.

Returns:int

the estimated memory usage

getLengthback to summary
public int getLength()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getLength.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getLength.

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.

Returns:int

The length of the data value

getNewNullback to summary
public DataValueDescriptor getNewNull()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getNewNull.

Get a new null value of the same type as this data value.

See Also
DataValueDescriptor#getNewNull
getObjectback to summary
public Object getObject()

Overrides org.apache.derby.iapi.types.DataType.getObject.

Implements org.apache.derby.iapi.types.DataValueDescriptor.getObject.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.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. 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:Object

The data value as an Object.

getStringback to summary
public String getString()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getString.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getString.

Gets the value in the data value descriptor as a String. Throws an exception if the data value is not a string.

Returns:String

The data value as a String.

getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Return my format identifier.

Returns:int

Doc from org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

The identifier. (A UUID stuffed in an array of 16 bytes).

See Also
org.apache.derby.iapi.services.io.TypedFormat#getTypeFormatId
getTypeNameback to summary
public String getTypeName()

Implements org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.getTypeName.

Get the SQL name of the datatype

Returns:String

The SQL name of the datatype

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Adding this overload makes it possible to use SQLRefs as keys in HashMaps.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

isNullback to summary
public boolean isNull()

Implements org.apache.derby.iapi.services.io.Storable.isNull.

Doc from org.apache.derby.iapi.services.io.Storable.isNull.

Return whether the value is null or not.

Returns:boolean

true if the value is null and false otherwise.

readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

Doc from java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Parameters
in:ObjectInput

the stream to read data from in order to restore the object

Exceptions
IOException:
Thrown on error reading the object
ClassNotFoundException:
Thrown if the class of the object read from the stream can't be found (not likely, since it's supposed to be SQLRef).
See Also
java.io.Externalizable#readExternal
restoreToNullback to summary
public void restoreToNull()

Implements org.apache.derby.iapi.services.io.Storable.restoreToNull.

Doc from org.apache.derby.iapi.services.io.Storable.restoreToNull.

Restore this object to its (SQL)null value.

See Also
org.apache.derby.iapi.services.io.Storable#restoreToNull
setFromback to summary
protected void setFrom(DataValueDescriptor theValue) throws StandardException

Overrides org.apache.derby.iapi.types.DataType.setFrom.

Doc from org.apache.derby.iapi.types.DataType.setFrom.

Set the value of this DataValueDescriptor based on the value of the specified DataValueDescriptor.

Parameters
theValue:DataValueDescriptor

The DataValueDescriptor that holds the value to which we want to set this DataValueDescriptor's value.

setIntoback to summary
public void setInto(PreparedStatement ps, int position)

Overrides org.apache.derby.iapi.types.DataType.setInto.

Implements org.apache.derby.iapi.types.DataValueDescriptor.setInto.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.setInto.

Set this value into a PreparedStatement. This method must handle setting NULL into the PreparedStatement.

setValueback to summary
public void setValue(RowLocation rowLocation)

Implements org.apache.derby.iapi.types.RefDataValue.setValue.

Doc from org.apache.derby.iapi.types.RefDataValue.setValue.

Set the value of this RefDataValue.

Parameters
rowLocation:RowLocation

Contains the boolean value to set this RefDataValue to. Null means set this RefDataValue to null.

setValueFromResultSetback to summary
public void setValueFromResultSet(ResultSet resultSet, int colNumber, boolean isNullable)

Implements org.apache.derby.iapi.types.DataValueDescriptor.setValueFromResultSet.

Doc from org.apache.derby.iapi.types.DataValueDescriptor.setValueFromResultSet.

Set the value based on the value for the specified DataValueDescriptor from the specified ResultSet.

Parameters
resultSet:ResultSet

The specified ResultSet.

colNumber:int

The 1-based column # into the resultSet.

isNullable:boolean

Whether or not the column is nullable (No need to call wasNull() if not)

See Also
DataValueDescriptor#setValueFromResultSet
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

Doc from java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Parameters
out:ObjectOutput

the stream to write the object to

Exceptions
IOException:
Includes any I/O exceptions that may occur