Class BinaryDataFileSync

java.lang.Object
org.apache.jena.dboe.base.file.BinaryDataFileSync
All Implemented Interfaces:
org.apache.jena.atlas.lib.Closeable, org.apache.jena.atlas.lib.Sync, BinaryDataFile

public class BinaryDataFileSync extends Object implements BinaryDataFile
Add synchronization to all BinaryDataFile operations. This gives the correct thread-safe operation but isn't necessarily the best way to do it.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
    Is it open?
    long
    Return the length of the file (including any buffered writes)
    void
    Open the file
    int
    read(long posn, byte[] b)
    Read into a byte array, returning the number of bytes read.
    int
    read(long posn, byte[] b, int start, int length)
    Read into a byte array, returning the number of bytes read.
    void
     
    void
    truncate(long length)
    Truncate the file
    long
    write(byte[] b)
    Write bytes - bytes are always written to the end of the file.
    long
    write(byte[] b, int start, int length)
    Write bytes - bytes are always written to the end of the file.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.jena.dboe.base.file.BinaryDataFile

    isEmpty
  • Constructor Details

    • BinaryDataFileSync

      public BinaryDataFileSync(BinaryDataFile other)
  • Method Details

    • open

      public void open()
      Description copied from interface: BinaryDataFile
      Open the file
      Specified by:
      open in interface BinaryDataFile
    • isOpen

      public boolean isOpen()
      Description copied from interface: BinaryDataFile
      Is it open?
      Specified by:
      isOpen in interface BinaryDataFile
    • read

      public int read(long posn, byte[] b)
      Description copied from interface: BinaryDataFile
      Read into a byte array, returning the number of bytes read. Reads are at an absolute position and a read is atomic/thread-safe.
      Specified by:
      read in interface BinaryDataFile
      Parameters:
      posn - Location of the read operation.
      b - byte array
      Returns:
      The number of bytes read
    • read

      public int read(long posn, byte[] b, int start, int length)
      Description copied from interface: BinaryDataFile
      Read into a byte array, returning the number of bytes read. Reads are at an absolute position and a read is atomic/thread-safe.
      Specified by:
      read in interface BinaryDataFile
      Parameters:
      posn - Location of the read operation.
      start - of bytesarray to read into
      length - Maximum number of bytes to read.
      Returns:
      The number of bytes read
    • write

      public long write(byte[] b)
      Description copied from interface: BinaryDataFile
      Write bytes - bytes are always written to the end of the file. Return the location where the write started.
      Specified by:
      write in interface BinaryDataFile
    • write

      public long write(byte[] b, int start, int length)
      Description copied from interface: BinaryDataFile
      Write bytes - bytes are always written to the end of the file. Return the location where the write started.
      Specified by:
      write in interface BinaryDataFile
    • length

      public long length()
      Description copied from interface: BinaryDataFile
      Return the length of the file (including any buffered writes)
      Specified by:
      length in interface BinaryDataFile
    • truncate

      public void truncate(long length)
      Description copied from interface: BinaryDataFile
      Truncate the file
      Specified by:
      truncate in interface BinaryDataFile
    • sync

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

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