Class BlockMarshaller

  • All Implemented Interfaces:
    java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.io.ObjectOutput, java.lang.AutoCloseable, ByteOutput, Marshaller

    public final class BlockMarshaller
    extends java.lang.Object
    implements Marshaller
    • Field Detail

      • buffer

        private final byte[] buffer
      • position

        private int position
    • Constructor Detail

      • BlockMarshaller

        BlockMarshaller​(RiverMarshaller riverMarshaller,
                        int blockSize)
    • Method Detail

      • start

        public void start​(ByteOutput newOutput)
                   throws java.io.IOException
        Description copied from interface: Marshaller
        Begin marshalling to a stream.
        Specified by:
        start in interface Marshaller
        Parameters:
        newOutput - the new stream
        Throws:
        java.io.IOException - if an error occurs during setup, such as an error writing the header
      • clearInstanceCache

        public void clearInstanceCache()
                                throws java.io.IOException
        Description copied from interface: Marshaller
        Discard the instance cache. May also discard the class cache in implementations that do not support separated class and instance caches.
        Specified by:
        clearInstanceCache in interface Marshaller
        Throws:
        java.io.IOException - if an error occurs
      • clearClassCache

        public void clearClassCache()
                             throws java.io.IOException
        Description copied from interface: Marshaller
        Discard the class cache. Implicitly also discards the instance cache.
        Specified by:
        clearClassCache in interface Marshaller
        Throws:
        java.io.IOException - if an error occurs
      • finish

        public void finish()
                    throws java.io.IOException
        Description copied from interface: Marshaller
        Finish marshalling to a stream. Any transient class or instance cache is discarded. The stream is released. No further marshalling may be done until the Marshaller.start(ByteOutput) method is again invoked.
        Specified by:
        finish in interface Marshaller
        Throws:
        java.io.IOException - if an error occurs
      • writeObject

        public void writeObject​(java.lang.Object obj)
                         throws java.io.IOException
        Specified by:
        writeObject in interface java.io.ObjectOutput
        Throws:
        java.io.IOException
      • writeObjectUnshared

        public void writeObjectUnshared​(java.lang.Object obj)
                                 throws java.io.IOException
        Description copied from interface: Marshaller
        Write an object to the underlying storage or stream as a new instance. The class that implements this interface defines how the object is written.
        Specified by:
        writeObjectUnshared in interface Marshaller
        Parameters:
        obj - the object to be written
        Throws:
        java.io.IOException - if an error occurs
      • doWriteObject

        private void doWriteObject​(java.lang.Object obj,
                                   boolean unshared)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(int v)
                   throws java.io.IOException
        Description copied from interface: ByteOutput
        Writes to the output stream the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
        Specified by:
        write in interface ByteOutput
        Specified by:
        write in interface java.io.DataOutput
        Specified by:
        write in interface java.io.ObjectOutput
        Parameters:
        v - the byte to write
        Throws:
        java.io.IOException - if an error occurs
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Description copied from interface: ByteOutput
        Write all the bytes from the given array to the stream.
        Specified by:
        write in interface ByteOutput
        Specified by:
        write in interface java.io.DataOutput
        Specified by:
        write in interface java.io.ObjectOutput
        Parameters:
        b - the byte array
        Throws:
        java.io.IOException - if an error occurs
      • write

        public void write​(byte[] bytes,
                          int off,
                          int len)
                   throws java.io.IOException
        Description copied from interface: ByteOutput
        Write some of the bytes from the given array to the stream.
        Specified by:
        write in interface ByteOutput
        Specified by:
        write in interface java.io.DataOutput
        Specified by:
        write in interface java.io.ObjectOutput
        Parameters:
        bytes - the byte array
        off - the index to start writing from
        len - the number of bytes to write
        Throws:
        java.io.IOException - if an error occurs
      • writeBoolean

        public void writeBoolean​(boolean v)
                          throws java.io.IOException
        Specified by:
        writeBoolean in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeByte

        public void writeByte​(int v)
                       throws java.io.IOException
        Specified by:
        writeByte in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeShort

        public void writeShort​(int v)
                        throws java.io.IOException
        Specified by:
        writeShort in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeChar

        public void writeChar​(int v)
                       throws java.io.IOException
        Specified by:
        writeChar in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeInt

        public void writeInt​(int v)
                      throws java.io.IOException
        Specified by:
        writeInt in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeLong

        public void writeLong​(long v)
                       throws java.io.IOException
        Specified by:
        writeLong in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeFloat

        public void writeFloat​(float v)
                        throws java.io.IOException
        Specified by:
        writeFloat in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeDouble

        public void writeDouble​(double v)
                         throws java.io.IOException
        Specified by:
        writeDouble in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeBytes

        public void writeBytes​(java.lang.String s)
                        throws java.io.IOException
        Specified by:
        writeBytes in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeChars

        public void writeChars​(java.lang.String s)
                        throws java.io.IOException
        Specified by:
        writeChars in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • writeUTF

        public void writeUTF​(java.lang.String s)
                      throws java.io.IOException
        Specified by:
        writeUTF in interface java.io.DataOutput
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in interface java.io.ObjectOutput
        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
        Specified by:
        close in interface java.io.ObjectOutput
        Throws:
        java.io.IOException