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:
Closeable
,Flushable
,AutoCloseable
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.create()
create
(int bufferSize, int extendSize) Factory method to create a new ProtocolOutputHandler.protected byte[]
Returns a reference to the byte array of the current chunk to transmit.int
Returns the number of chunk the handler has stored.protected int
Returns the number of bytes to transmit, starting at the offset.protected int
Returns the offset in the byte array of the current chunk where transmit should start.protected void
Marks a chunk completed.protected void
setBytesWritten
(int written) Sets the number of bytes written from the OutputListener.toString()
Methods inherited from class com.swiftmq.net.protocol.ProtocolOutputHandler
flush, invokeOutputListener, setOutputListener, write, write
Methods inherited from class java.io.OutputStream
close, nullOutputStream, write
-
Constructor Details
-
RawOutputHandler
public RawOutputHandler(int bufferSize, int extendSize) -
RawOutputHandler
public RawOutputHandler()
-
-
Method Details
-
create
-
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
- 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
-