public class ByteArrayEndPoint extends AbstractEndPoint
Modifier and Type | Field and Description |
---|---|
protected boolean |
_closed |
protected boolean |
_growOutput |
protected ByteBuffer |
_in |
protected boolean |
_ishut |
protected boolean |
_oshut |
protected ByteBuffer |
_out |
static InetSocketAddress |
NOIP |
Constructor and Description |
---|
ByteArrayEndPoint() |
ByteArrayEndPoint(byte[] input,
int outputSize) |
ByteArrayEndPoint(Scheduler scheduler,
long idleTimeoutMs) |
ByteArrayEndPoint(Scheduler timer,
long idleTimeoutMs,
byte[] input,
int outputSize) |
ByteArrayEndPoint(Scheduler timer,
long idleTimeoutMs,
ByteBuffer input,
ByteBuffer output) |
ByteArrayEndPoint(Scheduler timer,
long idleTimeoutMs,
String input,
int outputSize) |
ByteArrayEndPoint(String input,
int outputSize) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close any backing stream associated with the endpoint
|
int |
fill(ByteBuffer buffer)
Fill the passed buffer with data from this endpoint.
|
boolean |
flush(ByteBuffer... buffers)
Flush data from the passed header/buffer to this endpoint.
|
ByteBuffer |
getIn() |
ByteBuffer |
getOutput() |
String |
getOutputString() |
String |
getOutputString(Charset charset) |
Object |
getTransport() |
boolean |
hasMore() |
boolean |
isGrowOutput() |
boolean |
isInputShutdown()
Test if the input is shutdown.
|
boolean |
isOpen() |
boolean |
isOutputShutdown()
Test if output is shutdown.
|
protected boolean |
needsFill() |
protected void |
onIncompleteFlush() |
void |
reset() |
void |
setGrowOutput(boolean growOutput) |
void |
setIdleTimeout(long idleTimeout)
Set the idle timeout.
|
void |
setInput(ByteBuffer in) |
void |
setInput(String s) |
void |
setInput(String s,
Charset charset) |
void |
setInputEOF() |
void |
setOutput(ByteBuffer out) |
void |
shutdownOutput()
Shutdown the output.
|
ByteBuffer |
takeOutput() |
String |
takeOutputString() |
String |
takeOutputString(Charset charset) |
checkIdleTimeout, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getIdleTimeout, getIdleTimestamp, getLocalAddress, getRemoteAddress, getWriteFlusher, notIdle, onClose, onOpen, scheduleIdleTimeout, setConnection, toString, write
public static final InetSocketAddress NOIP
protected ByteBuffer _in
protected ByteBuffer _out
protected boolean _ishut
protected boolean _oshut
protected boolean _closed
protected boolean _growOutput
public ByteArrayEndPoint()
public ByteArrayEndPoint(byte[] input, int outputSize)
public ByteArrayEndPoint(String input, int outputSize)
public ByteArrayEndPoint(Scheduler scheduler, long idleTimeoutMs)
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, byte[] input, int outputSize)
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, String input, int outputSize)
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output)
protected void onIncompleteFlush()
onIncompleteFlush
in class AbstractEndPoint
protected boolean needsFill() throws IOException
needsFill
in class AbstractEndPoint
IOException
public ByteBuffer getIn()
public void setInputEOF()
public void setInput(ByteBuffer in)
in
- The in to set.public void setInput(String s)
public ByteBuffer getOutput()
public String getOutputString()
public ByteBuffer takeOutput()
public String takeOutputString()
public void setOutput(ByteBuffer out)
out
- The out to set.public boolean isOpen()
public boolean isInputShutdown()
EndPoint
EndPoint.fill(ByteBuffer)
. Once the input is shutdown, all calls to
EndPoint.fill(ByteBuffer)
will return -1, until such time as the
end point is close, when they will return EofException
.public boolean isOutputShutdown()
EndPoint
EndPoint.shutdownOutput()
or EndPoint.close()
.public void shutdownOutput()
EndPoint
This call indicates that no more data will be sent on this endpoint that that the remote end should read an EOF once all previously sent data has been consumed. Shutdown may be done either at the TCP/IP level, as a protocol exchange (Eg TLS close handshake) or both.
If the endpoint has EndPoint.isInputShutdown()
true, then this call has the same effect
as EndPoint.close()
.
public void close()
EndPoint
public boolean hasMore()
true
if there are bytes remaining to be read from the encoded inputpublic int fill(ByteBuffer buffer) throws IOException
EndPoint
buffer
- The buffer to fill. The position and limit are modified during the fill. After the
operation, the position is unchanged and the limit is increased to reflect the new data filled.int
value indicating the number of bytes
filled or -1 if EOF is read or the input is shutdown.EofException
- If the endpoint is closed.IOException
public boolean flush(ByteBuffer... buffers) throws IOException
EndPoint
EofException
- If the endpoint is closed or output is shutdown.IOException
public void reset()
public Object getTransport()
public boolean isGrowOutput()
public void setGrowOutput(boolean growOutput)
growOutput
- the growOutput to setpublic void setIdleTimeout(long idleTimeout)
EndPoint
setIdleTimeout
in interface EndPoint
setIdleTimeout
in class AbstractEndPoint
idleTimeout
- the idle timeout in MS. Timeout <= 0 implies an infinite timeoutCopyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.