public class ObjectReader extends Object
XByteBuffer
until a full package has been received.
This object uses an XByteBuffer which is an extendable object buffer that also allows
for message encoding and decoding.Modifier and Type | Field and Description |
---|---|
protected boolean |
accessed |
protected long |
lastAccess |
Constructor and Description |
---|
ObjectReader(int packetSize) |
ObjectReader(Socket socket)
Creates an
ObjectReader for a TCP socket |
ObjectReader(SocketChannel channel)
Creates an
ObjectReader for a TCP NIO socket channel |
Modifier and Type | Method and Description |
---|---|
void |
access() |
int |
append(byte[] data,
int off,
int len,
boolean count) |
int |
append(ByteBuffer data,
int len,
boolean count)
Append new bytes to buffer.
|
int |
bufferSize() |
void |
close() |
int |
count()
Returns the number of packages that the reader has read
|
ChannelMessage[] |
execute()
Send buffer to cluster listener (callback).
|
void |
finish() |
long |
getLastAccess() |
boolean |
hasPackage() |
boolean |
isAccessed() |
boolean |
isCancelled() |
void |
setCancelled(boolean cancelled) |
void |
setLastAccess(long lastAccess) |
public ObjectReader(int packetSize)
public ObjectReader(SocketChannel channel)
ObjectReader
for a TCP NIO socket channelchannel
- - the channel to be read.public ObjectReader(Socket socket)
ObjectReader
for a TCP socketsocket
- Socketpublic void access()
public void finish()
public boolean isAccessed()
public int append(ByteBuffer data, int len, boolean count) throws IOException
data
- new transfer bufferlen
- length in buffercount
- whether to return the countIOException
XByteBuffer.countPackages()
public int append(byte[] data, int off, int len, boolean count) throws IOException
IOException
public ChannelMessage[] execute() throws IOException
IOException
ReceiverBase.messageDataReceived(ChannelMessage)
,
XByteBuffer.doesPackageExist()
,
XByteBuffer.extractPackage(boolean)
public int bufferSize()
public boolean hasPackage()
public int count()
public void close()
public long getLastAccess()
public boolean isCancelled()
public void setLastAccess(long lastAccess)
public void setCancelled(boolean cancelled)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.