public abstract class Datum
extends java.lang.Object
implements java.io.Serializable
Each subclass represents one of the native kernel datatypes.
In order to allow for possible optimization of data copying between SQL and Java, instances of subclasses are immutable.
| Modifier and Type | Field and Description |
|---|---|
protected oracle.jdbc.internal.OracleDatumWithConnection |
ojiOracleDatumWithConnection |
protected Datum |
targetDatum |
| Constructor and Description |
|---|
Datum()
Creates an empty datum
|
Datum(byte[] newData)
Create a new datum with the given byte array as representation.
|
| Modifier and Type | Method and Description |
|---|---|
java.io.InputStream |
asciiStreamValue()
Convert to an ascii stream representation of the datum object
|
java.math.BigDecimal |
bigDecimalValue()
Convert to a BigDecimal representation of the datum object
|
java.io.InputStream |
binaryStreamValue()
Convert to a binary stream representation of the datum object
|
boolean |
booleanValue()
Convert to a boolean representation of the datum object
|
protected boolean |
bytesEqual(Datum other) |
int |
bytesHashCode() |
byte |
byteValue()
Convert to a byte representation of the datum object
|
java.io.Reader |
characterStreamValue()
Convert to a character stream representation of the datum object
|
static int |
compareBytes(byte[] m,
byte[] n)
Do an unsigned compare on byte arrays m and n
|
java.sql.Date |
dateValue()
Convert to a Date representation of the datum object
|
double |
doubleValue()
Convert to a double representation of the datum object
|
boolean |
equals(java.lang.Object obj)
Test any object for equality with an Datum.
|
float |
floatValue()
Convert to a float representation of the datum object
|
byte[] |
getBytes()
Create a new Java byte array containing a copy of the RDBMS data.
|
protected oracle.jdbc.internal.OracleConnection |
getConnectionDuringExceptionHandling() |
long |
getLength()
Retrieve the length of this datum's binary representation.
|
java.io.InputStream |
getStream()
Create an input stream so the raw data may be read.
|
int |
intValue()
Convert to a integer representation of the datum object
|
abstract boolean |
isConvertibleTo(java.lang.Class<?> cls)
Determines if datum object can be converted to a particular class
|
boolean |
isNull()
Test if this Datum is empty
|
long |
longValue()
Convert to a long representation of the datum object
|
abstract java.lang.Object |
makeJdbcArray(int arraySize)
Returns a JDBC array representation of the datum
|
void |
setBytes(byte[] array)
Sets datum value using a byte array.
|
void |
setShareBytes(byte[] array)
Sets datum value using a byte array.
|
byte[] |
shareBytes()
Retrieve the data bytes.
|
java.lang.String |
stringValue()
Convert to a String representation of the datum object
|
java.lang.String |
stringValue(java.sql.Connection conn)
Some Datum subclass such as TIMESTAMPTZ will override
this default implementation which simply ignores the
the connection.
|
java.sql.Timestamp |
timestampValue()
Convert to a Timestamp representation of the datum object
|
java.sql.Timestamp |
timestampValue(java.util.Calendar cal) |
java.sql.Time |
timeValue()
Convert to a Time representation of the datum object
|
java.sql.Time |
timeValue(java.util.Calendar cal) |
<T> T |
toClass(java.lang.Class<T> type)
Convert this datum to an instance of the specified type if possible.
|
abstract java.lang.Object |
toJdbc()
Returns the JDBC representation of the datum object
|
protected Datum targetDatum
protected oracle.jdbc.internal.OracleDatumWithConnection ojiOracleDatumWithConnection
public Datum()
public Datum(byte[] newData)
data array.newData - byte array to be stored in the datumpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - object to compare this withthis is the same as the class of
obj and the byte representation of this is the
same as the byte representation of obj.public int bytesHashCode()
public byte[] shareBytes()
Used by java code in subclasses to access the data bytes. If the bytes are not yet a Java array, this may cause them to be copied into one.
public long getLength()
public void setBytes(byte[] array)
array - byte array used to set the datum valuepublic void setShareBytes(byte[] array)
array - byte array used to set the datum valuepublic byte[] getBytes()
For now, the data array is simply copied. When we are using moss to go directly to the buffer cache, this implementation will be overridden by a native method which will cons an array and copy the bytes into it.
Subclasses which handle very long datatypes which will not ordinarily be represented as Java array, should check for allocation failure and return nil if detected. They should however try to materialize the raw data no matter how long since users may actually need to materialize huge arrays.
public boolean isNull()
public java.io.InputStream getStream()
This is the normal way to access long datatypes.
public java.lang.String stringValue()
throws java.sql.SQLException
SQLException, - if no String representation existsjava.sql.SQLExceptionpublic java.lang.String stringValue(java.sql.Connection conn)
throws java.sql.SQLException
java.sql.SQLExceptionpublic boolean booleanValue()
throws java.sql.SQLException
SQLException, - if no boolean representation existsjava.sql.SQLExceptionpublic int intValue()
throws java.sql.SQLException
SQLException, - if no integer representation existsjava.sql.SQLExceptionpublic long longValue()
throws java.sql.SQLException
SQLException, - if no long representation existsjava.sql.SQLExceptionpublic float floatValue()
throws java.sql.SQLException
SQLException, - if no float representation existsjava.sql.SQLExceptionpublic double doubleValue()
throws java.sql.SQLException
SQLException, - if no double representation existsjava.sql.SQLExceptionpublic byte byteValue()
throws java.sql.SQLException
SQLException, - if no byte representation existsjava.sql.SQLExceptionpublic java.math.BigDecimal bigDecimalValue()
throws java.sql.SQLException
SQLException, - if no BigDecimal representation existsjava.sql.SQLExceptionpublic java.sql.Date dateValue()
throws java.sql.SQLException
SQLException, - if no Date representation existsjava.sql.SQLExceptionpublic java.sql.Time timeValue()
throws java.sql.SQLException
SQLException, - if no Time representation existsjava.sql.SQLExceptionpublic java.sql.Time timeValue(java.util.Calendar cal)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.sql.Timestamp timestampValue()
throws java.sql.SQLException
SQLException, - if no Timestamp representation existsjava.sql.SQLExceptionpublic java.sql.Timestamp timestampValue(java.util.Calendar cal)
throws java.sql.SQLException
java.sql.SQLExceptionpublic java.io.Reader characterStreamValue()
throws java.sql.SQLException
SQLException, - if no character stream representation existsjava.sql.SQLExceptionpublic java.io.InputStream asciiStreamValue()
throws java.sql.SQLException
SQLException, - if no ascii stream representation existsjava.sql.SQLExceptionpublic java.io.InputStream binaryStreamValue()
throws java.sql.SQLException
SQLException, - if no binary stream representation existsjava.sql.SQLExceptionpublic abstract boolean isConvertibleTo(java.lang.Class<?> cls)
cls - Class to convert topublic <T> T toClass(java.lang.Class<T> type)
throws java.sql.SQLException
type - targetDatum classjava.sql.SQLException - if the conversion is not possible.public abstract java.lang.Object toJdbc()
throws java.sql.SQLException
java.sql.SQLException - if conversion to JDBC representation results in
an errorpublic abstract java.lang.Object makeJdbcArray(int arraySize)
arraySize - size of the arraypublic static int compareBytes(byte[] m,
byte[] n)
m - input byte arrayn - input byte arrayprotected boolean bytesEqual(Datum other)
protected oracle.jdbc.internal.OracleConnection getConnectionDuringExceptionHandling()