Top Description Fields Constructors Methods
org.eclipse.jetty.io

public Class ByteArrayEndPoint

extends AbstractEndPoint
Class Inheritance
Imports
java.io.EOFException, .IOException, java.net.InetAddress, .InetSocketAddress, .SocketAddress, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, java.nio.charset.Charset, .StandardCharsets, java.util.ArrayDeque, .Queue, java.util.concurrent.TimeUnit, java.util.concurrent.locks.Condition, org.eclipse.jetty.util.BufferUtil, org.eclipse.jetty.util.thread.AutoLock, .Scheduler, org.slf4j.Logger, .LoggerFactory

ByteArrayEndPoint.

Field Summary

Modifier and TypeField and Description
private boolean
private final Condition
private final Queue<ByteBuffer>
private final AutoLock
private ByteBuffer
private final int
private final Runnable
private static final ByteBuffer
private static final Logger
private static final int
private static final SocketAddress

Constructor Summary

AccessConstructor and Description
public
public
ByteArrayEndPoint(byte[]
the input bytes
input
,
int
the output size
outputSize
)

public
ByteArrayEndPoint(String
the input string (converted to bytes using default encoding charset)
input
,
int
the output size
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)

Method Summary

Modifier and TypeMethod and Description
public void
addInput(ByteBuffer
The in to set.
in
)

public void
public void
addInput(String s, Charset charset)

public void
public void
public void
public void
public void
protected void
public int
fill(ByteBuffer
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.
buffer
)

Overrides default org.eclipse.jetty.io.EndPoint.fill.

Fill the passed buffer with data from this endpoint.
public boolean
flush(ByteBuffer...
the buffers to flush
buffers
)

Overrides default org.eclipse.jetty.io.EndPoint.flush.

Flush data from the passed header/buffer to this endpoint.
public SocketAddress
public ByteBuffer

Returns:

Returns the out.
getOutput
()

public String

Returns:

Returns the out.
getOutputString
()

public String

Returns:

Returns the out.
getOutputString
(Charset
the charset to encode the output as
charset
)

public SocketAddress
public Object
public boolean

Returns:

true if there are bytes remaining to be read from the encoded input
hasMore
()

private static boolean

Returns:

Whether the reference buffer is equal to that of EOF
isEOF
(ByteBuffer
the input ByteBuffer to be compared to EOF
buffer
)

Compares a ByteBuffer Object to EOF by Reference

public boolean

Returns:

the growOutput
isGrowOutput
()

protected void
private static SocketAddress
protected void
public void
public void
setGrowOutput(boolean
the growOutput to set
growOutput
)

Set the growOutput to set.

public void
setOutput(ByteBuffer
The out to set.
out
)

public ByteBuffer

Returns:

Returns the out.
takeOutput
()

public String

Returns:

Returns the out.
takeOutputString
()

public String

Returns:

Returns the out.
takeOutputString
(Charset
the charset to encode the output as
charset
)

public String
toString()

Overrides org.eclipse.jetty.io.AbstractEndPoint.toString.

Returns a string representation of the object.
public ByteBuffer

Returns:

The buffer of output
waitForOutput
(long
Time to wait
time
,
TimeUnit
Units for time to wait
unit
)

Wait for some output

Inherited from org.eclipse.jetty.io.AbstractEndPoint:
closeclosedoShutdownInputfillInterestedgetConnectiongetCreatedTimeStampgetFillInterestgetLocalAddressgetRemoteAddressgetWriteFlusherisFillInterestedisInputShutdownisOpenisOutputShutdownonCloseonCloseonIdleExpiredonOpensetConnectionshutdownInputshutdownOutputtoConnectionStringtoEndPointStringtryFillInterestedupgradewrite

Field Detail

_growOutputback to summary
private boolean _growOutput
_hasOutputback to summary
private final Condition _hasOutput
_inQback to summary
private final Queue<ByteBuffer> _inQ
_lockback to summary
private final AutoLock _lock
_outback to summary
private ByteBuffer _out
_outputSizeback to summary
private final int _outputSize
_runFillableback to summary
private final Runnable _runFillable
EOFback to summary
private static final ByteBuffer EOF
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.io.AbstractEndPoint.LOG.

MAX_BUFFER_SIZEback to summary
private static final int MAX_BUFFER_SIZE
NO_SOCKET_ADDRESSback to summary
private static final SocketAddress NO_SOCKET_ADDRESS

Constructor Detail

ByteArrayEndPointback to summary
public ByteArrayEndPoint()
ByteArrayEndPointback to summary
public ByteArrayEndPoint(byte[] input, int outputSize)
Parameters
input:byte[]

the input bytes

outputSize:int

the output size

ByteArrayEndPointback to summary
public ByteArrayEndPoint(String input, int outputSize)
Parameters
input:String

the input string (converted to bytes using default encoding charset)

outputSize:int

the output size

ByteArrayEndPointback to summary
public ByteArrayEndPoint(Scheduler scheduler, long idleTimeoutMs)
ByteArrayEndPointback to summary
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, byte[] input, int outputSize)
ByteArrayEndPointback to summary
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, String input, int outputSize)
ByteArrayEndPointback to summary
public ByteArrayEndPoint(Scheduler timer, long idleTimeoutMs, ByteBuffer input, ByteBuffer output)

Method Detail

addInputback to summary
public void addInput(ByteBuffer in)
Parameters
in:ByteBuffer

The in to set.

addInputback to summary
public void addInput(String s)
addInputback to summary
public void addInput(String s, Charset charset)
addInputAndExecuteback to summary
public void addInputAndExecute(String s)
addInputAndExecuteback to summary
public void addInputAndExecute(ByteBuffer in)
addInputEOFback to summary
public void addInputEOF()
doCloseback to summary
public void doClose()

Overrides org.eclipse.jetty.io.AbstractEndPoint.doClose.

Annotations
@Override
doShutdownOutputback to summary
public void doShutdownOutput()

Overrides org.eclipse.jetty.io.AbstractEndPoint.doShutdownOutput.

Annotations
@Override
executeback to summary
protected void execute(Runnable task)
fillback to summary
public int fill(ByteBuffer buffer) throws IOException

Overrides default org.eclipse.jetty.io.EndPoint.fill.

Doc from org.eclipse.jetty.io.EndPoint.fill.

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:ByteBuffer

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:int

an int value indicating the number of bytes filled or -1 if EOF is read or the input is shutdown.

Annotations
@Override
Exceptions
IOException:
if the endpoint is closed.
flushback to summary
public boolean flush(ByteBuffer... buffers) throws IOException

Overrides default org.eclipse.jetty.io.EndPoint.flush.

Doc from org.eclipse.jetty.io.EndPoint.flush.

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:ByteBuffer[]

the buffers to flush

Returns:boolean

True IFF all the buffers have been consumed and the endpoint has flushed the data to its destination (ie is not buffering any data).

Annotations
@Override
Exceptions
IOException:
If the endpoint is closed or output is shutdown.
getLocalSocketAddressback to summary
public SocketAddress getLocalSocketAddress()

Overrides default org.eclipse.jetty.io.EndPoint.getLocalSocketAddress.

Implements abstract org.eclipse.jetty.io.AbstractEndPoint.getLocalSocketAddress.

Returns:SocketAddress

Doc from org.eclipse.jetty.io.EndPoint.getLocalSocketAddress.

the local SocketAddress to which this EndPoint is bound or null if this EndPoint is not bound to a Socket address.

Annotations
@Override
getOutputback to summary
public ByteBuffer getOutput()
Returns:ByteBuffer

Returns the out.

getOutputStringback to summary
public String getOutputString()
Returns:String

Returns the out.

getOutputStringback to summary
public String getOutputString(Charset charset)
Parameters
charset:Charset

the charset to encode the output as

Returns:String

Returns the out.

getRemoteSocketAddressback to summary
public SocketAddress getRemoteSocketAddress()

Overrides default org.eclipse.jetty.io.EndPoint.getRemoteSocketAddress.

Implements abstract org.eclipse.jetty.io.AbstractEndPoint.getRemoteSocketAddress.

Returns:SocketAddress

Doc from org.eclipse.jetty.io.EndPoint.getRemoteSocketAddress.

The remote SocketAddress to which this EndPoint is connected, or null if this EndPoint is not connected to a Socket address.

Annotations
@Override
getTransportback to summary
public Object getTransport()

Implements org.eclipse.jetty.io.EndPoint.getTransport.

Returns:Object

Doc from org.eclipse.jetty.io.EndPoint.getTransport.

The underlying transport object (socket, channel, etc.)

Annotations
@Override
hasMoreback to summary
public boolean hasMore()
Returns:boolean

true if there are bytes remaining to be read from the encoded input

isEOFback to summary
private static boolean isEOF(ByteBuffer buffer)

Compares a ByteBuffer Object to EOF by Reference

Parameters
buffer:ByteBuffer

the input ByteBuffer to be compared to EOF

Returns:boolean

Whether the reference buffer is equal to that of EOF

isGrowOutputback to summary
public boolean isGrowOutput()
Returns:boolean

the growOutput

needsFillInterestback to summary
protected void needsFillInterest() throws IOException

Implements abstract org.eclipse.jetty.io.AbstractEndPoint.needsFillInterest.

Annotations
@Override
noSocketAddressback to summary
private static SocketAddress noSocketAddress()
onIncompleteFlushback to summary
protected void onIncompleteFlush()

Implements abstract org.eclipse.jetty.io.AbstractEndPoint.onIncompleteFlush.

Annotations
@Override
resetback to summary
public void reset()

Overrides org.eclipse.jetty.io.AbstractEndPoint.reset.

Annotations
@Override
setGrowOutputback to summary
public void setGrowOutput(boolean growOutput)

Set the growOutput to set.

Parameters
growOutput:boolean

the growOutput to set

setOutputback to summary
public void setOutput(ByteBuffer out)
Parameters
out:ByteBuffer

The out to set.

takeOutputback to summary
public ByteBuffer takeOutput()
Returns:ByteBuffer

Returns the out.

takeOutputStringback to summary
public String takeOutputString()
Returns:String

Returns the out.

takeOutputStringback to summary
public String takeOutputString(Charset charset)
Parameters
charset:Charset

the charset to encode the output as

Returns:String

Returns the out.

toStringback to summary
public String toString()

Overrides org.eclipse.jetty.io.AbstractEndPoint.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
waitForOutputback to summary
public ByteBuffer waitForOutput(long time, TimeUnit unit) throws InterruptedException

Wait for some output

Parameters
time:long

Time to wait

unit:TimeUnit

Units for time to wait

Returns:ByteBuffer

The buffer of output

Exceptions
InterruptedException:
if interrupted