## org.eclipse.jetty.io
Class ByteArrayEndPoint

    java.lang.Object
      org.eclipse.jetty.io.ByteArrayEndPoint

All Implemented Interfaces:
  ConnectedEndPoint, EndPoint

    public class ByteArrayEndPoint

extends java.lang.Object
implements ConnectedEndPoint

ByteArrayEndPoint.

Field Summary
`protected boolean` `_closed`
`protected Connection` `_connection`
`protected boolean` `_growOutput`
`protected ByteArrayBuffer` `_in`
`protected byte[]` `_inBytes`
`protected int` `_maxIdleTime`
`protected boolean` `_nonBlocking`
`protected ByteArrayBuffer` `_out`

Constructor Summary
`ByteArrayEndPoint()`
`ByteArrayEndPoint(byte[] input, int outputSize)`

Method Summary
`boolean` `blockReadable(long millisecs)`
`boolean` `blockWritable(long millisecs)`
`void` `close()` Close any backing stream associated with the endpoint
`int` `fill(Buffer buffer)` Fill the buffer from the current putIndex to it's capacity from whatever byte source is backing the buffer.
`void` `flush()` Flush any buffered output.
`int` `flush(Buffer buffer)` Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
`int` `flush(Buffer header, Buffer buffer, Buffer trailer)` Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer.
`Connection` `getConnection()`
`ByteArrayBuffer` `getIn()`
`java.lang.String` `getLocalAddr()`
`java.lang.String` `getLocalHost()`
`int` `getLocalPort()`
`int` `getMaxIdleTime()` Get the max idle time in ms.
`ByteArrayBuffer` `getOut()`
`java.lang.String` `getRemoteAddr()`
`java.lang.String` `getRemoteHost()`
`int` `getRemotePort()`
`java.lang.Object` `getTransport()`
`boolean` `isBlocking()`
`boolean` `isBufferingInput()`
`boolean` `isBufferingOutput()`
`boolean` `isBufferred()`
`boolean` `isGrowOutput()`
`boolean` `isNonBlocking()`
`boolean` `isOpen()`
`void` `reset()`
`void` `setConnection(Connection connection)`
`void` `setGrowOutput(boolean growOutput)`
`void` `setIn(ByteArrayBuffer in)`
`void` `setMaxIdleTime(int timeMs)` Set the max idle time.
`void` `setNonBlocking(boolean nonBlocking)`
`void` `setOut(ByteArrayBuffer out)`
`void` `shutdownOutput()` Shutdown any backing output stream associated with the endpoint

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _inBytes

    protected byte[] _inBytes

### _in

    protected ByteArrayBuffer _in

### _out

    protected ByteArrayBuffer _out

### _closed

    protected boolean _closed

### _nonBlocking

    protected boolean _nonBlocking

### _growOutput

    protected boolean _growOutput

### _connection

    protected Connection _connection

### _maxIdleTime

    protected int _maxIdleTime

Constructor Detail

### ByteArrayEndPoint

    public ByteArrayEndPoint()

### ByteArrayEndPoint

    public ByteArrayEndPoint(byte[] input,
                             int outputSize)

Method Detail

### getConnection

    public Connection getConnection()

  Specified by:
    `getConnection` in interface `ConnectedEndPoint`
  See Also:
    `ConnectedEndPoint.getConnection()`

### setConnection

    public void setConnection(Connection connection)

  Specified by:
    `setConnection` in interface `ConnectedEndPoint`
  See Also:
    `ConnectedEndPoint.setConnection(org.eclipse.jetty.io.Connection)`

### isNonBlocking

    public boolean isNonBlocking()

  Returns:
    the nonBlocking

### setNonBlocking

    public void setNonBlocking(boolean nonBlocking)

  Parameters:
    `nonBlocking` - the nonBlocking to set

### getIn

    public ByteArrayBuffer getIn()

  Returns:
    Returns the in.

### setIn

    public void setIn(ByteArrayBuffer in)

  Parameters:
    `in` - The in to set.

### getOut

    public ByteArrayBuffer getOut()

  Returns:
    Returns the out.

### setOut

    public void setOut(ByteArrayBuffer out)

  Parameters:
    `out` - The out to set.

### isOpen

    public boolean isOpen()

  Specified by:
    `isOpen` in interface `EndPoint`

### isBlocking

    public boolean isBlocking()

  Specified by:
    `isBlocking` in interface `EndPoint`

### blockReadable

    public boolean blockReadable(long millisecs)

  Specified by:
    `blockReadable` in interface `EndPoint`

### blockWritable

    public boolean blockWritable(long millisecs)

  Specified by:
    `blockWritable` in interface `EndPoint`

### shutdownOutput

    public void shutdownOutput()
                        throws java.io.IOException

  Description copied from interface: `EndPoint`
  Shutdown any backing output stream associated with the endpoint

  Specified by:
    `shutdownOutput` in interface `EndPoint`
  Throws:
    `java.io.IOException`

### close

    public void close()
               throws java.io.IOException

  Description copied from interface: `EndPoint`
  Close any backing stream associated with the endpoint

  Specified by:
    `close` in interface `EndPoint`
  Throws:
    `java.io.IOException`

### fill

    public int fill(Buffer buffer)
             throws java.io.IOException

  Description copied from interface: `EndPoint`
  Fill the buffer from the current putIndex to it's capacity from whatever byte source is backing the buffer. The putIndex is increased if bytes filled. The buffer may chose to do a compact before filling.

  Specified by:
    `fill` in interface `EndPoint`
  Returns:
    an `int` value indicating the number of bytes filled or -1 if EOF is reached.
  Throws:
    `java.io.IOException`

### flush

    public int flush(Buffer buffer)
              throws java.io.IOException

  Description copied from interface: `EndPoint`
  Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer. The getIndex is updated with the number of bytes flushed. Any mark set is cleared. If the entire contents of the buffer are flushed, then an implicit empty() is done.

  Specified by:
    `flush` in interface `EndPoint`
  Parameters:
    `buffer` - The buffer to flush. This buffers getIndex is updated.
  Returns:
    the number of bytes written
  Throws:
    `java.io.IOException`

### flush

    public int flush(Buffer header,
                     Buffer buffer,
                     Buffer trailer)
              throws java.io.IOException

  Description copied from interface: `EndPoint`
  Flush the buffer from the current getIndex to it's putIndex using whatever byte sink is backing the buffer. The getIndex is updated with the number of bytes flushed. Any mark set is cleared. If the entire contents of the buffer are flushed, then an implicit empty() is done. The passed header/trailer buffers are written before/after the contents of this buffer. This may be done either as gather writes, as a poke into this buffer or as several writes. The implementation is free to select the optimal mechanism.

  Specified by:
    `flush` in interface `EndPoint`
  Parameters:
    `header` - A buffer to write before flushing this buffer. This buffers getIndex is updated.
    `buffer` - The buffer to flush. This buffers getIndex is updated.
    `trailer` - A buffer to write after flushing this buffer. This buffers getIndex is updated.
  Returns:
    the total number of bytes written.
  Throws:
    `java.io.IOException`

### reset

    public void reset()

### getLocalAddr

    public java.lang.String getLocalAddr()

  Specified by:
    `getLocalAddr` in interface `EndPoint`
  Returns:
    The local IP address to which this `EndPoint` is bound, or `null` if this `EndPoint` does not represent a network connection.

### getLocalHost

    public java.lang.String getLocalHost()

  Specified by:
    `getLocalHost` in interface `EndPoint`
  Returns:
    The local host name to which this `EndPoint` is bound, or `null` if this `EndPoint` does not represent a network connection.

### getLocalPort

    public int getLocalPort()

  Specified by:
    `getLocalPort` in interface `EndPoint`
  Returns:
    The local port number on which this `EndPoint` is listening, or `0` if this `EndPoint` does not represent a network connection.

### getRemoteAddr

    public java.lang.String getRemoteAddr()

  Specified by:
    `getRemoteAddr` in interface `EndPoint`
  Returns:
    The remote IP address to which this `EndPoint` is connected, or `null` if this `EndPoint` does not represent a network connection.

### getRemoteHost

    public java.lang.String getRemoteHost()

  Specified by:
    `getRemoteHost` in interface `EndPoint`
  Returns:
    The host name of the remote machine to which this `EndPoint` is connected, or `null` if this `EndPoint` does not represent a network connection.

### getRemotePort

    public int getRemotePort()

  Specified by:
    `getRemotePort` in interface `EndPoint`
  Returns:
    The remote port number to which this `EndPoint` is connected, or `0` if this `EndPoint` does not represent a network connection.

### getTransport

    public java.lang.Object getTransport()

  Specified by:
    `getTransport` in interface `EndPoint`
  Returns:
    The underlying transport object (socket, channel, etc.)

### flush

    public void flush()
               throws java.io.IOException

  Description copied from interface: `EndPoint`
  Flush any buffered output. May fail to write all data if endpoint is non-blocking

  Specified by:
    `flush` in interface `EndPoint`
  Throws:
    `java.io.IOException`

### isBufferingInput

    public boolean isBufferingInput()

  Specified by:
    `isBufferingInput` in interface `EndPoint`
  Returns:
    True if the endpoint has some buffered input data

### isBufferingOutput

    public boolean isBufferingOutput()

  Specified by:
    `isBufferingOutput` in interface `EndPoint`
  Returns:
    True if the endpoint has some buffered output data

### isBufferred

    public boolean isBufferred()

  Specified by:
    `isBufferred` in interface `EndPoint`

### isGrowOutput

    public boolean isGrowOutput()

  Returns:
    the growOutput

### setGrowOutput

    public void setGrowOutput(boolean growOutput)

  Parameters:
    `growOutput` - the growOutput to set

### getMaxIdleTime

    public int getMaxIdleTime()

  Description copied from interface: `EndPoint`
  Get the max idle time in ms.

  The max idle time is the time the endpoint can be idle before extraordinary handling takes place. This loosely corresponds to the `Socket.getSoTimeout()` for blocking connections, but `AsyncEndPoint` implementations must use other mechanisms to implement the max idle time.

  Specified by:
    `getMaxIdleTime` in interface `EndPoint`
  Returns:
    the max idle time in ms.
  See Also:
    `EndPoint.getMaxIdleTime()`

### setMaxIdleTime

    public void setMaxIdleTime(int timeMs)
                        throws java.io.IOException

  Description copied from interface: `EndPoint`
  Set the max idle time.

  Specified by:
    `setMaxIdleTime` in interface `EndPoint`
  Parameters:
    `timeMs` - the max idle time in MS.
  Throws:
    `java.io.IOException` - if the timeout cannot be set.
  See Also:
    `EndPoint.setMaxIdleTime(int)`

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.