public class ObjectReader
extends java.lang.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 |
protected static StringManager |
sm |
Constructor and Description |
---|
ObjectReader(int packetSize) |
ObjectReader(java.net.Socket socket)
Creates an
ObjectReader for a TCP socket |
ObjectReader(java.nio.channels.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(java.nio.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) |
protected static final StringManager sm
protected long lastAccess
protected boolean accessed
public ObjectReader(int packetSize)
public ObjectReader(java.nio.channels.SocketChannel channel)
ObjectReader
for a TCP NIO socket channelchannel
- - the channel to be read.public ObjectReader(java.net.Socket socket)
ObjectReader
for a TCP socketsocket
- Socketpublic void access()
public void finish()
public boolean isAccessed()
public int append(java.nio.ByteBuffer data, int len, boolean count) throws java.io.IOException
data
- new transfer bufferlen
- length in buffercount
- whether to return the countjava.io.IOException
XByteBuffer.countPackages()
public int append(byte[] data, int off, int len, boolean count)
public ChannelMessage[] execute() throws java.io.IOException
java.io.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-2018 Apache Software Foundation. All Rights Reserved.