Package org.apache.jena.dboe.base.file
Interface BufferChannel
- All Superinterfaces:
org.apache.jena.atlas.lib.Closeable,org.apache.jena.atlas.lib.Sync
- All Known Implementing Classes:
BufferChannelFile,BufferChannelMem
public interface BufferChannel
extends org.apache.jena.atlas.lib.Sync, org.apache.jena.atlas.lib.Closeable
Interface to storage : a simplified version of FileChannel. Read and write
bytes, passed via ByteBuffers, addressed by file location. This interface is
not suitable for memory mapped I/O - there is no ability to use slices of a
memory mapped file. This interface does not insert size of ByteBuffer, the size
of ByteBuffer passed to read controls the number of bytes read. Having our
own abstraction enables us to implement memory-backed versions.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturn another channel to the same storage but with independent position.Filename for this BufferChannel (maybe null)getLabel()useful display stringbooleanisEmpty()Is it empty?longposition()return the positionvoidposition(long pos) set the positionintread(ByteBuffer buffer) Read into a ByteBuffer.intread(ByteBuffer buffer, long loc) Read into a ByteBuffer, starting at position loc.longsize()Length of storage, in bytes.voidtruncate(long size) Truncate the file.intwrite(ByteBuffer buffer) Write from ByteBuffer, starting at the current position.intwrite(ByteBuffer buffer, long loc) Write from ByteBuffer, starting at position loc.Methods inherited from interface org.apache.jena.atlas.lib.Closeable
closeMethods inherited from interface org.apache.jena.atlas.lib.Sync
sync
-
Method Details
-
duplicate
BufferChannel duplicate()Return another channel to the same storage but with independent position. Chaos may result due to concurrent use. -
position
long position()return the position -
position
void position(long pos) set the position -
read
Read into a ByteBuffer. Returns the number of bytes read. -1 for end of file. -
read
Read into a ByteBuffer, starting at position loc. Return the number of bytes read. loc must be within the file. -
write
Write from ByteBuffer, starting at the current position. Return the number of bytes written -
write
Write from ByteBuffer, starting at position loc. Return the number of bytes written. loc must be within 0 to length - writing at length is append -
truncate
void truncate(long size) Truncate the file.- See Also:
-
size
long size()Length of storage, in bytes. -
isEmpty
boolean isEmpty()Is it empty? -
getLabel
String getLabel()useful display string -
getFilename
String getFilename()Filename for this BufferChannel (maybe null)
-