Class AtomicObjectOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class AtomicObjectOutputStream
    extends java.io.OutputStream
    Output stream writing content to a LockFile which is committed on close(). The stream checks if the hash of the stream content matches the id.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void abort()
      Aborts the stream.
      void close()
      AnyLongObjectId getId()
      Get the id.
      private void verifyHash()  
      void write​(byte[] b)
      void write​(byte[] b, int off, int len)
      void write​(int b)
      • Methods inherited from class java.io.OutputStream

        flush, nullOutputStream
      • Methods inherited from class java.lang.Object

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

      • out

        private java.security.DigestOutputStream out
      • aborted

        private boolean aborted
    • Constructor Detail

      • AtomicObjectOutputStream

        public AtomicObjectOutputStream​(java.nio.file.Path path,
                                        AnyLongObjectId id)
                                 throws java.io.IOException
        Constructor for AtomicObjectOutputStream.
        Parameters:
        path - a Path object.
        id - a AnyLongObjectId object.
        Throws:
        java.io.IOException
      • AtomicObjectOutputStream

        public AtomicObjectOutputStream​(java.nio.file.Path path)
                                 throws java.io.IOException
        Constructor for AtomicObjectOutputStream.
        Parameters:
        path - a Path object.
        Throws:
        java.io.IOException
    • Method Detail

      • getId

        @Nullable
        public AnyLongObjectId getId()
        Get the id.
        Returns:
        content hash of the object which was streamed through this stream. May return null if called before closing this stream.
      • write

        public void write​(int b)
                   throws java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException
      • verifyHash

        private void verifyHash()
      • abort

        public void abort()
        Aborts the stream. Temporary file will be deleted