org.h2.value

## Class Transfer

- java.lang.Object
- - org.h2.value.Transfer

    public class Transfer
    extends java.lang.Object

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
Constructor and Description
`Transfer(SessionInterface session)` Create a new transfer object for the specified session.

### Method Summary

Methods
`void` `close()` Close the transfer object and the socket.
`void` `flush()` Write pending changes.
`java.net.Socket` `getSocket()` Get the socket.
`void` `init()` Initialize the transfer object.
`boolean` `isClosed()`
`Transfer` `openNewConnection()` Open a new new connection to the same address and port as this one.
`boolean` `readBoolean()` Read a boolean.
`byte[]` `readBytes()` Read a byte array.
`void` `readBytes(byte[] buff, int off, int len)` Read a number of bytes.
`int` `readInt()` Read an int.
`long` `readLong()` Read a long.
`java.lang.String` `readString()` Read a string.
`Value` `readValue()` Read a value.
`void` `setSession(SessionInterface session)` Set the session.
`void` `setSocket(java.net.Socket s)` Set the socket this object uses.
`void` `setSSL(boolean ssl)` Enable or disable SSL.
`void` `setVersion(int version)`
`void` `verifyLobMac(byte[] hmac, long lobId)` Verify the HMAC.
`Transfer` `writeBoolean(boolean x)` Write a boolean.
`Transfer` `writeBytes(byte[] data)` Write a byte array.
`Transfer` `writeBytes(byte[] buff, int off, int len)` Write a number of bytes.
`Transfer` `writeInt(int x)` Write an int.
`Transfer` `writeLong(long x)` Write a long.
`Transfer` `writeString(java.lang.String s)` Write a string.
`void` `writeValue(Value v)` Write a value.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### Transfer

    public Transfer(SessionInterface session)

Create a new transfer object for the specified session.

Parameters:
  `session` - the session

### Method Detail

#### setSocket

    public void setSocket(java.net.Socket s)

Set the socket this object uses.

Parameters:
  `s` - the socket

#### init

    public void init()
              throws java.io.IOException

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

Throws:
  `java.io.IOException`

#### flush

    public void flush()
               throws java.io.IOException

Write pending changes.

Throws:
  `java.io.IOException`

#### writeBoolean

    public Transfer writeBoolean(boolean x)
                          throws java.io.IOException

Write a boolean.

Parameters:
  `x` - the value
Returns:
  itself
Throws:
  `java.io.IOException`

#### readBoolean

    public boolean readBoolean()
                        throws java.io.IOException

Read a boolean.

Returns:
  the value
Throws:
  `java.io.IOException`

#### writeInt

    public Transfer writeInt(int x)
                      throws java.io.IOException

Write an int.

Parameters:
  `x` - the value
Returns:
  itself
Throws:
  `java.io.IOException`

#### readInt

    public int readInt()
                throws java.io.IOException

Read an int.

Returns:
  the value
Throws:
  `java.io.IOException`

#### writeLong

    public Transfer writeLong(long x)
                       throws java.io.IOException

Write a long.

Parameters:
  `x` - the value
Returns:
  itself
Throws:
  `java.io.IOException`

#### readLong

    public long readLong()
                  throws java.io.IOException

Read a long.

Returns:
  the value
Throws:
  `java.io.IOException`

#### writeString

    public Transfer writeString(java.lang.String s)
                         throws java.io.IOException

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

Parameters:
  `s` - the value
Returns:
  itself
Throws:
  `java.io.IOException`

#### readString

    public java.lang.String readString()
                                throws java.io.IOException

Read a string.

Returns:
  the value
Throws:
  `java.io.IOException`

#### writeBytes

    public Transfer writeBytes(byte[] data)
                        throws java.io.IOException

Write a byte array.

Parameters:
  `data` - the value
Returns:
  itself
Throws:
  `java.io.IOException`

#### writeBytes

    public Transfer writeBytes(byte[] buff,
                      int off,
                      int len)
                        throws java.io.IOException

Write a number of bytes.

Parameters:
  `buff` - the value
  `off` - the offset
  `len` - the length
Returns:
  itself
Throws:
  `java.io.IOException`

#### readBytes

    public byte[] readBytes()
                     throws java.io.IOException

Read a byte array.

Returns:
  the value
Throws:
  `java.io.IOException`

#### readBytes

    public void readBytes(byte[] buff,
                 int off,
                 int len)
                   throws java.io.IOException

Read a number of bytes.

Parameters:
  `buff` - the target buffer
  `off` - the offset
  `len` - the number of bytes to read
Throws:
  `java.io.IOException`

#### close

    public void close()

Close the transfer object and the socket.

#### writeValue

    public void writeValue(Value v)
                    throws java.io.IOException

Write a value.

Parameters:
  `v` - the value
Throws:
  `java.io.IOException`

#### readValue

    public Value readValue()
                    throws java.io.IOException

Read a value.

Returns:
  the value
Throws:
  `java.io.IOException`

#### getSocket

    public java.net.Socket getSocket()

Get the socket.

Returns:
  the socket

#### setSession

    public void setSession(SessionInterface session)

Set the session.

Parameters:
  `session` - the session

#### setSSL

    public void setSSL(boolean ssl)

Enable or disable SSL.

Parameters:
  `ssl` - the new value

#### openNewConnection

    public Transfer openNewConnection()
                               throws java.io.IOException

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

Returns:
  the new transfer object
Throws:
  `java.io.IOException`

#### setVersion

    public void setVersion(int version)

#### isClosed

    public boolean isClosed()

#### verifyLobMac

    public void verifyLobMac(byte[] hmac,
                    long lobId)

Verify the HMAC.

Parameters:
  `hmac` - the message authentication code
  `lobId` - the lobId
Throws:
  `DbException` - if the HMAC does not match