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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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.booleanRead a boolean.bytereadByte()Read a byte.byte[]Read a byte array.voidreadBytes(byte[] buff, int off, int len) Read a number of bytes.intreadInt()Read an int.longreadLong()Read a long.longRead a row count.Read a string.Read a type information.Read 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.writeBytes(byte[] data) Write a byte array.writeBytes(byte[] buff, int off, int len) Write a number of bytes.writeInt(int x) Write an int.writeLong(long x) Write a long.writeRowCount(long rowCount) Write a row count.Write a string.writeTypeInfo(TypeInfo type) Write value type, precision, and scale.voidwriteValue(Value v) Write a value.
-
Constructor Details
-
Transfer
Create a new transfer object for the specified session.- Parameters:
session- the sessions- the socket
-
-
Method Details
-
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
-
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
-
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
-
readTypeInfo
Read a type information.- Returns:
- the type information
- Throws:
IOException- on failure
-
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
-
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
-