public final class SQLBoolean extends DataType implements BooleanDataValue
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.
| Modifier and Type | Field and Description |
|---|---|
private static int |
BASE_MEMORY_USAGE |
private static SQLBoolean |
BOOLEAN_FALSE |
(package private) static int |
BOOLEAN_LENGTH |
private static SQLBoolean |
BOOLEAN_TRUE |
private boolean |
immutable |
private boolean |
isnull |
(package private) static SQLBoolean |
UNKNOWN |
private boolean |
value |
UNKNOWN_LOGICAL_LENGTHORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN| Modifier | Constructor and Description |
|---|---|
|
SQLBoolean() |
|
SQLBoolean(boolean val) |
|
SQLBoolean(java.lang.Boolean obj) |
private |
SQLBoolean(boolean val,
boolean isnull) |
| Modifier and Type | Method and Description |
|---|---|
BooleanDataValue |
and(BooleanDataValue otherValue)
The AND operator.
|
DataValueDescriptor |
cloneValue(boolean forceMaterialization)
Clone this DataValueDescriptor.
|
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.
|
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.
|
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.
|
BooleanDataValue |
getImmutable()
Return an immutable BooleanDataValue with the same value as this.
|
int |
getInt()
Gets the value in the data value descriptor as a 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 int.
|
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) |
DataValueDescriptor |
recycle()
Recycle this SQLBoolean object if possible.
|
void |
restoreToNull()
Restore this object to its (SQL)null value.
|
void |
setBigDecimal(java.lang.Number bigDecimal)
Only to be called when the application sets a value using BigDecimal
|
protected void |
setFrom(DataValueDescriptor theValue)
Set the value of this DataValueDescriptor based on the value
of the specified DataValueDescriptor.
|
void |
setInto(java.sql.PreparedStatement ps,
int position)
Set the value into a PreparedStatement.
|
(package private) void |
setObject(java.lang.Object theValue)
Set the value from an non-null object.
|
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
At DataType level just throws an error lower classes will override
|
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(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(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 BooleanDataValue to the given String.
|
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 |
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) |
checkHostVariable, cloneHolder, coalesce, compare, compare, compareTo, dataTypeConversion, equals, flip, genericSetObject, getBytes, getDate, getStream, getTime, getTimestamp, getTraceString, getTypeName, hasStream, in, invalidFormat, isNotNull, isNullOp, normalize, outOfRange, readExternalFromArray, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, throwLangSetMismatchclone, finalize, getClass, notify, notifyAll, wait, wait, waitcheckHostVariable, cloneHolder, coalesce, compare, compare, getBytes, getDate, getStream, getTime, getTimestamp, getTraceString, hasStream, in, isNotNull, isNullOp, normalize, readExternalFromArray, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValuestatic 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
private boolean value
private boolean isnull
private boolean immutable
public SQLBoolean()
public SQLBoolean(boolean val)
public SQLBoolean(java.lang.Boolean obj)
private SQLBoolean(boolean val,
boolean isnull)
public boolean isNull()
Storablepublic boolean getBoolean()
DataTypegetBoolean in interface BooleanDataValuegetBoolean in interface DataValueDescriptorgetBoolean in class DataTypeprivate static int makeInt(boolean b)
public byte getByte()
DataTypegetByte in interface DataValueDescriptorgetByte in class DataTypeDataValueDescriptor.getByte()public short getShort()
DataTypegetShort in interface DataValueDescriptorgetShort in class DataTypeDataValueDescriptor.getShort()public int getInt()
DataTypegetInt in interface DataValueDescriptorgetInt in class DataTypeDataValueDescriptor.getInt()public long getLong()
DataTypegetLong in interface DataValueDescriptorgetLong in class DataTypeDataValueDescriptor.getLong()public float getFloat()
DataTypegetFloat in interface DataValueDescriptorgetFloat in class DataTypeDataValueDescriptor.getFloat()public double getDouble()
DataTypegetDouble in interface DataValueDescriptorgetDouble in class DataTypeDataValueDescriptor.getDouble()public int typeToBigDecimal()
typeToBigDecimal in interface DataValueDescriptortypeToBigDecimal in class DataTypepublic java.lang.String getString()
DataValueDescriptorgetString in interface DataValueDescriptorpublic java.lang.Object getObject()
DataTypegetObject in interface DataValueDescriptorgetObject in class DataTypepublic int getLength()
DataValueDescriptorgetLength in interface DataValueDescriptorpublic java.lang.String getTypeName()
DataValueDescriptorgetTypeName in interface DataValueDescriptorpublic DataValueDescriptor recycle()
recycle in interface DataValueDescriptorrecycle in class DataTypepublic 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.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException
readExternal in interface java.io.Externalizablejava.io.IOExceptionExternalizable.readExternal(java.io.ObjectInput)public void restoreToNull()
StorablerestoreToNull in interface StorableStorable.restoreToNull()public int compare(DataValueDescriptor other) throws StandardException
DataValueDescriptorcompare in interface DataValueDescriptorother - The Orderable to compare this one to.StandardException - thrown on errorpublic boolean compare(int op,
DataValueDescriptor other,
boolean orderedNulls,
boolean unknownRV)
throws StandardException
DataValueDescriptorcompare in interface DataValueDescriptorcompare in class DataTypeop - 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.StandardException - thrown on errorpublic DataValueDescriptor cloneValue(boolean forceMaterialization)
DataValueDescriptor
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.
cloneValue in interface DataValueDescriptorforceMaterialization - any streams representing the data value will
be materialized if true, the data value will be kept as a
stream if possible if falseDataValueDescriptor with the same initial
value as this.DataValueDescriptor.cloneValue(boolean)public DataValueDescriptor getNewNull()
DataValueDescriptorgetNewNull in interface DataValueDescriptorDataValueDescriptor.getNewNull()public void setValueFromResultSet(java.sql.ResultSet resultSet,
int colNumber,
boolean isNullable)
throws java.sql.SQLException
DataValueDescriptorsetValueFromResultSet 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)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - Contains the boolean value to set this toBooleanDataValue.setValue(java.lang.Boolean)public void setValue(java.lang.Boolean theValue)
BooleanDataValuesetValue in interface BooleanDataValuetheValue - Contains the boolean value to set this BooleanDataValue
to. Null means set this BooleanDataValue to null.public void setValue(byte theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor topublic void setValue(short theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor topublic void setValue(int theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor topublic void setValue(long theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor topublic void setValue(float theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor topublic void setValue(double theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor topublic void setBigDecimal(java.lang.Number bigDecimal)
throws StandardException
DataTypesetBigDecimal in interface DataValueDescriptorsetBigDecimal in class DataTypebigDecimal - required to be a BigDecimal or null.StandardExceptionpublic void setValue(java.lang.String theValue)
throws StandardException
setValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this BooleanDataValue toStandardException - Thrown on errorvoid setObject(java.lang.Object theValue)
DataTypesetObject in class DataTypeDataValueDescriptor.setValue(int)protected void setFrom(DataValueDescriptor theValue) throws StandardException
DataTypesetFrom in class DataTypetheValue - The DataValueDescriptor that holds the value to
which we want to set this DataValueDescriptor's value.StandardExceptionpublic 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 errorpublic 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 errorpublic 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 errorpublic 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 errorpublic 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 errorpublic 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 onepublic BooleanDataValue or(BooleanDataValue otherValue)
or in interface BooleanDataValueotherValue - The other boolean to OR with this onepublic 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 BooleanDataValuesqlState - The SQLState of the exception to throw if
this SQLBoolean is false.tableName - The name of the table to include in the exception
message.constraintName - The name of the failed constraint to include
in the exception message.StandardException - Thrown if this BooleanDataValue
is false.public int typePrecedence()
DataTypetypePrecedence 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 comparisonpublic static SQLBoolean truthValue(DataValueDescriptor leftOperand, DataValueDescriptor rightOperand, java.lang.Boolean truth)
public static SQLBoolean truthValue(boolean value)
value - The value of the SQLBooleanpublic static SQLBoolean unknownTruthValue()
public boolean equals(boolean val)
equals in interface BooleanDataValueval - The value to look forpublic BooleanDataValue getImmutable()
getImmutable in interface BooleanDataValuepublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int estimateMemoryUsage()
DataValueDescriptorestimateMemoryUsage in interface DataValueDescriptorApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.