Class RawOutputHandler

All Implemented Interfaces:
Closeable, Flushable, 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
  • Constructor Details

    • RawOutputHandler

      public RawOutputHandler(int bufferSize, int extendSize)
    • RawOutputHandler

      public RawOutputHandler()
  • Method Details

    • create

      public ProtocolOutputHandler create()
    • 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.
    • getChunkCount

      public int getChunkCount()
      Description copied from class: ProtocolOutputHandler
      Returns the number of chunk the handler has stored.
      Specified by:
      getChunkCount in class ProtocolOutputHandler
      Returns:
      number of chunks.
    • 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.
    • addByte

      protected void addByte(byte b)
      Description copied from class: ProtocolOutputHandler
      Add a byte to the current chunk. Called from write(b).
      Specified by:
      addByte in class ProtocolOutputHandler
      Parameters:
      b - byte.
    • 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 String toString()
      Overrides:
      toString in class Object