Class 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
      void close()  
      static BufferChannelFile create​(java.lang.String filename)
      Create a BufferChannelFile
      static BufferChannelFile create​(java.lang.String filename, java.lang.String mode)
      Create a BufferChannelFile
      static BufferChannelFile createUnmanaged​(java.lang.String filename, java.lang.String mode)
      Create a BufferChannelFile with unmanaged file resources - use with care
      BufferChannel duplicate()
      Return another channel to the same storage but with independent position.
      java.lang.String getFilename()
      Filename for this BufferChannel (maybe null)
      java.lang.String getLabel()
      useful display string
      boolean isEmpty()
      Is it empty?
      long position()
      return the position
      void position​(long pos)
      set the position
      int read​(java.nio.ByteBuffer buffer)
      Read into a ByteBuffer.
      int read​(java.nio.ByteBuffer buffer, long loc)
      Read into a ByteBuffer, starting at position loc.
      long size()
      Length of storage, in bytes.
      void sync()  
      java.lang.String toString()  
      void truncate​(long length)
      Truncate the file.
      int write​(java.nio.ByteBuffer buffer)
      Write from ByteBuffer, starting at the current position.
      int write​(java.nio.ByteBuffer buffer, long loc)
      Write from ByteBuffer, starting at position loc.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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: BufferChannel
        Return another channel to the same storage but with independent position. Chaos may result due to concurrent use.
        Specified by:
        duplicate in interface BufferChannel
      • truncate

        public void truncate​(long length)
        Description copied from interface: BufferChannel
        Truncate the file.
        Specified by:
        truncate in interface BufferChannel
        See Also:
        FileChannel.truncate(long)
      • read

        public int read​(java.nio.ByteBuffer buffer)
        Description copied from interface: BufferChannel
        Read into a ByteBuffer. Returns the number of bytes read. -1 for end of file.
        Specified by:
        read in interface BufferChannel
      • read

        public int read​(java.nio.ByteBuffer buffer,
                        long loc)
        Description copied from interface: BufferChannel
        Read into a ByteBuffer, starting at position loc. Return the number of bytes read. loc must be within the file.
        Specified by:
        read in interface BufferChannel
      • write

        public int write​(java.nio.ByteBuffer buffer)
        Description copied from interface: BufferChannel
        Write from ByteBuffer, starting at the current position. Return the number of bytes written
        Specified by:
        write in interface BufferChannel
      • write

        public int write​(java.nio.ByteBuffer buffer,
                         long loc)
        Description copied from interface: BufferChannel
        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
        Specified by:
        write in interface BufferChannel
      • size

        public long size()
        Description copied from interface: BufferChannel
        Length of storage, in bytes.
        Specified by:
        size in interface BufferChannel
      • sync

        public void sync()
        Specified by:
        sync in interface org.apache.jena.atlas.lib.Sync
      • close

        public void close()
        Specified by:
        close in interface org.apache.jena.atlas.lib.Closeable
      • getLabel

        public java.lang.String getLabel()
        Description copied from interface: BufferChannel
        useful display string
        Specified by:
        getLabel in interface BufferChannel
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getFilename

        public java.lang.String getFilename()
        Description copied from interface: BufferChannel
        Filename for this BufferChannel (maybe null)
        Specified by:
        getFilename in interface BufferChannel