Class LocalTextModificationAccessor

  • All Implemented Interfaces:
    java.lang.AutoCloseable, ModificationReader, ModificationWriter

    public class LocalTextModificationAccessor
    extends java.lang.Object
    implements ModificationReader, ModificationWriter, java.lang.AutoCloseable
    LocalTextModificationAccessor uses a file on local file system to store the modifications in text format, and writes modifications by appending to the tail of the file.
    • Constructor Summary

      Constructors 
      Constructor Description
      LocalTextModificationAccessor​(java.lang.String filePath)
      Construct a LocalTextModificationAccessor using a file specified by filePath.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()
      Abort last modification.
      void close()
      Release resources like streams.
      java.util.Collection<Modification> read()
      Read all modifications from a persistent medium.
      void write​(Modification mod)
      Write a new modification to the persistent medium.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LocalTextModificationAccessor

        public LocalTextModificationAccessor​(java.lang.String filePath)
        Construct a LocalTextModificationAccessor using a file specified by filePath.
        Parameters:
        filePath - the path of the file that is used for storing modifications.
    • Method Detail

      • read

        public java.util.Collection<Modification> read()
        Description copied from interface: ModificationReader
        Read all modifications from a persistent medium. If the mods file is crashed, the redundant modifications will be truncated until the file is correct.
        Specified by:
        read in interface ModificationReader
        Returns:
        a list of modifications contained the medium.
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: ModificationReader
        Release resources like streams.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface ModificationReader
        Specified by:
        close in interface ModificationWriter
        Throws:
        java.io.IOException
      • abort

        public void abort()
                   throws java.io.IOException
        Description copied from interface: ModificationWriter
        Abort last modification. Notice that after calling abort(), a fileWriter is opened.
        Specified by:
        abort in interface ModificationWriter
        Throws:
        java.io.IOException
      • write

        public void write​(Modification mod)
                   throws java.io.IOException
        Description copied from interface: ModificationWriter
        Write a new modification to the persistent medium. Notice that after calling write(), a fileWriter is opened.
        Specified by:
        write in interface ModificationWriter
        Parameters:
        mod - the modification to be written.
        Throws:
        java.io.IOException