|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.derby.iapi.types.DataType
org.apache.derby.iapi.types.SQLBoolean
SQLBoolean satisfies the DataValueDescriptor interfaces (i.e., DataType). It implements a boolean column, e.g. for * storing a column value; it can be specified when constructed to not allow nulls. Nullability cannot be changed after construction, as it affects the storage size and mechanism.
Because DataType is a subtype of DataType, SQLBoolean can play a role in either a DataType/Row or a DataType/Row, interchangeably.
We assume the store has a flag for nullness of the value, and simply return a 0-length array for the stored form when the value is null.
PERFORMANCE: There are likely alot of performance improvements possible for this implementation -- it new's Integer more than it probably wants to.
| Field Summary | |
private static int |
BASE_MEMORY_USAGE
|
private static SQLBoolean |
BOOLEAN_FALSE
|
(package private) static int |
BOOLEAN_LENGTH
|
private static SQLBoolean |
BOOLEAN_TRUE
|
protected boolean |
immutable
|
protected boolean |
isnull
|
(package private) static SQLBoolean |
UNKNOWN
|
protected boolean |
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 | |
|
SQLBoolean()
|
|
SQLBoolean(boolean val)
|
|
SQLBoolean(java.lang.Boolean obj)
|
private |
SQLBoolean(boolean val,
boolean isnull)
|
| Method Summary | |
BooleanDataValue |
and(BooleanDataValue otherValue)
The AND operator. |
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. |
boolean |
equals(boolean val)
Determine whether this SQLBoolean contains the given boolean value. |
BooleanDataValue |
equals(DataValueDescriptor left,
DataValueDescriptor right)
The = operator as called from the language module, as opposed to the storage module. |
int |
estimateMemoryUsage()
Estimate the memory usage in bytes of the data value and the overhead of the class. |
static SQLBoolean |
falseTruthValue()
Return a false truth value. |
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. |
DataValueDescriptor |
getClone()
Clone this DataValueDescriptor. |
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.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 |
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. |
int |
hashCode()
|
BooleanDataValue |
is(BooleanDataValue otherValue)
The SQL IS operator - consult any standard SQL reference for an explanation. |
BooleanDataValue |
isNot(BooleanDataValue otherValue)
Implements NOT IS. |
boolean |
isNull()
Return whether the value is null or not. |
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. |
private static int |
makeInt(boolean b)
|
BooleanDataValue |
notEquals(DataValueDescriptor left,
DataValueDescriptor right)
The <> operator as called from the language module, as opposed to the storage module. |
BooleanDataValue |
or(BooleanDataValue otherValue)
The OR operator. |
void |
readExternal(java.io.ObjectInput in)
|
void |
readExternalFromArray(ArrayInputStream in)
Read the DataValueDescriptor from the stream. |
void |
restoreToNull()
Restore this object to its (SQL)null value. |
void |
setBigDecimal(java.lang.Number bigDecimal)
Set this value from an application supplied java.math.BigDecimal. |
protected void |
setFrom(DataValueDescriptor theValue)
|
void |
setInto(java.sql.PreparedStatement ps,
int position)
Set the value into a PreparedStatement. |
void |
setValue(boolean theValue)
Set the value. |
void |
setValue(java.lang.Boolean theValue)
Set the value of this BooleanDataValue. |
void |
setValue(byte theValue)
Set the value of this DataValueDescriptor to the given byte value |
void |
setValue(byte[] theValue)
Set the value of this BooleanDataValue to the given byte array value |
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(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 BooleanDataValue to the given String. |
private void |
setValueCore(java.lang.Number theValue)
|
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. |
BooleanDataValue |
throwExceptionIfFalse(java.lang.String sqlState,
java.lang.String tableName,
java.lang.String constraintName)
Throw an exception with the given SQLState if this BooleanDataValue is false. |
java.lang.String |
toString()
|
static SQLBoolean |
trueTruthValue()
Return a true truth value. |
static SQLBoolean |
truthValue(boolean value)
Get a truth value. |
static SQLBoolean |
truthValue(DataValueDescriptor leftOperand,
DataValueDescriptor rightOperand,
boolean truth)
Return the SQL truth value for a comparison. |
static SQLBoolean |
truthValue(DataValueDescriptor leftOperand,
DataValueDescriptor rightOperand,
java.lang.Boolean truth)
same as above, but takes a Boolean, if it is null, unknownTruthValue is returned |
int |
typePrecedence()
Each built-in type in JSQL has a precedence. |
int |
typeToBigDecimal()
Implementation for BOOLEAN type. |
static SQLBoolean |
unknownTruthValue()
Return an unknown truth value. |
void |
writeExternal(java.io.ObjectOutput out)
|
| Methods inherited from class org.apache.derby.iapi.types.DataType |
checkHostVariable, cloneObject, coalesce, dataTypeConversion, equals, flip, genericSetObject, getBytes, getDate, getNationalString, getStream, getTime, getTimestamp, in, invalidFormat, isNotNull, isNullOp, normalize, outOfRange, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatch |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor |
checkHostVariable, coalesce, getBytes, getDate, getStream, getTime, getTimestamp, in, isNotNull, isNullOp, normalize, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue |
| Field Detail |
static final int BOOLEAN_LENGTH
private static final SQLBoolean BOOLEAN_TRUE
private static final SQLBoolean BOOLEAN_FALSE
static final SQLBoolean UNKNOWN
private static final int BASE_MEMORY_USAGE
protected boolean value
protected boolean isnull
protected boolean immutable
| Constructor Detail |
public SQLBoolean()
public SQLBoolean(boolean val)
public SQLBoolean(java.lang.Boolean obj)
private SQLBoolean(boolean val,
boolean isnull)
| Method Detail |
public boolean isNull()
Storable
isNull in interface Storablepublic boolean getBoolean()
DataValueDescriptor
getBoolean in interface BooleanDataValuegetBoolean in class DataTypeprivate static int makeInt(boolean b)
public byte getByte()
DataValueDescriptor
getByte in interface DataValueDescriptorgetByte in class DataTypeDataValueDescriptor.getByte()public short getShort()
DataValueDescriptor
getShort in interface DataValueDescriptorgetShort in class DataTypeDataValueDescriptor.getShort()public int getInt()
DataValueDescriptor
getInt in interface DataValueDescriptorgetInt in class DataTypeDataValueDescriptor.getInt()public long getLong()
DataValueDescriptor
getLong in interface DataValueDescriptorgetLong in class DataTypeDataValueDescriptor.getLong()public float getFloat()
DataValueDescriptor
getFloat in interface DataValueDescriptorgetFloat in class DataTypeDataValueDescriptor.getFloat()public double getDouble()
DataValueDescriptor
getDouble in interface DataValueDescriptorgetDouble in class DataTypeDataValueDescriptor.getDouble()public int typeToBigDecimal()
typeToBigDecimal in interface DataValueDescriptortypeToBigDecimal in class DataTypepublic java.lang.String getString()
DataValueDescriptor
getString in interface DataValueDescriptorpublic java.lang.Object getObject()
DataValueDescriptor
getObject in interface DataValueDescriptorgetObject in class DataTypepublic int getLength()
DataValueDescriptor
getLength in interface DataValueDescriptorpublic java.lang.String getTypeName()
DataValueDescriptor
getTypeName in interface DataValueDescriptorpublic int getTypeFormatId()
getTypeFormatId in interface TypedFormatTypedFormat.getTypeFormatId()
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException
readExternal in interface java.io.Externalizablejava.io.IOExceptionExternalizable.readExternal(java.io.ObjectInput)
public void readExternalFromArray(ArrayInputStream in)
throws java.io.IOException
DataValueDescriptorInitialize 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().
readExternalFromArray in interface DataValueDescriptorin - The array stream positioned at the beginning of the
byte stream to read from.
java.io.IOException - Usual error is if you try to read
past limit on the stream.public void restoreToNull()
Storable
restoreToNull in interface StorableStorable.restoreToNull()
public int compare(DataValueDescriptor other)
throws StandardException
DataValueDescriptor
compare in interface DataValueDescriptorother - The Orderable to compare this one to.
StandardException - thrown on error
public boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
throws StandardException
DataValueDescriptor
compare in interface DataValueDescriptorcompare in class DataTypeStandardException - thrown on errorpublic DataValueDescriptor getClone()
DataValueDescriptor
getClone in interface DataValueDescriptorDataValueDescriptor.getClone()public DataValueDescriptor getNewNull()
DataValueDescriptor
getNewNull in interface DataValueDescriptorDataValueDescriptor.getNewNull()
public void setValueFromResultSet(java.sql.ResultSet resultSet,
int colNumber,
boolean isNullable)
throws java.sql.SQLException
DataValueDescriptor
setValueFromResultSet in interface DataValueDescriptorresultSet - The specified ResultSet.colNumber - The 1-based column # into the resultSet.isNullable - Whether or not the column is nullable
(No need to call wasNull() if not)
java.sql.SQLException - Thrown on errorDataValueDescriptor.setValueFromResultSet(java.sql.ResultSet, int, boolean)
public final void setInto(java.sql.PreparedStatement ps,
int position)
throws java.sql.SQLException
setInto in interface DataValueDescriptorsetInto in class DataTypejava.sql.SQLException - Error setting value in PreparedStatementpublic void setValue(boolean theValue)
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - Contains the boolean value to set this to
BooleanDataValue.setValue(java.lang.Boolean)public void setValue(java.lang.Boolean theValue)
BooleanDataValue
setValue in interface BooleanDataValuetheValue - Contains the boolean value to set this BooleanDataValue
to. Null means set this BooleanDataValue to null.
public void setValue(byte theValue)
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
public void setValue(short theValue)
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
public void setValue(int theValue)
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
public void setValue(long theValue)
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
public void setValue(float theValue)
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
public void setValue(double theValue)
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor to
public void setBigDecimal(java.lang.Number bigDecimal)
throws StandardException
DataValueDescriptor
setBigDecimal in interface DataValueDescriptorsetBigDecimal in class DataTypeStandardExceptionpublic void setValue(byte[] theValue)
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this BooleanDataValue to
public void setValue(java.lang.String theValue)
throws StandardException
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this BooleanDataValue to
StandardException - Thrown on errorprivate void setValueCore(java.lang.Number theValue)
public void setValue(java.lang.Object theValue)
throws StandardException
DataValueDescriptor
setValue in interface DataValueDescriptorsetValue in class DataTypeStandardExceptionDataValueDescriptor.setValue(java.lang.Object)
protected void setFrom(DataValueDescriptor theValue)
throws StandardException
setFrom in class DataTypeStandardException
public BooleanDataValue equals(DataValueDescriptor left,
DataValueDescriptor right)
throws StandardException
equals in interface DataValueDescriptorequals in class DataTypeleft - The value on the left side of the =right - The value on the right side of the =
StandardException - Thrown on error
public BooleanDataValue notEquals(DataValueDescriptor left,
DataValueDescriptor right)
throws StandardException
notEquals in interface DataValueDescriptornotEquals in class DataTypeleft - The value on the left side of the <>right - The value on the right side of the <>
StandardException - Thrown on error
public BooleanDataValue lessThan(DataValueDescriptor left,
DataValueDescriptor right)
throws StandardException
lessThan in interface DataValueDescriptorlessThan in class DataTypeleft - The value on the left side of the <right - The value on the right side of the <
StandardException - Thrown on error
public BooleanDataValue greaterThan(DataValueDescriptor left,
DataValueDescriptor right)
throws StandardException
greaterThan in interface DataValueDescriptorgreaterThan in class DataTypeleft - The value on the left side of the >right - The value on the right side of the >
StandardException - Thrown on error
public BooleanDataValue lessOrEquals(DataValueDescriptor left,
DataValueDescriptor right)
throws StandardException
lessOrEquals in interface DataValueDescriptorlessOrEquals in class DataTypeleft - The value on the left side of the <=right - The value on the right side of the <=
StandardException - Thrown on error
public BooleanDataValue greaterOrEquals(DataValueDescriptor left,
DataValueDescriptor right)
throws StandardException
greaterOrEquals in interface DataValueDescriptorgreaterOrEquals in class DataTypeleft - The value on the left side of the >=right - The value on the right side of the >=
StandardException - Thrown on errorpublic BooleanDataValue and(BooleanDataValue otherValue)
and in interface BooleanDataValueotherValue - The other boolean to AND with this one
public BooleanDataValue or(BooleanDataValue otherValue)
or in interface BooleanDataValueotherValue - The other boolean to OR with this one
public BooleanDataValue is(BooleanDataValue otherValue)
is in interface BooleanDataValueotherValue - BooleanDataValue to compare to. May be TRUE, FALSE, or UNKNOWN.
public BooleanDataValue isNot(BooleanDataValue otherValue)
isNot in interface BooleanDataValueotherValue - BooleanDataValue to compare to. May be TRUE, FALSE, or UNKNOWN.
public BooleanDataValue throwExceptionIfFalse(java.lang.String sqlState,
java.lang.String tableName,
java.lang.String constraintName)
throws StandardException
throwExceptionIfFalse in interface BooleanDataValuetableName - The name of the table to include in the exception
message.constraintName - The name of the failed constraint to include
in the exception message.sqlState - The SQLState of the exception to throw if
this SQLBoolean is false.
StandardException - Thrown if this BooleanDataValue
is false.public int typePrecedence()
DataValueDescriptor
typePrecedence in interface DataValueDescriptortypePrecedence in class DataTypeDataValueDescriptor.typePrecedence()
public static SQLBoolean truthValue(DataValueDescriptor leftOperand,
DataValueDescriptor rightOperand,
boolean truth)
leftOperand - The left operand of the binary comparisonrightOperand - The right operand of the binary comparisontruth - The truth value of the comparison
public static SQLBoolean truthValue(DataValueDescriptor leftOperand,
DataValueDescriptor rightOperand,
java.lang.Boolean truth)
public static SQLBoolean truthValue(boolean value)
value - The value of the SQLBoolean
public static SQLBoolean unknownTruthValue()
public static SQLBoolean falseTruthValue()
public static SQLBoolean trueTruthValue()
public boolean equals(boolean val)
equals in interface BooleanDataValueval - The value to look for
public java.lang.String toString()
public int hashCode()
public int estimateMemoryUsage()
DataValueDescriptor
estimateMemoryUsage in interface DataValueDescriptor
|
Built on Tue 2006-10-10 19:23:47+0200, from revision exported | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||