public final class SQLSmallint extends NumberDataType
Because OrderableDataType is a subtype of ValueColumn, SQLSmallint 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 Short more than it probably wants to.
| Modifier and Type | Field and Description |
|---|---|
private static int |
BASE_MEMORY_USAGE |
private boolean |
isnull |
(package private) static int |
SMALLINT_LENGTH |
private short |
value |
MAXLONG_PLUS_ONE, MINLONG_MINUS_ONE, ONE, ZERO, ZERO_DECIMALMAX_DECIMAL_PRECISION_SCALE, MIN_DECIMAL_DIVIDE_SCALEUNKNOWN_LOGICAL_LENGTHORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN| Modifier | Constructor and Description |
|---|---|
|
SQLSmallint()
No-arg constructor, required by Formattable.
// This constructor also gets used when we are
// allocating space for a short.
|
|
SQLSmallint(short val) |
|
SQLSmallint(java.lang.Short obj) |
private |
SQLSmallint(short val,
boolean isnull) |
| Modifier and Type | Method and Description |
|---|---|
DataValueDescriptor |
cloneValue(boolean forceMaterialization)
Clone this DataValueDescriptor.
|
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.
|
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() |
protected boolean |
isNegative()
This method implements the isNegative method.
|
boolean |
isNull()
always false for non-nullable columns
|
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.
|
NumberDataValue |
minus(NumberDataValue result)
This method implements the unary minus operator for smallint.
|
NumberDataValue |
mod(NumberDataValue dividend,
NumberDataValue divisor,
NumberDataValue result)
mod(smallint, smallint)
|
BooleanDataValue |
notEquals(DataValueDescriptor left,
DataValueDescriptor right)
The <> operator as called from the language module, as opposed to
the storage module.
|
void |
readExternal(java.io.ObjectInput in) |
void |
restoreToNull()
Restore this object to its (SQL)null value.
|
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.
|
void |
setInto(java.sql.ResultSet rs,
int position)
Set this value into a ResultSet for a subsequent ResultSet.insertRow
or ResultSet.updateRow.
|
void |
setValue(boolean theValue)
Set the value.
|
void |
setValue(byte theValue)
Common code to handle converting a byte to this value
by using the int to this value conversion.
|
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)
Common code to handle converting a short to this value
by using the int to this value conversion.
|
void |
setValue(java.lang.String theValue)
Set the value of this DataValueDescriptor.
|
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.
|
NumberDataValue |
times(NumberDataValue left,
NumberDataValue right,
NumberDataValue result)
This method implements the * operator for "smallint * smallint".
|
java.lang.String |
toString() |
protected int |
typeCompare(DataValueDescriptor arg)
Compare this (not null) to a non-null value.
|
int |
typePrecedence()
Each built-in type in JSQL has a precedence.
|
void |
writeExternal(java.io.ObjectOutput out) |
absolute, compare, compare, divide, divide, getDecimalValuePrecision, getDecimalValueScale, minus, normalizeDOUBLE, normalizeREAL, normalizeREAL, objectNull, plus, setBigDecimal, setObject, setValue, sqrt, typeToBigDecimalcheckHostVariable, cloneHolder, coalesce, compare, compare, compareTo, dataTypeConversion, equals, flip, genericSetObject, getBytes, getDate, getStream, getTime, getTimestamp, getTraceString, getTypeName, hasStream, in, invalidFormat, isNotNull, isNullOp, normalize, outOfRange, readExternalFromArray, recycle, 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, recycle, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValuestatic final int SMALLINT_LENGTH
private static final int BASE_MEMORY_USAGE
private short value
private boolean isnull
public SQLSmallint()
public SQLSmallint(short val)
private SQLSmallint(short val,
boolean isnull)
public SQLSmallint(java.lang.Short obj)
public int getInt()
DataTypegetInt in interface DataValueDescriptorgetInt in class DataTypeDataValueDescriptor.getInt()public byte getByte()
throws StandardException
DataTypegetByte in interface DataValueDescriptorgetByte in class DataTypeStandardException - thrown on failure to convertDataValueDescriptor.getByte()public short getShort()
DataTypegetShort in interface DataValueDescriptorgetShort in class DataTypeDataValueDescriptor.getShort()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 boolean getBoolean()
DataTypegetBoolean in interface DataValueDescriptorgetBoolean in class DataTypeDataValueDescriptor.getBoolean()public java.lang.String getString()
DataValueDescriptorDataValueDescriptor.getString()public int getLength()
DataValueDescriptorDataValueDescriptor.getLength()public java.lang.Object getObject()
DataTypegetObject in interface DataValueDescriptorgetObject in class DataTypeDataValueDescriptor.getObject()public java.lang.String getTypeName()
DataValueDescriptorpublic int getTypeFormatId()
TypedFormat.getTypeFormatId()public boolean isNull()
Storable.isNull()public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
java.io.IOExceptionpublic void readExternal(java.io.ObjectInput in)
throws java.io.IOException
java.io.IOExceptionExternalizable.readExternal(java.io.ObjectInput)public void restoreToNull()
StorableStorable.restoreToNull()protected int typeCompare(DataValueDescriptor arg) throws StandardException
NumberDataTypetypeCompare in class NumberDataTypeStandardException - 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.
forceMaterialization - 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()
DataValueDescriptorDataValueDescriptor.getNewNull()public void setValueFromResultSet(java.sql.ResultSet resultSet,
int colNumber,
boolean isNullable)
throws java.sql.SQLException
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 final void setInto(java.sql.ResultSet rs,
int position)
throws java.sql.SQLException,
StandardException
setInto in interface DataValueDescriptorsetInto in class DataTypejava.sql.SQLException - thrown by the ResultSet objectStandardException - thrown by me accessing my value.public void setValue(java.lang.String theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The BigDecimal value to set this DataValueDescriptor toStandardException - thrown if string not acceptedpublic void setValue(short theValue)
NumberDataTypesetValue in interface DataValueDescriptorsetValue in class NumberDataTypetheValue - The value to set this DataValueDescriptor topublic void setValue(byte theValue)
NumberDataTypesetValue in interface DataValueDescriptorsetValue in class NumberDataTypetheValue - The value to set this DataValueDescriptor topublic void setValue(int theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - if outsideRangeForSmallintpublic void setValue(long theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - if outsideRangeForSmallintpublic void setValue(float theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorNumberDataValue.setValue(java.lang.Number)public void setValue(double theValue)
throws StandardException
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - The value to set this DataValueDescriptor toStandardException - Thrown on errorNumberDataValue.setValue(java.lang.Number)public void setValue(boolean theValue)
DataTypesetValue in interface DataValueDescriptorsetValue in class DataTypetheValue - Contains the boolean value to set this toNumberDataValue.setValue(java.lang.Number)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 int typePrecedence()
DataTypetypePrecedence in interface DataValueDescriptortypePrecedence in class DataTypeDataValueDescriptor.typePrecedence()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 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 <
is not.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 NumberDataValue times(NumberDataValue left, NumberDataValue right, NumberDataValue result) throws StandardException
left - The first value to be multipliedright - The second value to be multipliedresult - The result of a previous call to this method, null
if not called yetStandardException - Thrown on errorpublic NumberDataValue mod(NumberDataValue dividend, NumberDataValue divisor, NumberDataValue result) throws StandardException
mod in interface NumberDataValuemod in class NumberDataTypedividend - The numeratordivisor - The denominatorresult - The result of the previous call to this method, null
if not called yet.StandardException - Thrown on error, if result is non-null then its value will be unchanged.public NumberDataValue minus(NumberDataValue result) throws StandardException
result - The result of a previous call to this method, null
if not called yetStandardException - Thrown on errorprotected boolean isNegative()
isNegative in class NumberDataTypepublic java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int estimateMemoryUsage()
DataValueDescriptorApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.