Package org.eclipse.jetty.io
Class ByteArrayEndPoint
- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- org.eclipse.jetty.io.AbstractEndPoint
-
- org.eclipse.jetty.io.ByteArrayEndPoint
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,EndPoint
- Direct Known Subclasses:
LocalConnector.LocalEndPoint
public class ByteArrayEndPoint extends AbstractEndPoint
ByteArrayEndPoint.
-
-
Constructor Summary
Constructors Constructor Description ByteArrayEndPoint()
ByteArrayEndPoint(byte[] input, int outputSize)
ByteArrayEndPoint(java.lang.String input, int outputSize)
ByteArrayEndPoint(Scheduler scheduler, long idleTimeoutMs)
ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, byte[] input, int outputSize)
ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, java.lang.String input, int outputSize)
ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, java.nio.ByteBuffer input, java.nio.ByteBuffer output)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInput(java.lang.String s)
void
addInput(java.lang.String s, java.nio.charset.Charset charset)
void
addInput(java.nio.ByteBuffer in)
void
addInputAndExecute(java.nio.ByteBuffer in)
void
addInputEOF()
void
doClose()
void
doShutdownOutput()
protected void
execute(java.lang.Runnable task)
int
fill(java.nio.ByteBuffer buffer)
Fill the passed buffer with data from this endpoint.boolean
flush(java.nio.ByteBuffer... buffers)
Flush data from the passed header/buffer to this endpoint.java.net.InetSocketAddress
getLocalAddress()
java.nio.ByteBuffer
getOutput()
java.lang.String
getOutputString()
java.lang.String
getOutputString(java.nio.charset.Charset charset)
java.net.InetSocketAddress
getRemoteAddress()
java.lang.Object
getTransport()
boolean
hasMore()
boolean
isGrowOutput()
protected void
needsFillInterest()
protected void
onIncompleteFlush()
void
reset()
void
setGrowOutput(boolean growOutput)
void
setOutput(java.nio.ByteBuffer out)
java.nio.ByteBuffer
takeOutput()
java.lang.String
takeOutputString()
java.lang.String
takeOutputString(java.nio.charset.Charset charset)
java.lang.String
toString()
java.nio.ByteBuffer
waitForOutput(long time, java.util.concurrent.TimeUnit unit)
Wait for some output-
Methods inherited from class org.eclipse.jetty.io.AbstractEndPoint
checkFill, checkFlush, close, close, doShutdownInput, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getWriteFlusher, isFillInterested, isInputShutdown, isOpen, isOptimizedForDirectBuffers, isOutputShutdown, onClose, onClose, onIdleExpired, onOpen, setConnection, shutdownInput, shutdownOutput, toConnectionString, toEndPointString, tryFillInterested, upgrade, write
-
Methods inherited from class org.eclipse.jetty.io.IdleTimeout
checkIdleTimeout, getIdleFor, getIdleTimeout, getScheduler, notIdle, setIdleTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.io.EndPoint
getIdleTimeout, setIdleTimeout
-
-
-
-
Constructor Detail
-
ByteArrayEndPoint
public ByteArrayEndPoint()
-
ByteArrayEndPoint
public ByteArrayEndPoint(byte[] input, int outputSize)
- Parameters:
input
- the input bytesoutputSize
- the output size
-
ByteArrayEndPoint
public ByteArrayEndPoint(java.lang.String input, int outputSize)
- Parameters:
input
- the input string (converted to bytes using default encoding charset)outputSize
- the output size
-
ByteArrayEndPoint
public ByteArrayEndPoint(Scheduler scheduler, long idleTimeoutMs)
-
ByteArrayEndPoint
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, byte[] input, int outputSize)
-
ByteArrayEndPoint
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, java.lang.String input, int outputSize)
-
ByteArrayEndPoint
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, java.nio.ByteBuffer input, java.nio.ByteBuffer output)
-
-
Method Detail
-
doShutdownOutput
public void doShutdownOutput()
- Overrides:
doShutdownOutput
in classAbstractEndPoint
-
doClose
public void doClose()
- Overrides:
doClose
in classAbstractEndPoint
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()
- Returns:
- The local Inet address to which this
EndPoint
is bound, ornull
if thisEndPoint
does not represent a network connection.
-
getRemoteAddress
public java.net.InetSocketAddress getRemoteAddress()
- Returns:
- The remote Inet address to which this
EndPoint
is bound, ornull
if thisEndPoint
does not represent a network connection.
-
onIncompleteFlush
protected void onIncompleteFlush()
- Specified by:
onIncompleteFlush
in classAbstractEndPoint
-
execute
protected void execute(java.lang.Runnable task)
-
needsFillInterest
protected void needsFillInterest() throws java.io.IOException
- Specified by:
needsFillInterest
in classAbstractEndPoint
- Throws:
java.io.IOException
-
addInputEOF
public void addInputEOF()
-
addInput
public void addInput(java.nio.ByteBuffer in)
- Parameters:
in
- The in to set.
-
addInputAndExecute
public void addInputAndExecute(java.nio.ByteBuffer in)
-
addInput
public void addInput(java.lang.String s)
-
addInput
public void addInput(java.lang.String s, java.nio.charset.Charset charset)
-
getOutput
public java.nio.ByteBuffer getOutput()
- Returns:
- Returns the out.
-
getOutputString
public java.lang.String getOutputString()
- Returns:
- Returns the out.
-
getOutputString
public java.lang.String getOutputString(java.nio.charset.Charset charset)
- Parameters:
charset
- the charset to encode the output as- Returns:
- Returns the out.
-
takeOutput
public java.nio.ByteBuffer takeOutput()
- Returns:
- Returns the out.
-
waitForOutput
public java.nio.ByteBuffer waitForOutput(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Wait for some output- Parameters:
time
- Time to waitunit
- Units for time to wait- Returns:
- The buffer of output
- Throws:
java.lang.InterruptedException
- if interrupted
-
takeOutputString
public java.lang.String takeOutputString()
- Returns:
- Returns the out.
-
takeOutputString
public java.lang.String takeOutputString(java.nio.charset.Charset charset)
- Parameters:
charset
- the charset to encode the output as- Returns:
- Returns the out.
-
setOutput
public void setOutput(java.nio.ByteBuffer out)
- Parameters:
out
- The out to set.
-
hasMore
public boolean hasMore()
- Returns:
true
if there are bytes remaining to be read from the encoded input
-
fill
public int fill(java.nio.ByteBuffer buffer) throws java.io.IOException
Description copied from interface:EndPoint
Fill the passed buffer with data from this endpoint. The bytes are appended to any data already in the buffer by writing from the buffers limit up to it's capacity. The limit is updated to include the filled bytes.- Parameters:
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.- Returns:
- an
int
value indicating the number of bytes filled or -1 if EOF is read or the input is shutdown. - Throws:
java.io.IOException
- if the endpoint is closed.
-
flush
public boolean flush(java.nio.ByteBuffer... buffers) throws java.io.IOException
Description copied from interface:EndPoint
Flush data from the passed header/buffer to this endpoint. As many bytes as can be consumed are taken from the header/buffer position up until the buffer limit. The header/buffers position is updated to indicate how many bytes have been consumed.- Parameters:
buffers
- the buffers to flush- Returns:
- True IFF all the buffers have been consumed and the endpoint has flushed the data to its destination (ie is not buffering any data).
- Throws:
java.io.IOException
- If the endpoint is closed or output is shutdown.
-
reset
public void reset()
- Overrides:
reset
in classAbstractEndPoint
-
getTransport
public java.lang.Object getTransport()
- Returns:
- The underlying transport object (socket, channel, etc.)
-
isGrowOutput
public boolean isGrowOutput()
- Returns:
- the growOutput
-
setGrowOutput
public void setGrowOutput(boolean growOutput)
- Parameters:
growOutput
- the growOutput to set
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractEndPoint
-
-