Package com.swiftmq.net.protocol
Interface ProtocolInputHandler
-
- All Known Implementing Classes:
AMQPInputHandler
,RawInputHandler
,SMQPInputHandler
public interface ProtocolInputHandler
A ProtocolInputHandler receives bytes in form of byte arrays from the Network Swiftlet. Implementing classes handle everything protocol specific and detect whether a so-called chunk is completed. That is, for example, if there is a protocol which receives Strings, where each String is terminated by a '\n', thus a line reader, a chunk is completed when a '\n' is detected. By detecting a completed chunk, the ProtocolInputHandler calls the registered ChunkListener which in turn should process the chunk.
This procedure is required to handle blocking and nonblocking I/O transparently.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ProtocolInputHandler
create()
Factory method to create a new ProtocolInputHandler.void
createInputBuffer(int initialSize, int ensureSize)
Create the input buffer of the protocol handler.byte[]
getBuffer()
Returns the protocol handler input buffer.java.nio.ByteBuffer
getByteBuffer()
Returns the protocol handler input buffer.int
getOffset()
Returns the current offset of the input buffer.void
setBytesWritten(int written)
Set the number of bytes written into the buffer.void
setChunkListener(ChunkListener listener)
Set the ChunkListener.
-
-
-
Method Detail
-
create
ProtocolInputHandler create()
Factory method to create a new ProtocolInputHandler. For example, a RawInputHandler returns a RawInputHandler here.- Returns:
- new protocol input handler.
-
createInputBuffer
void createInputBuffer(int initialSize, int ensureSize)
Create the input buffer of the protocol handler. The buffer must be created with theinitialSize
. Each timegetBuffer()
is called, the buffer must have a remaining size ofensureSize
.- Parameters:
initialSize
- initial sizeensureSize
- ensured size on each getBuffer call
-
getByteBuffer
java.nio.ByteBuffer getByteBuffer()
Returns the protocol handler input buffer.- Returns:
- buffer.
-
getBuffer
byte[] getBuffer()
Returns the protocol handler input buffer.- Returns:
- buffer.
-
getOffset
int getOffset()
Returns the current offset of the input buffer.- Returns:
- offset.
-
setBytesWritten
void setBytesWritten(int written)
Set the number of bytes written into the buffer. Called from the Network Swiftlet after it has read bytes from sockets directly into the buffer+offset.- Parameters:
written
- number of bytes written
-
setChunkListener
void setChunkListener(ChunkListener listener)
Set the ChunkListener. The ChunkListener is implemented by the Network Swiftlet and will be set from it.- Parameters:
listener
- listener.
-
-