org.granite.gravity.tomcat
Class ByteArrayCometIO

java.lang.Object
  extended by java.io.InputStream
      extended by org.granite.gravity.tomcat.ByteArrayCometIO
All Implemented Interfaces:
Closeable, CometIO

public class ByteArrayCometIO
extends InputStream
implements CometIO

An unsynchronized input/output byte buffer that avoids useless byte array copies.

Author:
Franck

Field Summary
protected  byte[] buf
           
protected  int count
           
protected  int initialCapacity
           
protected  int mark
           
protected  int pos
           
 
Constructor Summary
ByteArrayCometIO()
           
ByteArrayCometIO(int initialCapacity)
           
 
Method Summary
 int available()
           
 void close()
           
 InputStream getInputStream()
           
 void mark(int readAheadLimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 boolean readAvailable(InputStream is)
           
 int readFully(InputStream is)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.io.InputStream
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialCapacity

protected final int initialCapacity

buf

protected byte[] buf

pos

protected int pos

mark

protected int mark

count

protected int count
Constructor Detail

ByteArrayCometIO

public ByteArrayCometIO()

ByteArrayCometIO

public ByteArrayCometIO(int initialCapacity)
Method Detail

readFully

public int readFully(InputStream is)
              throws IOException
Specified by:
readFully in interface CometIO
Throws:
IOException

readAvailable

public boolean readAvailable(InputStream is)
                      throws IOException
Specified by:
readAvailable in interface CometIO
Throws:
IOException

getInputStream

public InputStream getInputStream()
                           throws IOException
Specified by:
getInputStream in interface CometIO
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
Overrides:
read in class InputStream

skip

public long skip(long n)
Overrides:
skip in class InputStream

available

public int available()
Overrides:
available in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

mark

public void mark(int readAheadLimit)
Overrides:
mark in class InputStream

reset

public void reset()
Overrides:
reset in class InputStream

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException