public class NumericType extends java.lang.Object implements DataHandler
Constructor and Description |
---|
NumericType() |
Modifier and Type | Method and Description |
---|---|
NumberType |
convert(java.lang.Object sqlVal)
Creates and returns a new
NumberType from a SQL counterpart. |
BaseDataType |
getField(Record r,
int offset)
Obtain the value of the property of a
Record located at a specified offset in data
array. |
int |
getFieldSizeInIndex(java.lang.Object val)
Compute the size in bytes taken by a specified value for the data type handled by this
class.
|
int |
readProperty(java.sql.ResultSet rs,
int rsOffset,
java.lang.Object[] data,
int propIndex)
Does nothing, this method should not be called.
|
void |
setField(java.lang.Object[] data,
BaseDataType val,
int offset,
PropertyMeta meta)
Sets a value of a property in a
Record . |
int |
setParameter(java.sql.PreparedStatement stmt,
int index,
java.lang.Object val)
Use the the data from a
character field stored in BaseRecord.data and use it
to initialize a parameter of type a known numerical type in a SQL prepared query. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initialValue
public NumberType convert(java.lang.Object sqlVal)
NumberType
from a SQL counterpart. The evaluation is
dynamic in the sense that the returned result depends on the sqlVal
and is not
assumed to be a specific type as for other specific numeric types.convert
in interface DataHandler
sqlVal
- A value obtained from a SQL query, which needs to be converted to a
BaseDataType
.NumberType
object representing the same value as sqlVal
.public int readProperty(java.sql.ResultSet rs, int rsOffset, java.lang.Object[] data, int propIndex) throws java.sql.SQLException
readProperty
in interface PropertyReader
rs
- The ResultSet
to read from.rsOffset
- The index/position in current row of rs
to start reading.data
- The destination. Ie. the record's data
field member.propIndex
- The destination offset. Ie. the property index.java.lang.UnsupportedOperationException
- Always as this operation is not supported.java.sql.SQLException
- when an error is encountered while setting the value.public int setParameter(java.sql.PreparedStatement stmt, int index, java.lang.Object val) throws java.sql.SQLException
character
field stored in BaseRecord.data
and use it
to initialize a parameter of type a known numerical type in a SQL prepared query.setParameter
in interface ParameterSetter
stmt
- The prepared statement whose the parameter is to be set.index
- The index/position of the parameter.val
- The value of the parameter. Must be a decimal
.java.sql.SQLException
- when an error is encountered while setting the value.public int getFieldSizeInIndex(java.lang.Object val)
getFieldSizeInIndex
in interface DataHandler
val
- The value to be computed the size.val
object occupies.public void setField(java.lang.Object[] data, BaseDataType val, int offset, PropertyMeta meta)
Record
. The specified value is converted from
BaseDataType
FWD standard to plain Java, as the data
array expects before
assigning the value to right offset.setField
in interface DataHandler
data
- The data
array of the record to be altered.val
- The BaseDataType
value to be set.offset
- The offset of the property, ie, the entry in data
array. This includes both
base property offset and the eventual extent index.meta
- Property metadata. Used to fine-tune stored data.public BaseDataType getField(Record r, int offset)
Record
located at a specified offset in data
array. It assumes the data at specified offset is compatible with this data handler.getField
in interface DataHandler
r
- The Record
.offset
- The offset.BaseDataType
.