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

public final Class SQLBoolean

extends DataType
implements BooleanDataValue
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.types.BooleanDataValue, 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.sanity.SanityManager, org.apache.derby.iapi.services.io.Storable, .StoredFormatIds, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.cache.ClassSize, org.apache.derby.iapi.util.StringUtil, java.io.ObjectOutput, .ObjectInput, .IOException, java.math.BigDecimal, java.sql.ResultSet, .PreparedStatement, .SQLException, org.apache.derby.catalog.UUID, org.apache.derby.iapi.sql.Activation, .Row, org.apache.derby.iapi.sql.conn.LanguageConnectionContext, org.apache.derby.iapi.sql.execute.ExecPreparedStatement, org.apache.derby.impl.sql.execute.DMLWriteResultSet

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

Modifier and TypeField and Description
private static final int
private static final SQLBoolean
pack-priv static final int
private static final SQLBoolean
private boolean
private boolean
pack-priv static final SQLBoolean
private boolean

Constructor Summary

AccessConstructor and Description
public
public
SQLBoolean(boolean val)

public
private
SQLBoolean(boolean val, boolean isnull)

Method Summary

Modifier and TypeMethod and Description
public BooleanDataValue

Returns:

this AND otherValue
and
(BooleanDataValue
The other boolean to AND with this one
otherValue
)

Implements org.apache.derby.iapi.types.BooleanDataValue.and.

The AND operator.

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

Returns:

A SQL boolean value telling whether the two parameters are equal
equals
(DataValueDescriptor
The value on the left side of the =
left
,
DataValueDescriptor
The value on the right side of the =
right
)

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

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

The = operator as called from the language module, as opposed to the storage module.

public boolean

Returns:

true if the given value equals the value in this SQLBoolean, false if not
equals
(boolean
The value to look for
val
)

Implements org.apache.derby.iapi.types.BooleanDataValue.equals.

Determine whether this SQLBoolean contains the given boolean value.

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 boolean
public byte
getByte()

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

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

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

public double
getDouble()

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

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

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

public float
getFloat()

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

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

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

public BooleanDataValue

Returns:

An immutable BooleanDataValue with the same value as this.
getImmutable
()

Implements org.apache.derby.iapi.types.BooleanDataValue.getImmutable.

Return an immutable BooleanDataValue with the same value as this.

public int
getInt()

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

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

Gets the value in the data value descriptor as an int.

public int
getLength()

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

Gets the length of the data value.

public long
getLong()

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

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

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

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 short
getShort()

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

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

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

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 BooleanDataValue

Returns:

A SQL boolean value telling whether the left operand is greater than or equal to the right operand
greaterOrEquals
(DataValueDescriptor
The value on the left side of the operator
left
,
DataValueDescriptor
The value on the right side of the operator
right
)

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

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

The >= operator as called from the language module, as opposed to the storage module.

public BooleanDataValue

Returns:

A SQL boolean value telling whether the left operand is greater than the right operand
greaterThan
(DataValueDescriptor
The value on the left side of the operator
left
,
DataValueDescriptor
The value on the right side of the operator
right
)

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

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

The > operator as called from the language module, as opposed to the storage module.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public BooleanDataValue

Returns:

whether this IS otherValue
is
(BooleanDataValue
BooleanDataValue to compare to. May be TRUE, FALSE, or UNKNOWN.
otherValue
)

Implements org.apache.derby.iapi.types.BooleanDataValue.is.

The SQL IS operator - consult any standard SQL reference for an explanation.

public BooleanDataValue

Returns:

NOT( this IS otherValue )
isNot
(BooleanDataValue
BooleanDataValue to compare to. May be TRUE, FALSE, or UNKNOWN.
otherValue
)

Implements org.apache.derby.iapi.types.BooleanDataValue.isNot.

Implements NOT IS.

public boolean
isNull()

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

Return whether the value is null or not.

public BooleanDataValue

Returns:

A SQL boolean value telling whether the left operand is less than or equal to the right operand
lessOrEquals
(DataValueDescriptor
The value on the left side of the operator
left
,
DataValueDescriptor
The value on the right side of the operator
right
)

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

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

The <= operator as called from the language module, as opposed to the storage module.

public BooleanDataValue

Returns:

A SQL boolean value telling whether the left operand is less than the right operand
lessThan
(DataValueDescriptor
The value on the left side of the operator
left
,
DataValueDescriptor
The value on the right side of the operator
right
)

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

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

The < operator as called from the language module, as opposed to the storage module.

private static int
makeInt(boolean b)

public BooleanDataValue

Returns:

A SQL boolean value telling whether the two parameters are not equal
notEquals
(DataValueDescriptor
The value on the left side of the operator
left
,
DataValueDescriptor
The value on the right side of the operator
right
)

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

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

The <> operator as called from the language module, as opposed to the storage module.

public BooleanDataValue

Returns:

this OR otherValue
or
(BooleanDataValue
The other boolean to OR with this one
otherValue
)

Implements org.apache.derby.iapi.types.BooleanDataValue.or.

The OR operator.

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 DataValueDescriptor

Returns:

a new SQLBoolean if this object is immutable; otherwise, this object with value set to null
recycle
()

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

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

Recycle this SQLBoolean object if possible.

public void
restoreToNull()

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

Restore this object to its (SQL)null value.

public void
setBigDecimal(BigDecimal
required to be a BigDecimal or null.
bigDecimal
)

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

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

Set this value from an application supplied java.math.BigDecimal.

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 final void
setInto(PreparedStatement ps, int position)

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

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

Set the value into a PreparedStatement.

pack-priv void
setObject(Object theValue)

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

Set the value from an non-null object.

public void
setValue(boolean
Contains the boolean value to set this to
theValue
)

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

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

Set the value.

public void
setValue(Boolean
Contains the boolean value to set this BooleanDataValue to. Null means set this BooleanDataValue to null.
theValue
)

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

Set the value of this BooleanDataValue.

public void
setValue(byte
The value to set this DataValueDescriptor to
theValue
)

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

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

Set the value of this DataValueDescriptor to the given byte value

public void
setValue(short
The value to set this DataValueDescriptor to
theValue
)

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

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

Set the value of this DataValueDescriptor to the given short value

public void
setValue(int
The value to set this DataValueDescriptor to
theValue
)

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

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

Set the value of this DataValueDescriptor to the given int value

public void
setValue(long
The value to set this DataValueDescriptor to
theValue
)

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

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

Set the value of this DataValueDescriptor to the given long value

public void
setValue(float
A Double containing the value to set this DataValueDescriptor to. Null means set the value to SQL null.
theValue
)

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

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

Set the value of this DataValueDescriptor to the given double value

public void
setValue(double
The value to set this DataValueDescriptor to
theValue
)

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

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

Set the value of this DataValueDescriptor to the given double value

public void
setValue(String
The value to set this BooleanDataValue to
theValue
)

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

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

Set the value of this BooleanDataValue to the given String.

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 BooleanDataValue

Returns:

this
throwExceptionIfFalse
(String
The SQLState of the exception to throw if this SQLBoolean is false.
sqlState
,
String
The name of the table to include in the exception message.
tableName
,
String
The name of the failed constraint to include in the exception message.
constraintName
)

Implements org.apache.derby.iapi.types.BooleanDataValue.throwExceptionIfFalse.

Throw an exception with the given SQLState if this BooleanDataValue is false.

public BooleanDataValue
throwExceptionIfImmediateAndFalse(String
The SQLState of the exception to throw if this SQLBoolean is false.
sqlState
,
String
The name of the table to include in the exception message.
tableName
,
String
The name of the failed constraint to include in the exception message.
constraintName
,
Activation
The activation
a
,
int
The saved object number of the constraint's UUID.
savedUUIDIdx
)

Implements org.apache.derby.iapi.types.BooleanDataValue.throwExceptionIfImmediateAndFalse.

If this value is false and we have a deferred constraint, remember the violation and proceed, else throw.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public static SQLBoolean

Returns:

A SQLBoolean containing the desired truth value.
truthValue
(DataValueDescriptor
The left operand of the binary comparison
leftOperand
,
DataValueDescriptor
The right operand of the binary comparison
rightOperand
,
boolean
The truth value of the comparison
truth
)

Return the SQL truth value for a comparison.

public static SQLBoolean
truthValue(DataValueDescriptor leftOperand, DataValueDescriptor rightOperand, Boolean truth)

same as above, but takes a Boolean, if it is null, unknownTruthValue is returned

public static SQLBoolean

Returns:

A SQLBoolean with the given truth value
truthValue
(boolean
The value of the SQLBoolean
value
)

Get a truth value.

public int
public int
public static SQLBoolean

Returns:

A SQLBoolean representing the UNKNOWN truth value
unknownTruthValue
()

Return an unknown truth value.

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