Top Description Fields Constructors Methods
org.h2.value

public final Class Transfer

extends Object
Class Inheritance
Static Imports
org.h2.util.Bits.LONG_VH_BE

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

Modifier and TypeField and Description
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 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 final ReentrantLock
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

AccessConstructor and Description
public
Transfer(Session
the session
session
,
Socket
the socket
s
)

Create a new transfer object for the specified session.

Method Summary

Modifier and TypeMethod and Description
private static void
addType(int typeInformationType, int valueType)

private byte[]
calculateLobMac(long lobId)

public void
close()

Close the transfer object and the socket.

public void
flush()

Write pending changes.

public Socket

Returns:

the socket
getSocket
()

Get the socket.

public int
public void
init()

Initialize the transfer object.

public boolean
private void
lock()

Locks this object with a reentrant lock.

public Transfer

Returns:

the new transfer object
openNewConnection
()

Open a new connection to the same address and port as this one.

private Value[]
readArrayElements(int len, TypeInfo elementType)

public boolean

Returns:

the value
readBoolean
()

Read a boolean.

public byte

Returns:

the value
readByte
()

Read a byte.

public byte[]

Returns:

the value
readBytes
()

Read a byte array.

public void
readBytes(byte[]
the target buffer
buff
,
int
the offset
off
,
int
the number of bytes to read
len
)

Read a number of bytes.

private double

Returns:

the value
readDouble
()

Read a double.

private float

Returns:

the value
readFloat
()

Read a float.

public int

Returns:

the value
readInt
()

Read an int.

public long

Returns:

the value
readLong
()

Read a long.

public long

Returns:

the row count
readRowCount
()

Read a row count.

private short

Returns:

the value
readShort
()

Read a short.

public String

Returns:

the value
readString
()

Read a string.

public TypeInfo

Returns:

the type information
readTypeInfo
()

Read a type information.

private TypeInfo
private TypeInfo
private ExtTypeInfo
private ExtTypeInfo
private ExtTypeInfo
public Value

Returns:

the value
readValue
(TypeInfo
the data type of value, or null
columnType
)

Read a value.

public void
setSession(Session
the session
session
)

Set the session.

public void
setSSL(boolean
the new value
ssl
)

Enable or disable SSL.

public void
setVersion(int version)

private void
unlock()

Unlocks this object.

public void
verifyLobMac(byte[]
the message authentication code
hmac
,
long
the lobId
lobId
)

Verify the HMAC.

public Transfer

Returns:

itself
writeBoolean
(boolean
the value
x
)

Write a boolean.

public Transfer

Returns:

itself
writeByte
(byte
the value
x
)

Write a byte.

private void
public Transfer

Returns:

itself
writeBytes
(byte[]
the value
data
)

Write a byte array.

public Transfer

Returns:

itself
writeBytes
(byte[]
the value
buff
,
int
the offset
off
,
int
the length
len
)

Write a number of bytes.

private void
private Transfer

Returns:

itself
writeDouble
(double
the value
i
)

Write a double.

private Transfer

Returns:

itself
writeFloat
(float
the value
i
)

Write a float.

public Transfer

Returns:

itself
writeInt
(int
the value
x
)

Write an int.

public Transfer

Returns:

itself
writeLong
(long
the value
x
)

Write a long.

public Transfer

Returns:

itself
writeRowCount
(long
the row count
rowCount
)

Write a row count.

private Transfer

Returns:

itself
writeShort
(short
the value
x
)

Write a short.

public Transfer

Returns:

itself
writeString
(String
the value
s
)

Write a string.

public Transfer

Returns:

itself
writeTypeInfo
(TypeInfo
data type information
type
)

Write value type, precision, and scale.

private void
private void
private void
private void
private void
public void
writeValue(Value
the value
v
)

Write a value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ARRAYback to summary
private static final int ARRAY
BIGINTback to summary
private static final int BIGINT
BINARYback to summary
private static final int BINARY
BLOBback to summary
private static final int BLOB
BOOLEANback to summary
private static final int BOOLEAN
BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
CHARback to summary
private static final int CHAR
CLOBback to summary
private static final int CLOB
DATEback to summary
private static final int DATE
DECFLOATback to summary
private static final int DECFLOAT
DOUBLEback to summary
private static final int DOUBLE
ENUMback to summary
private static final int ENUM
GEOMETRYback to summary
private static final int GEOMETRY
inback to summary
private DataInputStream in
INTEGERback to summary
private static final int INTEGER
INTERVALback to summary
private static final int INTERVAL
JAVA_OBJECTback to summary
private static final int JAVA_OBJECT
JSONback to summary
private static final int JSON
LOB_MAC_SALT_LENGTHback to summary
private static final int LOB_MAC_SALT_LENGTH
LOB_MAGICback to summary
private static final int LOB_MAGIC
lobMacSaltback to summary
private byte[] lobMacSalt
lockback to summary
private final ReentrantLock lock
NULLback to summary
private static final int NULL
NUMERICback to summary
private static final int NUMERIC
outback to summary
private DataOutputStream out
REALback to summary
private static final int REAL
ROWback to summary
private static final int ROW
sessionback to summary
private Session session
SMALLINTback to summary
private static final int SMALLINT
socketback to summary
private Socket socket
sslback to summary
private boolean ssl
TI_TO_VALUEback to summary
private static final int[] TI_TO_VALUE
TIMEback to summary
private static final int TIME
TIME_TZback to summary
private static final int TIME_TZ
TIMESTAMPback to summary
private static final int TIMESTAMP
TIMESTAMP_TZback to summary
private static final int TIMESTAMP_TZ
TINYINTback to summary
private static final int TINYINT
UUIDback to summary
private static final int UUID
VALUE_TO_TIback to summary
private static final int[] VALUE_TO_TI
VARBINARYback to summary
private static final int VARBINARY
VARCHARback to summary
private static final int VARCHAR
VARCHAR_IGNORECASEback to summary
private static final int VARCHAR_IGNORECASE
versionback to summary
private int version

Constructor Detail

Transferback to summary
public Transfer(Session session, Socket s)

Create a new transfer object for the specified session.

Parameters
session:Session

the session

s:Socket

the socket

Method Detail

addTypeback to summary
private static void addType(int typeInformationType, int valueType)
calculateLobMacback to summary
private byte[] calculateLobMac(long lobId)
closeback to summary
public void close()

Close the transfer object and the socket.

flushback to summary
public void flush() throws IOException

Write pending changes.

Exceptions
IOException:
on failure
getSocketback to summary
public Socket getSocket()

Get the socket.

Returns:Socket

the socket

getVersionback to summary
public int getVersion()
initback to summary
public void init() throws IOException

Initialize the transfer object. This method will try to open an input and output stream.

Exceptions
IOException:
on failure
isClosedback to summary
public boolean isClosed()
lockback to summary
private void lock()

Locks this object with a reentrant lock.

lock();
try {
    ...
} finally {
    unlock();
}
openNewConnectionback to summary
public Transfer openNewConnection() throws IOException

Open a new connection to the same address and port as this one.

Returns:Transfer

the new transfer object

Exceptions
IOException:
on failure
readArrayElementsback to summary
private Value[] readArrayElements(int len, TypeInfo elementType) throws IOException
readBooleanback to summary
public boolean readBoolean() throws IOException

Read a boolean.

Returns:boolean

the value

Exceptions
IOException:
on failure
readByteback to summary
public byte readByte() throws IOException

Read a byte.

Returns:byte

the value

Exceptions
IOException:
on failure
readBytesback to summary
public byte[] readBytes() throws IOException

Read a byte array.

Returns:byte[]

the value

Exceptions
IOException:
on failure
readBytesback to summary
public void readBytes(byte[] buff, int off, int len) throws IOException

Read a number of bytes.

Parameters
buff:byte[]

the target buffer

off:int

the offset

len:int

the number of bytes to read

Exceptions
IOException:
on failure
readDoubleback to summary
private double readDouble() throws IOException

Read a double.

Returns:double

the value

Exceptions
IOException:
on failure
readFloatback to summary
private float readFloat() throws IOException

Read a float.

Returns:float

the value

Exceptions
IOException:
on failure
readIntback to summary
public int readInt() throws IOException

Read an int.

Returns:int

the value

Exceptions
IOException:
on failure
readLongback to summary
public long readLong() throws IOException

Read a long.

Returns:long

the value

Exceptions
IOException:
on failure
readRowCountback to summary
public long readRowCount() throws IOException

Read a row count.

Returns:long

the row count

Exceptions
IOException:
on failure
readShortback to summary
private short readShort() throws IOException

Read a short.

Returns:short

the value

Exceptions
IOException:
on failure
readStringback to summary
public String readString() throws IOException

Read a string.

Returns:String

the value

Exceptions
IOException:
on failure
readTypeInfoback to summary
public TypeInfo readTypeInfo() throws IOException

Read a type information.

Returns:TypeInfo

the type information

Exceptions
IOException:
on failure
readTypeInfo19back to summary
private TypeInfo readTypeInfo19() throws IOException
readTypeInfo20back to summary
private TypeInfo readTypeInfo20() throws IOException
readTypeInfoEnumback to summary
private ExtTypeInfo readTypeInfoEnum() throws IOException
readTypeInfoGeometryback to summary
private ExtTypeInfo readTypeInfoGeometry() throws IOException
readTypeInfoRowback to summary
private ExtTypeInfo readTypeInfoRow() throws IOException
readValueback to summary
public Value readValue(TypeInfo columnType) throws IOException

Read a value.

Parameters
columnType:TypeInfo

the data type of value, or null

Returns:Value

the value

Exceptions
IOException:
on failure
setSessionback to summary
public void setSession(Session session)

Set the session.

Parameters
session:Session

the session

setSSLback to summary
public void setSSL(boolean ssl)

Enable or disable SSL.

Parameters
ssl:boolean

the new value

setVersionback to summary
public void setVersion(int version)
unlockback to summary
private void unlock()

Unlocks this object.

See Also
lock()
verifyLobMacback to summary
public void verifyLobMac(byte[] hmac, long lobId)

Verify the HMAC.

Parameters
hmac:byte[]

the message authentication code

lobId:long

the lobId

Exceptions
DbException:
if the HMAC does not match
writeBooleanback to summary
public Transfer writeBoolean(boolean x) throws IOException

Write a boolean.

Parameters
x:boolean

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeByteback to summary
public Transfer writeByte(byte x) throws IOException

Write a byte.

Parameters
x:byte

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeBytePrecisionWithDefaultback to summary
private void writeBytePrecisionWithDefault(long precision) throws IOException
writeBytesback to summary
public Transfer writeBytes(byte[] data) throws IOException

Write a byte array.

Parameters
data:byte[]

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeBytesback to summary
public Transfer writeBytes(byte[] buff, int off, int len) throws IOException

Write a number of bytes.

Parameters
buff:byte[]

the value

off:int

the offset

len:int

the length

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeByteScaleWithDefaultback to summary
private void writeByteScaleWithDefault(int scale) throws IOException
writeDoubleback to summary
private Transfer writeDouble(double i) throws IOException

Write a double.

Parameters
i:double

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeFloatback to summary
private Transfer writeFloat(float i) throws IOException

Write a float.

Parameters
i:float

the value

Returns:Transfer

itself

writeIntback to summary
public Transfer writeInt(int x) throws IOException

Write an int.

Parameters
x:int

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeLongback to summary
public Transfer writeLong(long x) throws IOException

Write a long.

Parameters
x:long

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeRowCountback to summary
public Transfer writeRowCount(long rowCount) throws IOException

Write a row count.

Parameters
rowCount:long

the row count

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeShortback to summary
private Transfer writeShort(short x) throws IOException

Write a short.

Parameters
x:short

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeStringback to summary
public Transfer writeString(String s) throws IOException

Write a string. The maximum string length is Integer.MAX_VALUE.

Parameters
s:String

the value

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeTypeInfoback to summary
public Transfer writeTypeInfo(TypeInfo type) throws IOException

Write value type, precision, and scale.

Parameters
type:TypeInfo

data type information

Returns:Transfer

itself

Exceptions
IOException:
on failure
writeTypeInfo19back to summary
private void writeTypeInfo19(TypeInfo type) throws IOException
writeTypeInfo20back to summary
private void writeTypeInfo20(TypeInfo type) throws IOException
writeTypeInfoEnumback to summary
private void writeTypeInfoEnum(TypeInfo type) throws IOException
writeTypeInfoGeometryback to summary
private void writeTypeInfoGeometry(TypeInfo type) throws IOException
writeTypeInfoRowback to summary
private void writeTypeInfoRow(TypeInfo type) throws IOException
writeValueback to summary
public void writeValue(Value v) throws IOException

Write a value.

Parameters
v:Value

the value

Exceptions
IOException:
on failure