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 Constructor Description ReadBufferManager(FileChannel channel)Instantiates a ReadBufferManager to read the specified channelReadBufferManager(FileChannel channel, int bufferSize)Instantiates a ReadBufferManager to read the specified channel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byteget()Gets the byte value at the current positionByteBufferget(byte[] buffer)Gets the byte[] value at the current positionByteBufferget(long pos, byte[] buffer)Gets the byte[] value at the specified positionbytegetByte(long bytePos)Gets the byte value at the specified positiondoublegetDouble()Gets the double value at the specified positiondoublegetDouble(long bytePos)Gets the double value at the specified positionintgetInt()Gets the int value at the current positionintgetInt(long bytePos)Gets the int value at the specified positionlonggetLength()Gets the size of the channellonggetLong()Gets the long value at the current positionlonggetLong(long bytePos)Gets the long value at the specified positionlonggetPosition()Gets the positionf of this buffer in the file it's reading.booleanisEOF()If the current position is at the end of the channelvoidorder(ByteOrder order)Specifies the byte order.voidposition(long position)Moves the current position to the specified onelongremaining()Gets the number of remaining bytes in the current file, starting from the current positionvoidskip(int numBytes)skips the specified number of bytes from the current position in the channel
-
-
-
Constructor Detail
-
ReadBufferManager
public ReadBufferManager(FileChannel channel) throws IOException
Instantiates a ReadBufferManager to read the specified channel- Parameters:
channel-- 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-bufferSize-- Throws:
IOException
-
-
Method Detail
-
getByte
public byte getByte(long bytePos) throws IOExceptionGets the byte value at the specified position- Parameters:
bytePos-- Returns:
- Throws:
IOException
-
getLength
public long getLength() throws IOExceptionGets the size of the channel- Returns:
- Throws:
IOException
-
order
public void order(ByteOrder order)
Specifies the byte order. One of the constants inByteBuffer- Parameters:
order-
-
getInt
public int getInt(long bytePos) throws IOExceptionGets the int value at the specified position- Parameters:
bytePos-- Returns:
- Throws:
IOException
-
getLong
public long getLong(long bytePos) throws IOExceptionGets the long value at the specified position- Parameters:
bytePos-- Returns:
- Throws:
IOException
-
getLong
public long getLong() throws IOExceptionGets the long value at the current position- Returns:
- Throws:
IOException
-
get
public byte get() throws IOExceptionGets the byte value at the current position- Returns:
- Throws:
IOException
-
getInt
public int getInt() throws IOExceptionGets the int value at the current position- Returns:
- Throws:
IOException
-
skip
public void skip(int numBytes) throws IOExceptionskips the specified number of bytes from the current position in the channel- Parameters:
numBytes-- Throws:
IOException
-
get
public ByteBuffer get(byte[] buffer) throws IOException
Gets the byte[] value at the current position- Parameters:
buffer-- Returns:
- Throws:
IOException
-
get
public ByteBuffer get(long pos, byte[] buffer) throws IOException
Gets the byte[] value at the specified position- Parameters:
pos-buffer-- Returns:
- Throws:
IOException
-
position
public void position(long position)
Moves the current position to the specified one- Parameters:
position-
-
getPosition
public long getPosition()
Gets the positionf of this buffer in the file it's reading.- Returns:
-
getDouble
public double getDouble() throws IOExceptionGets the double value at the specified position- Returns:
- Throws:
IOException
-
getDouble
public double getDouble(long bytePos) throws IOExceptionGets the double value at the specified position- Parameters:
bytePos-- Returns:
- Throws:
IOException
-
isEOF
public boolean isEOF() throws IOExceptionIf the current position is at the end of the channel- Returns:
- Throws:
IOException
-
remaining
public long remaining() throws IOExceptionGets the number of remaining bytes in the current file, starting from the current position- Returns:
- a number of bytes >=0
- Throws:
IOException
-
-