Package org.apache.jena.dboe.base.file
Class BufferChannelFile
- java.lang.Object
-
- org.apache.jena.dboe.base.file.BufferChannelFile
-
- All Implemented Interfaces:
org.apache.jena.atlas.lib.Closeable,org.apache.jena.atlas.lib.Sync,BufferChannel
public class BufferChannelFile extends java.lang.Object implements BufferChannel
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static BufferChannelFilecreate(java.lang.String filename)Create a BufferChannelFilestatic BufferChannelFilecreate(java.lang.String filename, java.lang.String mode)Create a BufferChannelFilestatic BufferChannelFilecreateUnmanaged(java.lang.String filename, java.lang.String mode)Create a BufferChannelFile with unmanaged file resources - use with careBufferChannelduplicate()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.voidsync()java.lang.StringtoString()voidtruncate(long length)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
-
create
public static BufferChannelFile create(java.lang.String filename)
Create a BufferChannelFile
-
create
public static BufferChannelFile create(java.lang.String filename, java.lang.String mode)
Create a BufferChannelFile
-
createUnmanaged
public static BufferChannelFile createUnmanaged(java.lang.String filename, java.lang.String mode)
Create a BufferChannelFile with unmanaged file resources - use with care
-
duplicate
public BufferChannel duplicate()
Description copied from interface:BufferChannelReturn another channel to the same storage but with independent position. Chaos may result due to concurrent use.- Specified by:
duplicatein interfaceBufferChannel
-
position
public long position()
Description copied from interface:BufferChannelreturn the position- Specified by:
positionin interfaceBufferChannel
-
position
public void position(long pos)
Description copied from interface:BufferChannelset the position- Specified by:
positionin interfaceBufferChannel
-
truncate
public void truncate(long length)
Description copied from interface:BufferChannelTruncate the file.- Specified by:
truncatein interfaceBufferChannel- See Also:
FileChannel.truncate(long)
-
read
public int read(java.nio.ByteBuffer buffer)
Description copied from interface:BufferChannelRead into a ByteBuffer. Returns the number of bytes read. -1 for end of file.- Specified by:
readin interfaceBufferChannel
-
read
public int read(java.nio.ByteBuffer buffer, long loc)Description copied from interface:BufferChannelRead into a ByteBuffer, starting at position loc. Return the number of bytes read. loc must be within the file.- Specified by:
readin interfaceBufferChannel
-
write
public int write(java.nio.ByteBuffer buffer)
Description copied from interface:BufferChannelWrite from ByteBuffer, starting at the current position. Return the number of bytes written- Specified by:
writein interfaceBufferChannel
-
write
public int write(java.nio.ByteBuffer buffer, long loc)Description copied from interface:BufferChannelWrite from ByteBuffer, starting at position loc. Return the number of bytes written. loc must be within 0 to length - writing at length is append- Specified by:
writein interfaceBufferChannel
-
size
public long size()
Description copied from interface:BufferChannelLength of storage, in bytes.- Specified by:
sizein interfaceBufferChannel
-
isEmpty
public boolean isEmpty()
Description copied from interface:BufferChannelIs it empty?- Specified by:
isEmptyin interfaceBufferChannel
-
sync
public void sync()
- Specified by:
syncin interfaceorg.apache.jena.atlas.lib.Sync
-
close
public void close()
- Specified by:
closein interfaceorg.apache.jena.atlas.lib.Closeable
-
getLabel
public java.lang.String getLabel()
Description copied from interface:BufferChanneluseful display string- Specified by:
getLabelin interfaceBufferChannel
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getFilename
public java.lang.String getFilename()
Description copied from interface:BufferChannelFilename for this BufferChannel (maybe null)- Specified by:
getFilenamein interfaceBufferChannel
-
-