org.mortbay.io
Class ByteArrayEndPoint

java.lang.Object
  extended by org.mortbay.io.ByteArrayEndPoint
All Implemented Interfaces:
EndPoint

public class ByteArrayEndPoint
extends Object
implements EndPoint

ByteArrayEndPoint.

Author:
gregw

Field Summary
(package private)  boolean _closed
           
(package private)  ByteArrayBuffer _in
           
(package private)  byte[] _inBytes
           
(package private)  ByteArrayBuffer _out
           
 
Constructor Summary
ByteArrayEndPoint()
           
ByteArrayEndPoint(byte[] input, int outputSize)
           
 
Method Summary
 void blockReadable(long millisecs)
           
 void blockWritable(long millisecs)
           
 void close()
          Close any backing stream associated with the buffer
 int fill(Buffer buffer)
          Fill the buffer from the current putIndex to it's capacity from whatever byte source is backing the buffer.
 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.
 Object getConnection()
           
 ByteArrayBuffer getIn()
           
 String getLocalAddr()
           
 String getLocalHost()
           
 int getLocalPort()
           
 ByteArrayBuffer getOut()
           
 String getRemoteAddr()
           
 String getRemoteHost()
           
 int getRemotePort()
           
 boolean isBlocking()
           
 boolean isOpen()
           
 void reset()
           
 void setIn(ByteArrayBuffer in)
           
 void setOut(ByteArrayBuffer out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_inBytes

byte[] _inBytes

_in

ByteArrayBuffer _in

_out

ByteArrayBuffer _out

_closed

boolean _closed
Constructor Detail

ByteArrayEndPoint

public ByteArrayEndPoint()

ByteArrayEndPoint

public ByteArrayEndPoint(byte[] input,
                         int outputSize)
Method Detail

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 void blockReadable(long millisecs)
Specified by:
blockReadable in interface EndPoint

blockWritable

public void blockWritable(long millisecs)
Specified by:
blockWritable in interface EndPoint

close

public void close()
           throws IOException
Description copied from interface: EndPoint
Close any backing stream associated with the buffer

Specified by:
close in interface EndPoint
Throws:
IOException

fill

public int fill(Buffer buffer)
         throws 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:
IOException

flush

public int flush(Buffer buffer)
          throws 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:
IOException

flush

public int flush(Buffer header,
                 Buffer buffer,
                 Buffer trailer)
          throws 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:
IOException

reset

public void reset()

getLocalAddr

public String getLocalAddr()
Specified by:
getLocalAddr in interface EndPoint
Returns:

getLocalHost

public String getLocalHost()
Specified by:
getLocalHost in interface EndPoint
Returns:

getLocalPort

public int getLocalPort()
Specified by:
getLocalPort in interface EndPoint
Returns:

getRemoteAddr

public String getRemoteAddr()
Specified by:
getRemoteAddr in interface EndPoint

getRemoteHost

public String getRemoteHost()
Specified by:
getRemoteHost in interface EndPoint
Returns:

getRemotePort

public int getRemotePort()
Specified by:
getRemotePort in interface EndPoint
Returns:

getConnection

public Object getConnection()
Specified by:
getConnection in interface EndPoint