org.apache.derby.iapi.types
Class DataType

java.lang.Object
  extended byorg.apache.derby.iapi.types.DataType
All Implemented Interfaces:
CloneableObject, DataValueDescriptor, java.io.Externalizable, Formatable, Orderable, java.io.Serializable, Storable, TypedFormat
Direct Known Subclasses:
GenericConglomerate, HeapRowLocation, NumberDataType, SQLBinary, SQLBoolean, SQLChar, SQLDate, SQLRef, SQLTime, SQLTimestamp, StorableFormatId, UserType

public abstract class DataType
extends java.lang.Object
implements DataValueDescriptor, CloneableObject

DataType is the superclass for all data types. It provides common behavior for datavalue descriptors -- it throws exceptions for all of the get* and setvalue(*) methods of DataValueDescriptor; the subtypes need only override the one for the type they represent and all types it can also be returned as, and the methods dealing with nulls. Since all types satisfy getString DataType does not define that interfaces of DataValueDescriptor. DataType is a little glue for columns to hold values with.

See Also:
Serialized Form

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
 
Constructor Summary
DataType()
           
 
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.
 java.lang.Object cloneObject()
          From CloneableObject
 DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList, DataValueDescriptor returnValue)
          The SQL language COALESCE/VALUE function.
 boolean compare(int op, DataValueDescriptor other, boolean orderedNulls, boolean unknownRV)
          Compare this Orderable with a given Orderable for the purpose of qualification and sorting.
protected  StandardException dataTypeConversion(java.lang.String targetType)
          Return an conversion exception for this type.
 BooleanDataValue equals(DataValueDescriptor left, DataValueDescriptor right)
          The = operator as called from the language module, as opposed to the storage module.
 boolean equals(java.lang.Object other)
           
protected static int flip(int operator)
          Flip the operator used in a comparison (< -> >).
protected  void genericSetObject(java.lang.Object theValue)
           
 java.math.BigDecimal getBigDecimal()
          Gets the value in the data value descriptor as a BigDecimal.
 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[].
 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 a int.
 long getLong()
          Gets the value in the data value descriptor as a long.
protected  java.lang.String getNationalString(LocaleFinder localeFinder)
          International version of getString().
 java.lang.Object getObject()
          Gets the value in the data value descriptor as a int.
 short getShort()
          Gets the value in the data value descriptor as a short.
 java.io.InputStream getStream()
          Gets the value in the data stream descriptor as an InputStream.
 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.
 BooleanDataValue greaterOrEquals(DataValueDescriptor left, DataValueDescriptor right)
          The >= operator as called from the language module, as opposed to the storage module.
 BooleanDataValue greaterThan(DataValueDescriptor left, DataValueDescriptor right)
          The > operator as called from the language module, as opposed to the storage module.
 BooleanDataValue in(DataValueDescriptor left, DataValueDescriptor[] inList, boolean orderedList)
          The SQL language IN operator.
protected  StandardException invalidFormat()
          Return an out of range exception for this type.
 BooleanDataValue isNotNull()
          The is not null operator as called from the language module, as opposed to the storage module.
 BooleanDataValue isNullOp()
          The is null operator as called from the language module, as opposed to the storage module.
 BooleanDataValue lessOrEquals(DataValueDescriptor left, DataValueDescriptor right)
          The <= operator as called from the language module, as opposed to the storage module.
 BooleanDataValue lessThan(DataValueDescriptor left, DataValueDescriptor right)
          The < operator as called from the language module, as opposed to the storage module.
 void normalize(DataTypeDescriptor desiredType, DataValueDescriptor source)
          Default normalization method.
 BooleanDataValue notEquals(DataValueDescriptor left, DataValueDescriptor right)
          The <> operator as called from the language module, as opposed to the storage module.
protected  StandardException outOfRange()
          Return an out of range exception for this type.
protected  void setFrom(DataValueDescriptor dvd)
           
 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 instanceOf, 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(java.math.BigDecimal theValue)
          Set the value of this DataValueDescriptor.
 void setValue(boolean theValue)
          Set the value.
 void setValue(byte theValue)
          Set the value of this DataValueDescriptor to the given byte value At DataType level just throws an error lower classes will override
 void setValue(byte[] theValue)
          Set the value of this DataValueDescriptor.
 void setValue(DataValueDescriptor dvd)
          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 At DataType level just throws an error lower classes will override
 void setValue(float theValue)
          Set the value of this DataValueDescriptor to the given float value At DataType level just throws an error lower classes will override
 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 At DataType level just throws an error lower classes will override
 void setValue(long theValue)
          Set the value of this DataValueDescriptor to the given long value At DataType level just throws an error lower classes will override
 void setValue(java.lang.Object theValue)
          Set the value from an object.
 void setValue(short theValue)
          Set the value of this DataValueDescriptor to the given short value At DataType level just throws an error lower classes will override
 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 throwLangSetMismatch(java.lang.Object value)
           
(package private)  void throwLangSetMismatch(java.lang.String argTypeName)
           
 int typePrecedence()
          Each built-in type in JSQL has a precedence.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
compare, estimateMemoryUsage, getClone, getLength, getNewNull, getString, getTypeName, readExternalFromArray, setValueFromResultSet
 
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
 

Constructor Detail

DataType

public DataType()
Method Detail

getBoolean

public boolean getBoolean()
                   throws StandardException
Gets the value in the data value descriptor as a boolean. Throws an exception if the data value is not receivable as a boolean.

Specified by:
getBoolean in interface DataValueDescriptor
Returns:
The data value as a boolean.
Throws:
StandardException - Thrown on error

getByte

public byte getByte()
             throws StandardException
Gets the value in the data value descriptor as a byte. Throws an exception if the data value is not receivable as a byte.

Specified by:
getByte in interface DataValueDescriptor
Returns:
The data value as a byte.
Throws:
StandardException - Thrown on error

getShort

public short getShort()
               throws StandardException
Gets the value in the data value descriptor as a short. Throws an exception if the data value is not receivable as a short.

Specified by:
getShort in interface DataValueDescriptor
Returns:
The data value as a short.
Throws:
StandardException - Thrown on error

getInt

public int getInt()
           throws StandardException
Gets the value in the data value descriptor as a int. Throws an exception if the data value is not receivable as a int.

Specified by:
getInt in interface DataValueDescriptor
Returns:
The data value as a int.
Throws:
StandardException - Thrown on error

getLong

public long getLong()
             throws StandardException
Gets the value in the data value descriptor as a long. Throws an exception if the data value is not receivable as a long.

Specified by:
getLong in interface DataValueDescriptor
Returns:
The data value as a long.
Throws:
StandardException - Thrown on error

getFloat

public float getFloat()
               throws StandardException
Gets the value in the data value descriptor as a float. Throws an exception if the data value is not receivable as a float.

Specified by:
getFloat in interface DataValueDescriptor
Returns:
The data value as a float.
Throws:
StandardException - Thrown on error

getDouble

public double getDouble()
                 throws StandardException
Gets the value in the data value descriptor as a double. Throws an exception if the data value is not receivable as a double.

Specified by:
getDouble in interface DataValueDescriptor
Returns:
The data value as a double.
Throws:
StandardException - Thrown on error

getBigDecimal

public java.math.BigDecimal getBigDecimal()
                                   throws StandardException
Gets the value in the data value descriptor as a BigDecimal. Throws an exception if the data value is not receivable as a BigDecimal.

Specified by:
getBigDecimal in interface DataValueDescriptor
Returns:
The data value as a java.lang.BigDecimal.
Throws:
StandardException - Thrown on error

getBytes

public byte[] getBytes()
                throws StandardException
Gets the value in the data value descriptor as a byte[]. Throws an exception if the data value is not receivable as a Binary or Varbinary.

Specified by:
getBytes in interface DataValueDescriptor
Returns:
The Binary value as a byte[].
Throws:
StandardException - Thrown on error

getDate

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

Specified by:
getDate in interface DataValueDescriptor
Parameters:
cal - calendar for object creation
Returns:
The data value as a java.sql.Date.
Throws:
StandardException - Thrown on error

getTime

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

Specified by:
getTime in interface DataValueDescriptor
Parameters:
cal - calendar for object creation
Returns:
The data value as a java.sql.Time.
Throws:
StandardException - Thrown on error

getTimestamp

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

Specified by:
getTimestamp in interface DataValueDescriptor
Parameters:
cal - calendar for object creation
Returns:
The data value as a java.sql.Timestamp.
Throws:
StandardException - Thrown on error

getStream

public java.io.InputStream getStream()
                              throws StandardException
Gets the value in the data stream descriptor as an InputStream. Throws an exception if the data value is not receivable as a stream.

Specified by:
getStream in interface DataValueDescriptor
Returns:
The data value as an InputStream.
Throws:
StandardException - Thrown on error

isNullOp

public final BooleanDataValue isNullOp()
The is null operator as called from the language module, as opposed to the storage module.

Specified by:
isNullOp in interface DataValueDescriptor
Returns:
A SQL boolean value telling whether the operand is null

isNotNull

public final BooleanDataValue isNotNull()
The is not null operator as called from the language module, as opposed to the storage module.

Specified by:
isNotNull in interface DataValueDescriptor
Returns:
A SQL boolean value telling whether the operand is not null

setValue

public void setValue(java.sql.Time theValue)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The Time value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(java.sql.Time theValue,
                     java.util.Calendar cal)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The Time value to set this DataValueDescriptor to
cal - The time zone from the calendar is used to construct the database time value
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(java.sql.Timestamp theValue)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The Timestamp value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(java.sql.Timestamp theValue,
                     java.util.Calendar cal)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The Timestamp value to set this DataValueDescriptor to
cal - The time zone from the calendar is used to construct the database timestamp value
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(java.sql.Date theValue)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The Date value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(java.sql.Date theValue,
                     java.util.Calendar cal)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The Date value to set this DataValueDescriptor to
cal - The time zone from the calendar is used to construct the database date value
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(java.math.BigDecimal theValue)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The BigDecimal value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(java.lang.String theValue)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The BigDecimal value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public void setValue(int theValue)
              throws StandardException
Set the value of this DataValueDescriptor to the given int value At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException - Thrown on error

setValue

public void setValue(double theValue)
              throws StandardException
Set the value of this DataValueDescriptor to the given double value At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException - Thrown on error

setValue

public void setValue(float theValue)
              throws StandardException
Set the value of this DataValueDescriptor to the given float value At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException - Thrown on error

setValue

public void setValue(short theValue)
              throws StandardException
Set the value of this DataValueDescriptor to the given short value At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException - Thrown on error

setValue

public void setValue(long theValue)
              throws StandardException
Set the value of this DataValueDescriptor to the given long value At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException - Thrown on error

setValue

public void setValue(byte theValue)
              throws StandardException
Set the value of this DataValueDescriptor to the given byte value At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException - Thrown on error

setValue

public void setValue(boolean theValue)
              throws StandardException
Set the value. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - Contains the boolean value to set this to
Returns:
This value
Throws:
StandardException

setValue

public void setValue(byte[] theValue)
              throws StandardException
Set the value of this DataValueDescriptor. At DataType level just throws an error lower classes will override

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - The byte value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException

setValue

public final void setValue(DataValueDescriptor dvd)
                    throws StandardException
Description copied from interface: DataValueDescriptor
Set the value of this DataValueDescriptor from another.

Specified by:
setValue in interface DataValueDescriptor
Parameters:
dvd - The Date value to set this DataValueDescriptor to
Returns:
This DataValueDescriptor
Throws:
StandardException

setFrom

protected void setFrom(DataValueDescriptor dvd)
                throws StandardException
Throws:
StandardException

setToNull

public void setToNull()
Description copied from interface: DataValueDescriptor
Set the value to SQL null.

Specified by:
setToNull in interface DataValueDescriptor
See Also:
DataValueDescriptor.setToNull()

setObjectForCast

public void setObjectForCast(java.lang.Object value,
                             boolean instanceOf,
                             java.lang.String resultTypeClassName)
                      throws StandardException
Set the Object that this Data Type contains (for an explicit cast).

Specified by:
setObjectForCast in interface DataValueDescriptor
Parameters:
value - The new value
instanceOf - Whether or not the new value is an instanceof the result type.
resultTypeClassName - The class name of the resulting type (for error messages only).
Throws:
StandardException - Thrown on error

setValue

public void setValue(java.lang.Object theValue)
              throws StandardException
Set the value from an object. Usually overridden. This implementation sets this to NULL if the passed in value is null, otherwise an exception is thrown.

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theValue - An Object containing the value to set this DataValueDescriptor to. Null means set the value to SQL null.
Returns:
This DataValueDescriptor
Throws:
StandardException - Thrown on error

getObject

public java.lang.Object getObject()
                           throws StandardException
Gets the value in the data value descriptor as a int. Throws an exception if the data value is not receivable as a int.

Specified by:
getObject in interface DataValueDescriptor
Returns:
The data value as a int.
Throws:
StandardException - Thrown on error

genericSetObject

protected void genericSetObject(java.lang.Object theValue)
                         throws StandardException
Throws:
StandardException

cloneObject

public java.lang.Object cloneObject()
From CloneableObject

Specified by:
cloneObject in interface CloneableObject
Returns:
clone of me as an Object

getNationalString

protected java.lang.String getNationalString(LocaleFinder localeFinder)
                                      throws StandardException
International version of getString(). Overridden for date, time, and timestamp in SQLDate, SQLTime, SQLTimestamp.

Throws:
StandardException - Thrown on error

throwLangSetMismatch

public void throwLangSetMismatch(java.lang.Object value)
                          throws StandardException
Throws:
StandardException

throwLangSetMismatch

void throwLangSetMismatch(java.lang.String argTypeName)
                    throws StandardException
Throws:
StandardException

setInto

public void setInto(java.sql.PreparedStatement ps,
                    int position)
             throws java.sql.SQLException,
                    StandardException
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
Throws:
StandardException - thrown by me accessing my value.
java.sql.SQLException - thrown by the PreparedStatement object

setInto

public void setInto(java.sql.ResultSet rs,
                    int position)
             throws java.sql.SQLException,
                    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.

Specified by:
setInto in interface DataValueDescriptor
Throws:
java.sql.SQLException - thrown by the ResultSet object
StandardException - thrown by me accessing my value.

normalize

public void normalize(DataTypeDescriptor desiredType,
                      DataValueDescriptor source)
               throws StandardException
Default normalization method. No information needed from DataTypeDescriptor.

Specified by:
normalize in interface DataValueDescriptor
Parameters:
desiredType - The type to normalize the source column to
source - The value to normalize
Throws:
StandardException - Thrown normalization error.

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.

Specified by:
typePrecedence in interface DataValueDescriptor
Returns:
The precedence of this type.

equals

public BooleanDataValue equals(DataValueDescriptor left,
                               DataValueDescriptor right)
                        throws StandardException
The = operator as called from the language module, as opposed to the storage module. This default implementations uses compare().

Specified by:
equals in interface DataValueDescriptor
Parameters:
left - The value on the left side of the =
right - The value on the right side of the =
Returns:
A SQL boolean value telling whether the two parameters are equal
Throws:
StandardException - Thrown on error

notEquals

public BooleanDataValue notEquals(DataValueDescriptor left,
                                  DataValueDescriptor right)
                           throws StandardException
The <> operator as called from the language module, as opposed to the storage module. This default implementations uses compare().

Specified by:
notEquals in interface DataValueDescriptor
Parameters:
left - The value on the left side of the <>
right - The value on the right side of the <>
Returns:
A SQL boolean value telling whether the two parameters are not equal
Throws:
StandardException - Thrown on error

lessThan

public BooleanDataValue lessThan(DataValueDescriptor left,
                                 DataValueDescriptor right)
                          throws StandardException
The < operator as called from the language module, as opposed to the storage module.

Specified by:
lessThan in interface DataValueDescriptor
Parameters:
left - The value on the left side of the <
right - The value on the right side of the <
Returns:
A SQL boolean value telling whether the first operand is less than the second operand
Throws:
StandardException - Thrown on error

greaterThan

public BooleanDataValue greaterThan(DataValueDescriptor left,
                                    DataValueDescriptor right)
                             throws StandardException
The > operator as called from the language module, as opposed to the storage module. This default implementations uses compare().

Specified by:
greaterThan in interface DataValueDescriptor
Parameters:
left - The value on the left side of the >
right - The value on the right side of the >
Returns:
A SQL boolean value telling whether the first operand is greater than the second operand
Throws:
StandardException - Thrown on error

lessOrEquals

public BooleanDataValue lessOrEquals(DataValueDescriptor left,
                                     DataValueDescriptor right)
                              throws StandardException
The <= operator as called from the language module, as opposed to the storage module. This default implementations uses compare().

Specified by:
lessOrEquals in interface DataValueDescriptor
Parameters:
left - The value on the left side of the <=
right - The value on the right side of the <=
Returns:
A SQL boolean value telling whether the first operand is less than or equal to the second operand
Throws:
StandardException - Thrown on error

greaterOrEquals

public BooleanDataValue greaterOrEquals(DataValueDescriptor left,
                                        DataValueDescriptor right)
                                 throws StandardException
The >= operator as called from the language module, as opposed to the storage module. This default implementation uses compare().

Specified by:
greaterOrEquals in interface DataValueDescriptor
Parameters:
left - The value on the left side of the >=
right - The value on the right side of the >=
Returns:
A SQL boolean value telling whether the first operand is greater than or equal to the second operand
Throws:
StandardException - Thrown on error

compare

public boolean compare(int op,
                       DataValueDescriptor other,
                       boolean orderedNulls,
                       boolean unknownRV)
                throws 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
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

flip

protected static int flip(int operator)
Flip the operator used in a comparison (< -> >). This is useful when flipping a comparison due to type precedence.

Parameters:
operator - The operator to flip.
Returns:
The flipped operator.

coalesce

public DataValueDescriptor coalesce(DataValueDescriptor[] argumentsList,
                                    DataValueDescriptor returnValue)
                             throws StandardException
Description copied from interface: DataValueDescriptor
The SQL language COALESCE/VALUE function. This method is called from the language module.

Specified by:
coalesce in interface DataValueDescriptor
Parameters:
argumentsList - 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
See Also:
DataValueDescriptor.coalesce(org.apache.derby.iapi.types.DataValueDescriptor[], org.apache.derby.iapi.types.DataValueDescriptor)

in

public BooleanDataValue in(DataValueDescriptor left,
                           DataValueDescriptor[] inList,
                           boolean orderedList)
                    throws StandardException
Description copied from interface: DataValueDescriptor
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.

Specified by:
in in interface DataValueDescriptor
Parameters:
left - The value on the left side of the operator
inList - The values in the IN list
orderedList - 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
See Also:
DataValueDescriptor.in(org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.iapi.types.DataValueDescriptor[], boolean)

equals

public boolean equals(java.lang.Object other)

setValue

public void setValue(java.io.InputStream theStream,
                     int streamLength)
              throws StandardException
Description copied from interface: DataValueDescriptor
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.

Specified by:
setValue in interface DataValueDescriptor
Parameters:
theStream - stream of correctly formatted data
streamLength - logical length of the stream's value in units of this type (e.g. chars for string types).
Throws:
StandardException

checkHostVariable

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

Specified by:
checkHostVariable in interface DataValueDescriptor
Throws:
StandardException - Variable is too big.

dataTypeConversion

protected final StandardException dataTypeConversion(java.lang.String targetType)
Return an conversion exception for this type.


outOfRange

protected final StandardException outOfRange()
Return an out of range exception for this type.


invalidFormat

protected final StandardException invalidFormat()
Return an out of range exception for this type.



Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.