Package com.swiftmq.net.protocol.raw
Class RawOutputHandler
- java.lang.Object
-
- java.io.OutputStream
-
- com.swiftmq.net.protocol.ProtocolOutputHandler
-
- com.swiftmq.net.protocol.raw.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 toflush()
without any protocol specifiy actions.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
-
-
Constructor Summary
Constructors Constructor Description RawOutputHandler()
RawOutputHandler(int bufferSize, int extendSize)
-
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 com.swiftmq.net.protocol.ProtocolOutputHandler
flush, invokeOutputListener, setOutputListener, write, write
-
-
-
-
Method Detail
-
create
public ProtocolOutputHandler create()
Description copied from class:ProtocolOutputHandler
Factory method to create a new ProtocolOutputHandler. For example, a RawOutputHandler returns a RawOutputHandler here.- Specified by:
create
in classProtocolOutputHandler
- Returns:
- new protocol input handler.
-
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 classProtocolOutputHandler
- Parameters:
bufferSize
- initial buffer sizeextendSize
- 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 classProtocolOutputHandler
- 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 duringinvokeOutputListener()
.- Specified by:
getByteArray
in classProtocolOutputHandler
- 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 duringinvokeOutputListener()
.- Specified by:
getOffset
in classProtocolOutputHandler
- Returns:
- offset.
-
getLength
protected int getLength()
Description copied from class:ProtocolOutputHandler
Returns the number of bytes to transmit, starting at the offset. Called duringinvokeOutputListener()
.- Specified by:
getLength
in classProtocolOutputHandler
- 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 tooffset+written
and the length tolength-written
. If all bytes of the current chunk have been written, the chunk can be destroyed or marked for reuse.- Specified by:
setBytesWritten
in classProtocolOutputHandler
- 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 fromwrite(b)
.- Specified by:
addByte
in classProtocolOutputHandler
- 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 fromwrite(b[],offset,len)
.- Specified by:
addBytes
in classProtocolOutputHandler
- Parameters:
b
- byte array.offset
- offset.len
- length.
-
markChunkCompleted
protected void markChunkCompleted()
Description copied from class:ProtocolOutputHandler
Marks a chunk completed. Called duringflush()
If a protocol transmits byte streams with a length field in front, this is the place to determine the length.- Specified by:
markChunkCompleted
in classProtocolOutputHandler
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-