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.CloseableInterface 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:
BlockAccess,FileChannel
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BufferChannelduplicate()Return another channel to the same storage but with independent position.java.lang.StringgetFilename()Filename for this BufferChannel (maybe null)java.lang.StringgetLabel()useful display stringbooleanisEmpty()Is it empty?longposition()return the positionvoidposition(long pos)set the positionintread(java.nio.ByteBuffer buffer)Read into a ByteBuffer.intread(java.nio.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(java.nio.ByteBuffer buffer)Write from ByteBuffer, starting at the current position.intwrite(java.nio.ByteBuffer buffer, long loc)Write from ByteBuffer, starting at position loc.
-
-
-
Method Detail
-
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
int read(java.nio.ByteBuffer buffer)
Read into a ByteBuffer. Returns the number of bytes read. -1 for end of file.
-
read
int read(java.nio.ByteBuffer buffer, long loc)Read into a ByteBuffer, starting at position loc. Return the number of bytes read. loc must be within the file.
-
write
int write(java.nio.ByteBuffer buffer)
Write from ByteBuffer, starting at the current position. Return the number of bytes written
-
write
int write(java.nio.ByteBuffer buffer, long loc)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:
FileChannel.truncate(long)
-
size
long size()
Length of storage, in bytes.
-
isEmpty
boolean isEmpty()
Is it empty?
-
getLabel
java.lang.String getLabel()
useful display string
-
getFilename
java.lang.String getFilename()
Filename for this BufferChannel (maybe null)
-
-