Package org.h2.value
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 int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private DataInputStream
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private byte[]
private static final int
private static final int
private DataOutputStream
private static final int
private static final int
private Session
private static final int
private Socket
private boolean
private static final int[]
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int[]
private static final int
private static final int
private static final int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
addType
(int typeInformationType, int valueType) private byte[]
calculateLobMac
(long lobId) void
close()
Close the transfer object and the socket.void
flush()
Write pending changes.Get the socket.int
void
init()
Initialize the transfer object.boolean
isClosed()
Open a new connection to the same address and port as this one.private Value[]
readArrayElements
(int len, TypeInfo elementType) boolean
Read a boolean.byte
readByte()
Read a byte.byte[]
Read a byte array.void
readBytes
(byte[] buff, int off, int len) Read a number of bytes.private double
Read a double.private float
Read a float.int
readInt()
Read an int.long
readLong()
Read a long.long
Read a row count.private short
Read a short.Read a string.Read a type information.private TypeInfo
private TypeInfo
private ExtTypeInfo
private ExtTypeInfo
private ExtTypeInfo
Read a value.void
setSession
(Session session) Set the session.void
setSSL
(boolean ssl) Enable or disable SSL.void
setVersion
(int version) void
verifyLobMac
(byte[] hmac, long lobId) Verify the HMAC.writeBoolean
(boolean x) Write a boolean.writeByte
(byte x) Write a byte.private void
writeBytePrecisionWithDefault
(long precision) writeBytes
(byte[] data) Write a byte array.writeBytes
(byte[] buff, int off, int len) Write a number of bytes.private void
writeByteScaleWithDefault
(int scale) private Transfer
writeDouble
(double i) Write a double.private Transfer
writeFloat
(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 Transfer
writeShort
(short x) Write a short.Write a string.writeTypeInfo
(TypeInfo type) Write value type, precision, and scale.private void
writeTypeInfo19
(TypeInfo type) private void
writeTypeInfo20
(TypeInfo type) private void
writeTypeInfoEnum
(TypeInfo type) private void
private void
writeTypeInfoRow
(TypeInfo type) void
writeValue
(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
Create a new transfer object for the specified session.- Parameters:
session
- the sessions
- the socket
-
-
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
Write pending changes.- Throws:
IOException
- on failure
-
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
Get the socket.- Returns:
- the socket
-
setSession
Set the session.- Parameters:
session
- the session
-
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)
-