Class VECTOR
- java.lang.Object
-
- oracle.sql.Datum
-
- oracle.sql.VECTOR
-
- All Implemented Interfaces:
java.io.Serializable
public final class VECTOR extends Datum
VECTOR ClassThe
VECTORclass provides conversions between the Oracle VECTOR data type and Java classes:-
double[] -
float[] -
long[] -
int[] -
short[] -
byte[] -
boolean[] -
String
- Since:
- 23.4
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class oracle.sql.Datum
ojiOracleDatumWithConnection, targetDatum
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)Checks if this VECTOR is equal to another VECTOR.static VECTORfromData(byte[] data)Creates aVECTORthat contains the values encoded in the givendata.OracleTypegetType()Returns the type of this VECTOR, which is one of the following:inthashCode()Returns a hash code computed from the type and values of this VECTOR.booleanisConvertibleTo(java.lang.Class<?> cls)Determines if datum object can be converted to a particular classjava.lang.ObjectmakeJdbcArray(int arraySize)Returns a JDBC array representation of the datumstatic VECTORofFloat32Values(java.lang.Object values)Converts the givenvaluesinto aVECTORof 32-bit floating point numbers.static VECTORofFloat64Values(java.lang.Object values)Converts the givenvaluesinto aVECTORof 64-bit floating point numbers.static VECTORofInt8Values(java.lang.Object values)Converts the givenvaluesinto aVECTORof signed 8-bit integers.java.lang.StringstringValue()Converts this VECTOR into String.boolean[]toBooleanArray()Converts this VECTOR into an array of booleans.static boolean[]toBooleanArray(byte[] data)Converts the binary representation of a VECTOR into an array of booleans.byte[]toByteArray()Converts this VECTOR into an array of bytes.static byte[]toByteArray(byte[] data)Converts the binary representation of a VECTOR into an array of bytes.<T> TtoClass(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 binary representation of a VECTOR into an array of doubles.float[]toFloatArray()Converts this VECTOR into an array of floats.static float[]toFloatArray(byte[] data)Converts the binary representation of a VECTOR into an array of floats.int[]toIntArray()Converts this VECTOR into an array of ints.static int[]toIntArray(byte[] data)Converts the binary representation of a VECTOR into an array of ints.java.lang.ObjecttoJdbc()Returns the JDBC representation of the datum objectlong[]toLongArray()Converts this VECTOR into an array of longs.static long[]toLongArray(byte[] data)Converts the binary representation of a VECTOR into an array of longs.short[]toShortArray()Converts this VECTOR into an array of shorts.static short[]toShortArray(byte[] data)Converts the binary representation of a VECTOR into an array of shorts.java.lang.StringtoString()-
Methods inherited from class oracle.sql.Datum
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
-
-
-
-
Method Detail
-
fromData
public static VECTOR fromData(byte[] data)
Creates aVECTORthat contains the values encoded in the givendata.- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- A VECTOR that contains the encoded values. Not null.
- Throws:
java.lang.NullPointerException- Ifencodingisnull
-
ofFloat64Values
public static VECTOR ofFloat64Values(java.lang.Object values) throws java.sql.SQLException
Converts the given
valuesinto aVECTORof 64-bit floating point numbers. Thevaluesmay be an instance of any class listed in the "Java to SQL Conversions" section of the JavaDoc forOracleType.VECTOR_FLOAT64. Lossy conversions specified in that JavaDoc also apply to this method.- Parameters:
values- Values contained in the returned VECTOR. Not null.- Returns:
- A VECTOR that contains the values. Not null.
- Throws:
java.lang.NullPointerException- Ifbytesisnulljava.sql.SQLException- If a VECTOR can not represent the givenvalues, for instance because thevaluesare not an instance of a supported class, or have a length that exceeds the maximum length of a VECTOR.
-
ofFloat32Values
public static VECTOR ofFloat32Values(java.lang.Object values) throws java.sql.SQLException
Converts the given
valuesinto aVECTORof 32-bit floating point numbers. Thevaluesmay be an instance of any class listed in the "Java to SQL Conversions" section of the JavaDoc forOracleType.VECTOR_FLOAT32. Lossy conversions specified in that JavaDoc also apply to this method.- Parameters:
values- Values contained in the returned VECTOR. Not null.- Returns:
- A VECTOR that contains the values. Not null.
- Throws:
java.lang.NullPointerException- Ifbytesisnulljava.sql.SQLException- If a VECTOR can not represent the givenvalues, for instance because thevaluesare not an instance of a supported class, or have a length that exceeds the maximum length of a VECTOR.
-
ofInt8Values
public static VECTOR ofInt8Values(java.lang.Object values) throws java.sql.SQLException
Converts the given
valuesinto aVECTORof signed 8-bit integers. Thevaluesmay be an instance of any class listed in the "Java to SQL Conversions" section of the JavaDoc forOracleType.VECTOR_INT8. Lossy conversions specified in that JavaDoc also apply to this method.- Parameters:
values- Values contained in the returned VECTOR. Not null.- Returns:
- A VECTOR that contains the values. Not null.
- Throws:
java.lang.NullPointerException- Ifbytesisnulljava.sql.SQLException- If a VECTOR can not represent the givenvalues, for instance because thevaluesare not an instance of a supported class, or have a length that exceeds the maximum length of a VECTOR.
-
getType
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 numeric value type: FLOAT64, FLOAT32, or INT8.- Returns:
- The type of this VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toDoubleArray
public double[] toDoubleArray() throws java.sql.SQLExceptionConverts this VECTOR into an array of doubles.
This is a lossless conversion. The array returned by this method contains
doublevalues which store the same information as this VECTOR.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toDoubleArray
public static double[] toDoubleArray(byte[] data) throws java.sql.SQLExceptionConverts the binary representation of a VECTOR into an array of doubles.
This method performs a lossless conversion. The array returned by this method contains
doublevalues which store the same information as the given VECTOR.- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If thedatais not recognized as the binary encoding of a VECTOR.java.lang.NullPointerException- Ifdataisnull.
-
toFloatArray
public float[] toFloatArray() throws java.sql.SQLExceptionConverts 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- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toFloatArray
public static float[] toFloatArray(byte[] data) throws java.sql.SQLExceptionConverts the binary representation 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- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If thedatais not recognized as the binary encoding of a VECTOR.java.lang.NullPointerException- Ifdataisnull.
-
toLongArray
public long[] toLongArray() throws java.sql.SQLExceptionConverts 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- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toLongArray
public static long[] toLongArray(byte[] data) throws java.sql.SQLExceptionConverts the binary representation 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- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If thedatais not recognized as the binary encoding of a VECTOR.java.lang.NullPointerException- Ifdataisnull.
-
toIntArray
public int[] toIntArray() throws java.sql.SQLExceptionConverts 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- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toIntArray
public static int[] toIntArray(byte[] data) throws java.sql.SQLExceptionConverts the binary representation 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- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If thedatais not recognized as the binary encoding of a VECTOR.java.lang.NullPointerException- Ifdataisnull.
-
toShortArray
public short[] toShortArray() throws java.sql.SQLExceptionConverts 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- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toShortArray
public static short[] toShortArray(byte[] data) throws java.sql.SQLExceptionConverts the binary representation 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- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If thedatais not recognized as the binary encoding of a VECTOR.java.lang.NullPointerException- Ifdataisnull.
-
toByteArray
public byte[] toByteArray() throws java.sql.SQLExceptionConverts 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- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toByteArray
public static byte[] toByteArray(byte[] data) throws java.sql.SQLExceptionConverts the binary representation 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- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If thedatais not recognized as the binary encoding of a VECTOR.java.lang.NullPointerException- Ifdataisnull.
-
toBooleanArray
public boolean[] toBooleanArray() throws java.sql.SQLExceptionConverts 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- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toBooleanArray
public static boolean[] toBooleanArray(byte[] data) throws java.sql.SQLExceptionConverts the binary representation 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- Parameters:
data- The binary representation of a VECTOR. Not null.- Returns:
- An array containing the values (ie: "dimensions") of a VECTOR. Not null.
- Throws:
java.sql.SQLException- If thedatais not recognized as the binary encoding of a VECTOR.java.lang.NullPointerException- Ifdataisnull.
-
stringValue
public java.lang.String stringValue() throws java.sql.SQLExceptionConverts 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- Overrides:
stringValuein classDatum- Returns:
- The VARCHAR literal representation of this VECTOR. Not null.
- Throws:
java.sql.SQLException- If the data this VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
Returns a hash code computed from the type and values of this VECTOR.- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code for this VECTOR.
-
equals
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
falseif the data that either VECTOR was created with is not recognized as the binary encoding of a VECTOR.
-
toClass
public <T> T toClass(java.lang.Class<T> type) throws java.sql.SQLExceptionDescription copied from class:DatumConvert this datum to an instance of the specified type if possible.
-
isConvertibleTo
public boolean isConvertibleTo(java.lang.Class<?> cls)
Description copied from class:DatumDetermines if datum object can be converted to a particular class- Specified by:
isConvertibleToin classDatum- Parameters:
cls- Class to convert to- Returns:
- true, if conversion to cls is permitted false, if conversion to cls is not permitted
-
toJdbc
public java.lang.Object toJdbc() throws java.sql.SQLExceptionReturns the JDBC representation of the datum objectTHE 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.
-
makeJdbcArray
public java.lang.Object makeJdbcArray(int arraySize)
Returns a JDBC array representation of the datumTHE 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.- Specified by:
makeJdbcArrayin classDatum- Parameters:
arraySize- size of the array- Returns:
- an object containing the JDBC array value
-
-