public class ByteArrayEndPoint extends AbstractEndPoint
Modifier and Type | Field and Description |
---|---|
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 |
addInput(ByteBuffer in) |
void |
addInput(String s) |
void |
addInput(String s,
Charset charset) |
void |
addInputAndExecute(ByteBuffer in) |
void |
addInputEOF() |
void |
close()
Close any backing stream associated with the endpoint
|
protected void |
execute(Runnable task) |
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 |
getOutput() |
String |
getOutputString() |
String |
getOutputString(Charset charset) |
Object |
getTransport() |
boolean |
hasMore() |
boolean |
isGrowOutput() |
boolean |
isInputShutdown()
Test if the input is shutdown.
|
boolean |
isOpen()
This abstract method should be called to check if idle timeouts
should still be checked.
|
boolean |
isOutputShutdown()
Test if output is shutdown.
|
protected void |
needsFillInterest() |
protected void |
onIncompleteFlush() |
void |
reset() |
void |
setGrowOutput(boolean growOutput) |
void |
setOutput(ByteBuffer out) |
void |
shutdownInput() |
void |
shutdownOutput()
Shutdown the output.
|
ByteBuffer |
takeOutput() |
String |
takeOutputString() |
String |
takeOutputString(Charset charset) |
fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getLocalAddress, getRemoteAddress, getWriteFlusher, isOptimizedForDirectBuffers, onClose, onIdleExpired, onOpen, setConnection, toString, upgrade, write
checkIdleTimeout, getIdleFor, getIdleTimeout, getIdleTimestamp, getScheduler, notIdle, setIdleTimeout
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getIdleTimeout, setIdleTimeout
public static final InetSocketAddress NOIP
public ByteArrayEndPoint()
public ByteArrayEndPoint(byte[] input, int outputSize)
input
- the input bytesoutputSize
- the output sizepublic ByteArrayEndPoint(String input, int outputSize)
input
- the input string (converted to bytes using default encoding charset)outputSize
- the output sizepublic 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 void execute(Runnable task)
protected void needsFillInterest() throws IOException
needsFillInterest
in class AbstractEndPoint
IOException
public void addInputEOF()
public void addInput(ByteBuffer in)
in
- The in to set.public void addInputAndExecute(ByteBuffer in)
public void addInput(String s)
public ByteBuffer getOutput()
public String getOutputString()
public String getOutputString(Charset charset)
charset
- the charset to encode the output aspublic ByteBuffer takeOutput()
public String takeOutputString()
public String takeOutputString(Charset charset)
charset
- the charset to encode the output aspublic void setOutput(ByteBuffer out)
out
- The out to set.public boolean isOpen()
IdleTimeout
isOpen
in interface EndPoint
isOpen
in class IdleTimeout
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 shutdownInput()
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
close
in interface Closeable
close
in interface AutoCloseable
close
in interface EndPoint
close
in class AbstractEndPoint
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.IOException
- if the endpoint is closed.public boolean flush(ByteBuffer... buffers) throws IOException
EndPoint
buffers
- the buffers to flushIOException
- If the endpoint is closed or output is shutdown.public void reset()
public Object getTransport()
public boolean isGrowOutput()
public void setGrowOutput(boolean growOutput)
growOutput
- the growOutput to setCopyright © 1995-2015 Webtide. All Rights Reserved.