Class Transfer
java.lang.Object
org.h2.value.Transfer
The transfer class is used to send and receive Value objects.
It is used on both the client side, and on the server side.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate DataInputStreamprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate byte[]private static final intprivate static final intprivate DataOutputStreamprivate static final intprivate static final intprivate Sessionprivate static final intprivate Socketprivate booleanprivate static final int[]private static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final int[]private static final intprivate static final intprivate static final intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddType(int typeInformationType, int valueType) private byte[]calculateLobMac(long lobId) voidclose()Close the transfer object and the socket.voidflush()Write pending changes.Get the socket.intvoidinit()Initialize the transfer object.booleanisClosed()Open a new connection to the same address and port as this one.private Value[]readArrayElements(int len, TypeInfo elementType) booleanRead a boolean.bytereadByte()Read a byte.byte[]Read a byte array.voidreadBytes(byte[] buff, int off, int len) Read a number of bytes.private doubleRead a double.private floatRead a float.intreadInt()Read an int.longreadLong()Read a long.longRead a row count.private shortRead a short.Read a string.Read a type information.private TypeInfoprivate TypeInfoprivate ExtTypeInfoprivate ExtTypeInfoprivate ExtTypeInfoRead a value.voidsetSession(Session session) Set the session.voidsetSSL(boolean ssl) Enable or disable SSL.voidsetVersion(int version) voidverifyLobMac(byte[] hmac, long lobId) Verify the HMAC.writeBoolean(boolean x) Write a boolean.writeByte(byte x) Write a byte.private voidwriteBytePrecisionWithDefault(long precision) writeBytes(byte[] data) Write a byte array.writeBytes(byte[] buff, int off, int len) Write a number of bytes.private voidwriteByteScaleWithDefault(int scale) private TransferwriteDouble(double i) Write a double.private TransferwriteFloat(float i) Write a float.writeInt(int x) Write an int.writeLong(long x) Write a long.writeRowCount(long rowCount) Write a row count.private TransferwriteShort(short x) Write a short.Write a string.writeTypeInfo(TypeInfo type) Write value type, precision, and scale.private voidwriteTypeInfo19(TypeInfo type) private voidwriteTypeInfo20(TypeInfo type) private voidwriteTypeInfoEnum(TypeInfo type) private voidprivate voidwriteTypeInfoRow(TypeInfo type) voidwriteValue(Value v) Write a value.
-
Field Details
-
BUFFER_SIZE
private static final int BUFFER_SIZE- See Also:
-
LOB_MAGIC
private static final int LOB_MAGIC- See Also:
-
LOB_MAC_SALT_LENGTH
private static final int LOB_MAC_SALT_LENGTH- See Also:
-
NULL
private static final int NULL- See Also:
-
BOOLEAN
private static final int BOOLEAN- See Also:
-
TINYINT
private static final int TINYINT- See Also:
-
SMALLINT
private static final int SMALLINT- See Also:
-
INTEGER
private static final int INTEGER- See Also:
-
BIGINT
private static final int BIGINT- See Also:
-
NUMERIC
private static final int NUMERIC- See Also:
-
DOUBLE
private static final int DOUBLE- See Also:
-
REAL
private static final int REAL- See Also:
-
TIME
private static final int TIME- See Also:
-
DATE
private static final int DATE- See Also:
-
TIMESTAMP
private static final int TIMESTAMP- See Also:
-
VARBINARY
private static final int VARBINARY- See Also:
-
VARCHAR
private static final int VARCHAR- See Also:
-
VARCHAR_IGNORECASE
private static final int VARCHAR_IGNORECASE- See Also:
-
BLOB
private static final int BLOB- See Also:
-
CLOB
private static final int CLOB- See Also:
-
ARRAY
private static final int ARRAY- See Also:
-
JAVA_OBJECT
private static final int JAVA_OBJECT- See Also:
-
UUID
private static final int UUID- See Also:
-
CHAR
private static final int CHAR- See Also:
-
GEOMETRY
private static final int GEOMETRY- See Also:
-
TIMESTAMP_TZ
private static final int TIMESTAMP_TZ- See Also:
-
ENUM
private static final int ENUM- See Also:
-
INTERVAL
private static final int INTERVAL- See Also:
-
ROW
private static final int ROW- See Also:
-
JSON
private static final int JSON- See Also:
-
TIME_TZ
private static final int TIME_TZ- See Also:
-
BINARY
private static final int BINARY- See Also:
-
DECFLOAT
private static final int DECFLOAT- See Also:
-
VALUE_TO_TI
private static final int[] VALUE_TO_TI -
TI_TO_VALUE
private static final int[] TI_TO_VALUE -
socket
-
in
-
out
-
session
-
ssl
private boolean ssl -
version
private int version -
lobMacSalt
private byte[] lobMacSalt
-
-
Constructor Details
-
Transfer
-
-
Method Details
-
addType
private static void addType(int typeInformationType, int valueType) -
init
Initialize the transfer object. This method will try to open an input and output stream.- Throws:
IOException- on failure
-
flush
-
writeBoolean
Write a boolean.- Parameters:
x- the value- Returns:
- itself
- Throws:
IOException- on failure
-
readBoolean
Read a boolean.- Returns:
- the value
- Throws:
IOException- on failure
-
writeByte
Write a byte.- Parameters:
x- the value- Returns:
- itself
- Throws:
IOException- on failure
-
readByte
Read a byte.- Returns:
- the value
- Throws:
IOException- on failure
-
writeShort
Write a short.- Parameters:
x- the value- Returns:
- itself
- Throws:
IOException- on failure
-
readShort
Read a short.- Returns:
- the value
- Throws:
IOException- on failure
-
writeInt
Write an int.- Parameters:
x- the value- Returns:
- itself
- Throws:
IOException- on failure
-
readInt
Read an int.- Returns:
- the value
- Throws:
IOException- on failure
-
writeLong
Write a long.- Parameters:
x- the value- Returns:
- itself
- Throws:
IOException- on failure
-
readLong
Read a long.- Returns:
- the value
- Throws:
IOException- on failure
-
writeDouble
Write a double.- Parameters:
i- the value- Returns:
- itself
- Throws:
IOException- on failure
-
writeFloat
Write a float.- Parameters:
i- the value- Returns:
- itself
- Throws:
IOException
-
readDouble
Read a double.- Returns:
- the value
- Throws:
IOException- on failure
-
readFloat
Read a float.- Returns:
- the value
- Throws:
IOException- on failure
-
writeString
Write a string. The maximum string length is Integer.MAX_VALUE.- Parameters:
s- the value- Returns:
- itself
- Throws:
IOException- on failure
-
readString
Read a string.- Returns:
- the value
- Throws:
IOException- on failure
-
writeBytes
Write a byte array.- Parameters:
data- the value- Returns:
- itself
- Throws:
IOException- on failure
-
writeBytes
Write a number of bytes.- Parameters:
buff- the valueoff- the offsetlen- the length- Returns:
- itself
- Throws:
IOException- on failure
-
readBytes
Read a byte array.- Returns:
- the value
- Throws:
IOException- on failure
-
readBytes
Read a number of bytes.- Parameters:
buff- the target bufferoff- the offsetlen- the number of bytes to read- Throws:
IOException- on failure
-
close
public void close()Close the transfer object and the socket. -
writeTypeInfo
Write value type, precision, and scale.- Parameters:
type- data type information- Returns:
- itself
- Throws:
IOException- on failure
-
writeTypeInfo20
- Throws:
IOException
-
writeBytePrecisionWithDefault
- Throws:
IOException
-
writeByteScaleWithDefault
- Throws:
IOException
-
writeTypeInfoEnum
- Throws:
IOException
-
writeTypeInfoGeometry
- Throws:
IOException
-
writeTypeInfoRow
- Throws:
IOException
-
writeTypeInfo19
- Throws:
IOException
-
readTypeInfo
Read a type information.- Returns:
- the type information
- Throws:
IOException- on failure
-
readTypeInfo20
- Throws:
IOException
-
readTypeInfoEnum
- Throws:
IOException
-
readTypeInfoGeometry
- Throws:
IOException
-
readTypeInfoRow
- Throws:
IOException
-
readTypeInfo19
- Throws:
IOException
-
writeValue
Write a value.- Parameters:
v- the value- Throws:
IOException- on failure
-
readValue
Read a value.- Parameters:
columnType- the data type of value, ornull- Returns:
- the value
- Throws:
IOException- on failure
-
readArrayElements
- Throws:
IOException
-
readRowCount
Read a row count.- Returns:
- the row count
- Throws:
IOException- on failure
-
writeRowCount
Write a row count.- Parameters:
rowCount- the row count- Returns:
- itself
- Throws:
IOException- on failure
-
getSocket
-
setSession
-
setSSL
public void setSSL(boolean ssl) Enable or disable SSL.- Parameters:
ssl- the new value
-
openNewConnection
Open a new connection to the same address and port as this one.- Returns:
- the new transfer object
- Throws:
IOException- on failure
-
setVersion
public void setVersion(int version) -
getVersion
public int getVersion() -
isClosed
public boolean isClosed() -
verifyLobMac
public void verifyLobMac(byte[] hmac, long lobId) Verify the HMAC.- Parameters:
hmac- the message authentication codelobId- the lobId- Throws:
DbException- if the HMAC does not match
-
calculateLobMac
private byte[] calculateLobMac(long lobId)
-