public final class VECTOR extends Datum
The VECTOR
class provides conversions between the Oracle VECTOR
data type and Java classes:
double[]
float[]
long[]
int[]
short[]
byte[]
boolean[]
String
Instances of this class may be passed to
setObject
methods of PreparedStatement
, and
may be returned by getObject
methods of
ResultSet
.
Static factory methods convert a Java array into a VECTOR
of
a specific dimension type:
The dimension type of a VECTOR
can be obtained from
getType()
, and its number of dimensions can be obtained from
getVectorLength()
.
ojiOracleDatumWithConnection, targetDatum
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object object)
Checks if this VECTOR is equal to another VECTOR.
|
static VECTOR |
fromData(byte[] data)
For most use cases, an of...Values method
should be used when creating a VECTOR object, not this method.
|
OracleType |
getType()
Returns the type of this VECTOR, which is one of the following:
|
int |
getVectorLength()
Returns the number of values in this VECTOR (ie: The dimension count).
|
int |
hashCode()
Returns a hash code computed from the type and
values of this VECTOR.
|
boolean |
isConvertibleTo(java.lang.Class<?> cls)
Determines if datum object can be converted to a particular class
|
java.lang.Object |
makeJdbcArray(int arraySize)
Returns a JDBC array representation of the datum
|
static VECTOR |
ofBinaryValues(java.lang.Object object)
Converts an
Object into a VECTOR of the
BINARY dimension type. |
static VECTOR |
ofFloat32Values(java.lang.Object object)
Converts an
Object into a VECTOR of the
FLOAT32 dimension type. |
static VECTOR |
ofFloat64Values(java.lang.Object object)
Converts an
Object into a VECTOR of the
FLOAT64 dimension type. |
static VECTOR |
ofInt8Values(java.lang.Object object)
Converts an
Object into a VECTOR of the
INT8 dimension type. |
java.lang.Class<?> |
preferredArrayClass()
Returns the preferred array class
for this VECTOR.
|
java.lang.String |
stringValue()
Converts this VECTOR into String.
|
boolean[] |
toBooleanArray()
Converts this VECTOR into an array of booleans.
|
static boolean[] |
toBooleanArray(byte[] data)
Converts Oracle's internal encoding of a VECTOR into an array of booleans.
|
byte[] |
toByteArray()
Converts this VECTOR into an array of bytes.
|
static byte[] |
toByteArray(byte[] data)
Converts Oracle's internal encoding of a VECTOR into an array of bytes.
|
<T> T |
toClass(java.lang.Class<T> type)
Convert this datum to an instance of the specified type if possible.
|
double[] |
toDoubleArray()
Converts this VECTOR into an array of doubles.
|
static double[] |
toDoubleArray(byte[] data)
Converts the Oracle's internal encoding of a VECTOR into an array of doubles.
|
float[] |
toFloatArray()
Converts this VECTOR into an array of floats.
|
static float[] |
toFloatArray(byte[] data)
Converts Oracle's internal encoding of a VECTOR into an array of floats.
|
int[] |
toIntArray()
Converts this VECTOR into an array of ints.
|
static int[] |
toIntArray(byte[] data)
Converts Oracle's internal encoding of a VECTOR into an array of ints.
|
java.lang.Object |
toJdbc()
Returns the JDBC representation of the datum object
|
long[] |
toLongArray()
Converts this VECTOR into an array of longs.
|
static long[] |
toLongArray(byte[] data)
Converts Oracle's internal encoding of a VECTOR into an array of longs.
|
short[] |
toShortArray()
Converts this VECTOR into an array of shorts.
|
static short[] |
toShortArray(byte[] data)
Converts Oracle's internal encoding of a VECTOR into an array of shorts.
|
java.lang.String |
toString() |
asciiStreamValue, bigDecimalValue, binaryStreamValue, booleanValue, bytesEqual, bytesHashCode, byteValue, characterStreamValue, compareBytes, dateValue, doubleValue, floatValue, getBytes, getConnectionDuringExceptionHandling, getLength, getStream, intValue, isNull, longValue, setBytes, setShareBytes, shareBytes, stringValue, timestampValue, timestampValue, timeValue, timeValue
public static VECTOR fromData(byte[] data)
For most use cases, an of...Values method should be used when creating a VECTOR object, not this method.
Creates a VECTOR
from Oracle's internal encoding of a VECTOR.
data
- Oracle's internal encoding of a VECTOR. Not null.java.lang.NullPointerException
- If data
is null
public static VECTOR ofFloat64Values(java.lang.Object object) throws java.sql.SQLException
Converts an Object
into a VECTOR
of the
FLOAT64 dimension type. The object
may be an instance
of any class listed in the "Java to SQL Conversions" section of the JavaDoc
for OracleType.VECTOR_FLOAT64
. Lossy conversions specified in that
JavaDoc also apply to this method.
object
- Object containing values of a VECTOR. Not null.java.lang.NullPointerException
- If the object
is
null
.java.sql.SQLException
- If the object
can not be
converted into a VECTOR, for instance because its class is not recognized,
or because the number of values exceeds the maximum length of a VECTOR.public static VECTOR ofFloat32Values(java.lang.Object object) throws java.sql.SQLException
Converts an Object
into a VECTOR
of the
FLOAT32 dimension type. The object
may be an instance
of any class listed in the "Java to SQL Conversions" section of the JavaDoc
for OracleType.VECTOR_FLOAT32
. Lossy conversions specified in that
JavaDoc also apply to this method.
object
- Object containing values of a VECTOR. Not null.java.lang.NullPointerException
- If the object
is
null
.java.sql.SQLException
- If the object
can not be
converted into a VECTOR, for instance because its class is not recognized,
or because the number of values exceeds the maximum length of a VECTOR.public static VECTOR ofInt8Values(java.lang.Object object) throws java.sql.SQLException
Converts an Object
into a VECTOR
of the
INT8 dimension type. The object
may be an instance
of any class listed in the "Java to SQL Conversions" section of the JavaDoc
for OracleType.VECTOR_INT8
. Lossy conversions specified in that
JavaDoc also apply to this method.
object
- Object containing values of a VECTOR. Not null.java.lang.NullPointerException
- If the object
is
null
.java.sql.SQLException
- If the object
can not be
converted into a VECTOR, for instance because its class is not recognized,
or because the number of values exceeds the maximum length of a VECTOR.public static VECTOR ofBinaryValues(java.lang.Object object) throws java.sql.SQLException
Converts an Object
into a VECTOR
of the
BINARY dimension type. The object
may be an instance
of any class listed in the "Java to SQL Conversions" section of the JavaDoc
for OracleType.VECTOR_BINARY
.
object
- Object containing values of a VECTOR. Not null.java.lang.NullPointerException
- If the object
is
null
.java.sql.SQLException
- If the object
can not be
converted into a VECTOR, for instance because its class is not recognized,
or because the number of values exceeds the maximum length of a VECTOR.public OracleType getType() throws java.sql.SQLException
Returns the type of this VECTOR, which is one of the following:
This method will not return OracleType.VECTOR
, which is only
applicable to columns and parameters. Individual VECTOR values always have
a specific dimension type: FLOAT64, FLOAT32, or INT8.
java.sql.SQLException
- If the data this VECTOR was created with is not
recognized as the binary encoding of a VECTOR.public double[] toDoubleArray() throws java.sql.SQLException
Converts this VECTOR into an array of doubles.
This is a lossless conversion. The array returned by this method contains
double
values which store the same information as this VECTOR.
java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public static double[] toDoubleArray(byte[] data) throws java.sql.SQLException
Converts the Oracle's internal encoding of a VECTOR into an array of doubles.
This method performs a lossless conversion. The array returned by this
method contains double
values which store the same information
as the given VECTOR.
data
- Oracle's internal encoding of a VECTOR. Not null.java.sql.SQLException
- If the dimension type can not
be converted to the returned type.java.lang.NullPointerException
- If data
is null
.public float[] toFloatArray() throws java.sql.SQLException
Converts this VECTOR into an array of floats.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public static float[] toFloatArray(byte[] data) throws java.sql.SQLException
Converts Oracle's internal encoding of a VECTOR into an array of floats.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
data
- Oracle's internal encoding of a VECTOR. Not null.java.lang.NullPointerException
- If data
is null
.java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public long[] toLongArray() throws java.sql.SQLException
Converts this VECTOR into an array of longs.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public static long[] toLongArray(byte[] data) throws java.sql.SQLException
Converts Oracle's internal encoding of a VECTOR into an array of longs.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
data
- Oracle's internal encoding of a VECTOR. Not null.java.lang.NullPointerException
- If data
is null
.java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public int[] toIntArray() throws java.sql.SQLException
Converts this VECTOR into an array of ints.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public static int[] toIntArray(byte[] data) throws java.sql.SQLException
Converts Oracle's internal encoding of a VECTOR into an array of ints.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
data
- Oracle's internal encoding of a VECTOR. Not null.java.lang.NullPointerException
- If data
is null
.java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public short[] toShortArray() throws java.sql.SQLException
Converts this VECTOR into an array of shorts.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public static short[] toShortArray(byte[] data) throws java.sql.SQLException
Converts Oracle's internal encoding of a VECTOR into an array of shorts.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
data
- Oracle's internal encoding of a VECTOR. Not null.java.lang.NullPointerException
- If data
is null
.java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public byte[] toByteArray() throws java.sql.SQLException
Converts this VECTOR into an array of bytes.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
.
If the type of this VECTOR is
OracleType.VECTOR_BINARY
, each byte returned by this method is
8 dimensions packed as bits in MSB order.
java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public static byte[] toByteArray(byte[] data) throws java.sql.SQLException
Converts Oracle's internal encoding of a VECTOR into an array of bytes.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
.
If the type of this VECTOR is
OracleType.VECTOR_BINARY
, each byte returned by this method
contains up to 8 dimensions, packed as bits in MSB order. The last byte may
contain less than 8 dimensions if the
length of this VECTOR is not a multiple of
8.
data
- Oracle's internal encoding of a VECTOR. Not null.java.lang.NullPointerException
- If data
is null
.java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public boolean[] toBooleanArray() throws java.sql.SQLException
Converts this VECTOR into an array of booleans.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
java.sql.SQLException
- If the data this VECTOR was created with is not
recognized as the binary encoding of a VECTOR.public static boolean[] toBooleanArray(byte[] data) throws java.sql.SQLException
Converts Oracle's internal encoding of a VECTOR into an array of booleans.
This method may perform lossy conversions as specified in the
"SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
data
- Oracle's internal encoding of a VECTOR. Not null.java.lang.NullPointerException
- If data
is null
.java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public java.lang.String stringValue() throws java.sql.SQLException
Converts this VECTOR into String.
This method returns a VARCHAR literal representation of this VECTOR, as
specified in the "SQL to Java Conversions" section of the JavaDoc for
OracleType.VECTOR
stringValue
in class Datum
java.sql.SQLException
- If the dimension type can not
be converted to the returned type.public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
Checks if this VECTOR is equal to another VECTOR. This method considers two vectors to be equal if both have the same type, and contain the same values (ie: "dimensions").
This method returns false
if the data that either VECTOR was
created with is not recognized as the binary encoding of a VECTOR.
public java.lang.Class<?> preferredArrayClass() throws java.sql.SQLException
java.sql.SQLException
- If the data this VECTOR was created with is not
recognized as the binary encoding of a VECTOR.public int getVectorLength()
java.lang.IllegalStateException
- If the data this VECTOR was created with is
not recognized as the binary encoding of a VECTOR.public <T> T toClass(java.lang.Class<T> type) throws java.sql.SQLException
Datum
public boolean isConvertibleTo(java.lang.Class<?> cls)
Datum
isConvertibleTo
in class Datum
cls
- Class to convert topublic java.lang.Object toJdbc() throws java.sql.SQLException
THE BEHAVIOR OF THIS METHOD MAY CHANGE IN A FUTURE RELEASE.
The behavior of this method may change if a future JDBC specification defines a mapping for VECTOR data. No such mapping is defined in JDBC 4.3, so this method is currently implemented to return this VECTOR.
public java.lang.Object makeJdbcArray(int arraySize)
THE BEHAVIOR OF THIS METHOD MAY CHANGE IN A FUTURE RELEASE.
The behavior of this method may change if a future JDBC specification
defines a mapping for VECTOR data. No such mapping is defined in JDBC 4.3,
so this method is currently implemented to return an array with the
component type of oracle.sql.VECTOR
.
makeJdbcArray
in class Datum
arraySize
- size of the array