Class RawOutputHandler

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

    public class RawOutputHandler
    extends ProtocolOutputHandler
    A RawOutputHandler handles a raw byte stream and pass them to an output listener on every call to flush() without any protocol specifiy actions.
    Author:
    IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addByte​(byte b)
      Add a byte to the current chunk.
      protected void addBytes​(byte[] b, int offset, int len)
      Adds a number of bytes to the current chunk.
      ProtocolOutputHandler create()
      Factory method to create a new ProtocolOutputHandler.
      ProtocolOutputHandler create​(int bufferSize, int extendSize)
      Factory method to create a new ProtocolOutputHandler.
      protected byte[] getByteArray()
      Returns a reference to the byte array of the current chunk to transmit.
      int getChunkCount()
      Returns the number of chunk the handler has stored.
      protected int getLength()
      Returns the number of bytes to transmit, starting at the offset.
      protected int getOffset()
      Returns the offset in the byte array of the current chunk where transmit should start.
      protected void markChunkCompleted()
      Marks a chunk completed.
      protected void setBytesWritten​(int written)
      Sets the number of bytes written from the OutputListener.
      java.lang.String toString()  
      • Methods inherited from class java.io.OutputStream

        close, nullOutputStream, write
      • Methods inherited from class java.lang.Object

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

      • RawOutputHandler

        public RawOutputHandler​(int bufferSize,
                                int extendSize)
      • RawOutputHandler

        public RawOutputHandler()
    • Method Detail

      • create

        public ProtocolOutputHandler create​(int bufferSize,
                                            int extendSize)
        Description copied from class: ProtocolOutputHandler
        Factory method to create a new ProtocolOutputHandler. For example, a RawOutputHandler returns a RawOutputHandler here.
        Specified by:
        create in class ProtocolOutputHandler
        Parameters:
        bufferSize - initial buffer size
        extendSize - extend size
        Returns:
        new protocol input handler.
      • getByteArray

        protected byte[] getByteArray()
        Description copied from class: ProtocolOutputHandler
        Returns a reference to the byte array of the current chunk to transmit. Called during invokeOutputListener().
        Specified by:
        getByteArray in class ProtocolOutputHandler
        Returns:
        byte array.
      • getOffset

        protected int getOffset()
        Description copied from class: ProtocolOutputHandler
        Returns the offset in the byte array of the current chunk where transmit should start. Called during invokeOutputListener().
        Specified by:
        getOffset in class ProtocolOutputHandler
        Returns:
        offset.
      • getLength

        protected int getLength()
        Description copied from class: ProtocolOutputHandler
        Returns the number of bytes to transmit, starting at the offset. Called during invokeOutputListener().
        Specified by:
        getLength in class ProtocolOutputHandler
        Returns:
        length.
      • setBytesWritten

        protected void setBytesWritten​(int written)
        Description copied from class: ProtocolOutputHandler
        Sets the number of bytes written from the OutputListener. This is the actual number of bytes written from the OutputListener to the network. The offset then must be set to offset+written and the length to length-written. If all bytes of the current chunk have been written, the chunk can be destroyed or marked for reuse.
        Specified by:
        setBytesWritten in class ProtocolOutputHandler
        Parameters:
        written - number of written bytes.
      • addBytes

        protected void addBytes​(byte[] b,
                                int offset,
                                int len)
        Description copied from class: ProtocolOutputHandler
        Adds a number of bytes to the current chunk. Called from write(b[],offset,len).
        Specified by:
        addBytes in class ProtocolOutputHandler
        Parameters:
        b - byte array.
        offset - offset.
        len - length.
      • markChunkCompleted

        protected void markChunkCompleted()
        Description copied from class: ProtocolOutputHandler
        Marks a chunk completed. Called during flush() If a protocol transmits byte streams with a length field in front, this is the place to determine the length.
        Specified by:
        markChunkCompleted in class ProtocolOutputHandler
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object