Class CompositeByteArrayRelativeWriter

  • All Implemented Interfaces:
    IoRelativeWriter

    public class CompositeByteArrayRelativeWriter
    extends CompositeByteArrayRelativeBase
    implements IoRelativeWriter
    Provides restricted, relative, write-only access to the bytes in a CompositeByteArray. Using this interface has the advantage that it can be automatically determined when a component ByteArray can no longer be written to, and thus components can be automatically flushed. This makes it easier to use pooling for underlying ByteArrays. By providing an appropriate Expander it is also possible to automatically add more backing storage as more data is written.

    TODO: Get flushing working.
    Author:
    Apache MINA Project
    • Constructor Detail

      • CompositeByteArrayRelativeWriter

        public CompositeByteArrayRelativeWriter​(CompositeByteArray cba,
                                                CompositeByteArrayRelativeWriter.Expander expander,
                                                CompositeByteArrayRelativeWriter.Flusher flusher,
                                                boolean autoFlush)
        Creates a new instance of CompositeByteArrayRelativeWriter.
        Parameters:
        cba - The CompositeByteArray to use to back this class
        expander - The expander. Will increase the size of the internal ByteArray
        flusher - Flushed the ByteArray when necessary
        autoFlush - Should this class automatically flush?
    • Method Detail

      • flush

        public void flush()
        Flush to the current index.
      • flushTo

        public void flushTo​(int index)
        Flush to the given index.
        Parameters:
        index - The end position
      • skip

        public void skip​(int length)
        Advances the writer by the given number of bytes.
        Specified by:
        skip in interface IoRelativeWriter
        Parameters:
        length - The number of bytes to skip
      • cursorPassedFirstComponent

        protected void cursorPassedFirstComponent()
        Description copied from class: CompositeByteArrayRelativeBase
        Called whenever the cursor has passed from the cba's first component. As the first component is no longer used, this provides a good opportunity for subclasses to perform some action on it (such as freeing it).
        Specified by:
        cursorPassedFirstComponent in class CompositeByteArrayRelativeBase
      • put

        public void put​(byte b)
        Puts a byte and advances the reader.
        Specified by:
        put in interface IoRelativeWriter
        Parameters:
        b - The byte to put
      • put

        public void put​(IoBuffer bb)
        Puts enough bytes to fill the IoBuffer and advances the reader.
        Specified by:
        put in interface IoRelativeWriter
        Parameters:
        bb - The bytes to put
      • putShort

        public void putShort​(short s)
        Puts a short and advances the reader.
        Specified by:
        putShort in interface IoRelativeWriter
        Parameters:
        s - The short to put
      • putInt

        public void putInt​(int i)
        Puts an int and advances the reader.
        Specified by:
        putInt in interface IoRelativeWriter
        Parameters:
        i - The int to put
      • putLong

        public void putLong​(long l)
        Puts a long and advances the reader.
        Specified by:
        putLong in interface IoRelativeWriter
        Parameters:
        l - The long to put
      • putFloat

        public void putFloat​(float f)
        Puts a float and advances the reader.
        Specified by:
        putFloat in interface IoRelativeWriter
        Parameters:
        f - The float to put
      • putDouble

        public void putDouble​(double d)
        Puts a double and advances the reader.
        Specified by:
        putDouble in interface IoRelativeWriter
        Parameters:
        d - The double to put
      • putChar

        public void putChar​(char c)
        Puts a char and advances the reader.
        Specified by:
        putChar in interface IoRelativeWriter
        Parameters:
        c - The char to put