Package org.h2gis.functions.io.utility

## Class ReadBufferManager

- java.lang.Object
- - org.h2gis.functions.io.utility.ReadBufferManager

    public final class ReadBufferManager
    extends Object

### Constructor Summary

Constructors
`ReadBufferManager​(FileChannel channel)` Instantiates a ReadBufferManager to read the specified channel
`ReadBufferManager​(FileChannel channel, int bufferSize)` Instantiates a ReadBufferManager to read the specified channel.

### Method Summary

All Methods Instance Methods Concrete Methods
`byte` `get()` Gets the byte value at the current position
`ByteBuffer` `get​(byte[] buffer)` Gets the byte[] value at the current position
`ByteBuffer` `get​(long pos, byte[] buffer)` Gets the byte[] value at the specified position
`byte` `getByte​(long bytePos)` Gets the byte value at the specified position
`double` `getDouble()` Gets the double value at the specified position
`double` `getDouble​(long bytePos)` Gets the double value at the specified position
`int` `getInt()` Gets the int value at the current position
`int` `getInt​(long bytePos)` Gets the int value at the specified position
`long` `getLength()` Gets the size of the channel
`long` `getLong()` Gets the long value at the current position
`long` `getLong​(long bytePos)` Gets the long value at the specified position
`long` `getPosition()` Gets the position of this buffer in the file it's reading.
`boolean` `isEOF()` If the current position is at the end of the channel
`void` `order​(ByteOrder order)` Specifies the byte order.
`void` `position​(long position)` Moves the current position to the specified one
`long` `remaining()` Gets the number of remaining bytes in the current file, starting from the current position
`void` `skip​(int numBytes)` skips the specified number of bytes from the current position in the channel

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

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

### Constructor Detail

#### ReadBufferManager

    public ReadBufferManager​(FileChannel channel)
                      throws IOException

Instantiates a ReadBufferManager to read the specified channel

Parameters:
  `channel` - `FileChannel`
Throws:
  `IOException`

#### ReadBufferManager

    public ReadBufferManager​(FileChannel channel,
                             int bufferSize)
                      throws IOException

Instantiates a ReadBufferManager to read the specified channel. The specified bufferSize is the size of the channel content cached in memory

Parameters:
  `channel` - `FileChannel`
  `bufferSize` - buffer size
Throws:
  `IOException`

### Method Detail

#### getByte

    public byte getByte​(long bytePos)
                 throws IOException

Gets the byte value at the specified position

Parameters:
  `bytePos` - byte position
Returns:
  byte value
Throws:
  `IOException`

#### getLength

    public long getLength()
                   throws IOException

Gets the size of the channel

Returns:
  channel size
Throws:
  `IOException`

#### order

    public void order​(ByteOrder order)

Specifies the byte order. One of the constants in `ByteBuffer`

Parameters:
  `order` - `ByteOrder`

#### getInt

    public int getInt​(long bytePos)
               throws IOException

Gets the int value at the specified position

Parameters:
  `bytePos` - byte position
Returns:
  int value
Throws:
  `IOException`

#### getLong

    public long getLong​(long bytePos)
                 throws IOException

Gets the long value at the specified position

Parameters:
  `bytePos` - byte position
Returns:
  long value
Throws:
  `IOException`

#### getLong

    public long getLong()
                 throws IOException

Gets the long value at the current position

Returns:
  long value
Throws:
  `IOException`

#### get

    public byte get()
             throws IOException

Gets the byte value at the current position

Returns:
  byte value
Throws:
  `IOException`

#### getInt

    public int getInt()
               throws IOException

Gets the int value at the current position

Returns:
  int value
Throws:
  `IOException`

#### skip

    public void skip​(int numBytes)
              throws IOException

skips the specified number of bytes from the current position in the channel

Parameters:
  `numBytes` - numBytes to move the buffer to a new position
Throws:
  `IOException`

#### get

    public ByteBuffer get​(byte[] buffer)
                   throws IOException

Gets the byte[] value at the current position

Parameters:
  `buffer` - byte array
Returns:
  ByteBuffer
Throws:
  `IOException`

#### get

    public ByteBuffer get​(long pos,
                          byte[] buffer)
                   throws IOException

Gets the byte[] value at the specified position

Parameters:
  `pos` - buffer position
  `buffer` - bytes
Returns:
  ByteBuffer
Throws:
  `IOException`

#### position

    public void position​(long position)

Moves the current position to the specified one

Parameters:
  `position` - buffer position

#### getPosition

    public long getPosition()

Gets the position of this buffer in the file it's reading.

Returns:
  index of the position

#### getDouble

    public double getDouble()
                     throws IOException

Gets the double value at the specified position

Returns:
  double value
Throws:
  `IOException`

#### getDouble

    public double getDouble​(long bytePos)
                     throws IOException

Gets the double value at the specified position

Parameters:
  `bytePos` - buffer position
Returns:
  double value
Throws:
  `IOException`

#### isEOF

    public boolean isEOF()
                  throws IOException

If the current position is at the end of the channel

Returns:
  true if the current position is at the end of the channel
Throws:
  `IOException`

#### remaining

    public long remaining()
                   throws IOException

Gets the number of remaining bytes in the current file, starting from the current position

Returns:
  a number of bytes >=0
Throws:
  `IOException`