Class NioByteStoreAccess
java.lang.Object
uk.ac.starlink.table.storage.NioByteStoreAccess
- All Implemented Interfaces:
ByteStoreAccess
Partial implementation of ByteStoreAccess.
Not thread-safe.
- Since:
- 20 Aug 2010
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBuffer[]copyBuffers(ByteBuffer[] bufs) Utility method to make a deep copy of an array of ByteBuffers.static ByteStoreAccesscreateAccess(ByteBuffer[] bbufs) Returns a reader implementation for an array of ByteBuffers.protected abstract ByteBuffergetBuffer(int nbyte) Returns a buffer with at least the requested number of bytes between the current position and the limit.bytereadByte()Reads a byte from the current position.voidreadBytes(byte[] b, int offset, int length) Reads bytes into a buffer from the current position.charreadChar()Reads a char from the current position.doubleReads a double from the current position.floatReads a float from the current position.intreadInt()Reads an int from the current position.longreadLong()Reads a long from the current position.shortReads a short from the current position.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ByteStoreAccess
seek, skip
-
Constructor Details
-
NioByteStoreAccess
public NioByteStoreAccess()
-
-
Method Details
-
getBuffer
Returns a buffer with at least the requested number of bytes between the current position and the limit. Whennbytebytes have been read from the returned buffer, the current position of this ByteStoreAccess will have advanced bynbytebytes. The position in the case that this call is made with no corresponding read is undefined, so it's important that the read is actually done (don't call this method speculatively).If no such buffer is available (the end of the storage has been reached), then an IOException will be thrown.
- Parameters:
nbyte- number of bytes required- Returns:
- buffer from which
nbytebytes can be read - Throws:
IOException
-
readByte
Description copied from interface:ByteStoreAccessReads a byte from the current position.- Specified by:
readBytein interfaceByteStoreAccess- Returns:
- read value
- Throws:
IOException
-
readShort
Description copied from interface:ByteStoreAccessReads a short from the current position.- Specified by:
readShortin interfaceByteStoreAccess- Returns:
- read value
- Throws:
IOException
-
readChar
Description copied from interface:ByteStoreAccessReads a char from the current position.- Specified by:
readCharin interfaceByteStoreAccess- Returns:
- read value
- Throws:
IOException
-
readInt
Description copied from interface:ByteStoreAccessReads an int from the current position.- Specified by:
readIntin interfaceByteStoreAccess- Returns:
- read value
- Throws:
IOException
-
readLong
Description copied from interface:ByteStoreAccessReads a long from the current position.- Specified by:
readLongin interfaceByteStoreAccess- Returns:
- read value
- Throws:
IOException
-
readFloat
Description copied from interface:ByteStoreAccessReads a float from the current position.- Specified by:
readFloatin interfaceByteStoreAccess- Returns:
- read value
- Throws:
IOException
-
readDouble
Description copied from interface:ByteStoreAccessReads a double from the current position.- Specified by:
readDoublein interfaceByteStoreAccess- Returns:
- read value
- Throws:
IOException
-
readBytes
Description copied from interface:ByteStoreAccessReads bytes into a buffer from the current position.- Specified by:
readBytesin interfaceByteStoreAccess- Parameters:
b- buffer to receive bytesoffset- offset intobfor first bytelength- number of bytes to read- Throws:
IOException
-
copyBuffers
Utility method to make a deep copy of an array of ByteBuffers.- Parameters:
bufs- input buffers- Returns:
- matching array with buffers that are duplicates of the input elements
-
createAccess
Returns a reader implementation for an array of ByteBuffers.- Parameters:
bbufs- buffer array- Returns:
- reader implementation
-