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

public final Class SQLReal

extends NumberDataType
Class Inheritance
Imports
org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.io.Storable, .StoredFormatIds, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.cache.ClassSize, java.io.ObjectOutput, .ObjectInput, .IOException, java.math.BigDecimal, java.sql.ResultSet, .PreparedStatement, .SQLException

SQLReal satisfies the DataValueDescriptor interfaces (i.e., OrderableDataType). It implements a real 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 OrderableDataType is a subtype of ValueColumn, SQLReal can play a role in either a ValueColumn/Row or a OrderableDataType/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 Float more than it probably wants to.

This is called SQLReal even though it maps to the Java float type, to avoid confusion with whether it maps to the SQL float type or not. It doesn't, it maps to the SQL real type.

This is modeled after SQLSmallint.

See Also
SQLSmallint

Field Summary

Modifier and TypeField and Description
private static final int
private boolean
pack-priv static final int
private float
Inherited from org.apache.derby.iapi.types.NumberDataType:
MAXLONG_PLUS_ONEMINLONG_MINUS_ONE

Constructor Summary

AccessConstructor and Description
public
SQLReal()

no-arg constructor, required by Formattable.

public
SQLReal(float val)

public

Method Summary

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

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

Clone this DataValueDescriptor.

public NumberDataValue

Returns:

A SQLReal containing the result of the division
divide
(NumberDataValue
The numerator
dividend
,
NumberDataValue
The denominator
divisor
,
NumberDataValue
The result of a previous call to this method, null if not called yet
result
)

Overrides org.apache.derby.iapi.types.NumberDataType.divide.

Implements org.apache.derby.iapi.types.NumberDataValue.divide.

This method implements the / operator for "real / real".

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 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
getBoolean()

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

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

Gets the value in the data value descriptor as a 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 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 first operand is greater than or equal to the second 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 first operand is greater than the second 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.

protected boolean

Returns:

A boolean. If this.value is negative, return true. For positive values or null, return false.
isNegative
()

Implements abstract org.apache.derby.iapi.types.NumberDataType.isNegative.

This method implements the isNegative method.

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 first operand is less than or equal to the second 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 first operand is less than the second 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.

public NumberDataValue

Returns:

A SQLReal containing the result of the subtraction
minus
(NumberDataValue
The value to be subtracted from
left
,
NumberDataValue
The value to be subtracted
right
,
NumberDataValue
The result of a previous call to this method, null if not called yet
result
)

Overrides org.apache.derby.iapi.types.NumberDataType.minus.

Implements org.apache.derby.iapi.types.NumberDataValue.minus.

This method implements the - operator for "real - real".

public NumberDataValue

Returns:

A SQLSmalllint containing the result of the division
minus
(NumberDataValue
The result of a previous call to this method, null if not called yet
result
)

Implements org.apache.derby.iapi.types.NumberDataValue.minus.

This method implements the unary minus operator for real.

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 NumberDataValue

Returns:

A SQLReal containing the result of the addition
plus
(NumberDataValue
One of the addends
addend1
,
NumberDataValue
The other addend
addend2
,
NumberDataValue
The result of a previous call to this method, null if not called yet
result
)

Overrides org.apache.derby.iapi.types.NumberDataType.plus.

Implements org.apache.derby.iapi.types.NumberDataValue.plus.

This method implements the + operator for "real + real".

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

Implements java.io.Externalizable.readExternal.

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

public void
restoreToNull()

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

Restore this object to its (SQL)null value.

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

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

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

Called for an application setting this value using a 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.

public final void
setInto(ResultSet rs, int position)

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

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

Set this value into a ResultSet for a subsequent ResultSet.insertRow or ResultSet.updateRow.

pack-priv void
setObject(Object theValue)

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

Set the value from a correctly typed Float object.

public void
setValue(String
The String 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.

public void
setValue(Number
An Number containing the value to set this NumberDataValue to. Null means set the value to SQL null.
theValue
)

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

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

Common code to handle java.lang.Integer as a Number, used for TINYINT, SMALLINT, INTEGER

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(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(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(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
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 NumberDataValue

Returns:

A SQLReal containing the result of the multiplication
times
(NumberDataValue
The first value to be multiplied
left
,
NumberDataValue
The second value to be multiplied
right
,
NumberDataValue
The result of a previous call to this method, null if not called yet
result
)

Implements org.apache.derby.iapi.types.NumberDataValue.times.

This method implements the * operator for "real * real".

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected int
typeCompare(DataValueDescriptor arg)

Implements abstract org.apache.derby.iapi.types.NumberDataType.typeCompare.

Compare this (not null) to a non-null value.

public int
public int
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.NumberDataType:
absolutecomparecomparedividemodnormalizeDOUBLEnormalizeREALnormalizeREALobjectNullsetValuesetValuesqrt