org.apache.axiom.attachments
Class BoundaryPushbackInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.axiom.attachments.BoundaryPushbackInputStream
All Implemented Interfaces:
java.io.Closeable

public class BoundaryPushbackInputStream
extends java.io.InputStream

An InputStream that reads bytes up to a boundary. The boundary is not logically part of the bytes to read. The wrapped PushbackInputStream is set to to the byte after the boundary once the bytes are read. The boundary is not logically returned. There are two forms that are supported, where . is a byte .......................boundary and ..................../r/nboundary In both cases, only the bytes (.) are returned.


Field Summary
(package private)  int bIndex
           
(package private)  byte[] boundary
           
protected static int BOUNDARY_NT_FOUND
           
(package private)  boolean boundaryFound
           
(package private)  byte[] buffer
           
(package private)  int bufferSize
           
(package private)  int index
           
(package private)  java.io.PushbackInputStream is
           
private static boolean isDebugEnabled
           
private static org.apache.commons.logging.Log log
           
(package private)  int MIN_BUF_SIZE
           
(package private)  int numBytes
           
private  byte[] read_byte
           
(package private)  int rnBoundaryLen
           
private  short[] skip
           
 
Constructor Summary
BoundaryPushbackInputStream(java.io.PushbackInputStream inStream, byte[] boundary, int pushBackSize)
           
 
Method Summary
protected  int boundaryPosition(byte[] searchbuf, int start, int end)
          Read from the boundary delimited stream.
 boolean getBoundaryStatus()
           
 int read()
          Read from the boundary delimited stream.
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
          Read from the boundary delimited stream.
private  int readFromStream(byte[] b)
           
private  int readFromStream(byte[] b, int start, int length)
          Method readFromStream
 java.lang.String toString()
          toString dumps state information.
private  void unread()
          Unread the bytes past the buffer
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

isDebugEnabled

private static boolean isDebugEnabled

is

java.io.PushbackInputStream is

boundaryFound

boolean boundaryFound

boundary

byte[] boundary

rnBoundaryLen

int rnBoundaryLen

buffer

byte[] buffer

bufferSize

int bufferSize

numBytes

int numBytes

index

int index

bIndex

int bIndex

MIN_BUF_SIZE

final int MIN_BUF_SIZE
See Also:
Constant Field Values

BOUNDARY_NT_FOUND

protected static final int BOUNDARY_NT_FOUND
See Also:
Constant Field Values

skip

private short[] skip

read_byte

private byte[] read_byte
Constructor Detail

BoundaryPushbackInputStream

public BoundaryPushbackInputStream(java.io.PushbackInputStream inStream,
                                   byte[] boundary,
                                   int pushBackSize)
Parameters:
inStream -
boundary -
pushBackSize -
Method Detail

readFromStream

private final int readFromStream(byte[] b,
                                 int start,
                                 int length)
                          throws java.io.IOException
Method readFromStream

Parameters:
b -
start -
length -
Returns:
Throws:
java.io.IOException

readFromStream

private final int readFromStream(byte[] b)
                          throws java.io.IOException
Parameters:
b -
Returns:
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Read from the boundary delimited stream. Generally, this won't be called...callers will most likely call the read(byte[]..) methods

Specified by:
read in class java.io.InputStream
Returns:
The byte read, or -1 if endof stream.
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read from the boundary delimited stream.

Overrides:
read in class java.io.InputStream
Parameters:
b - is the array to read into.
off - is the offset
len -
Returns:
the number of bytes read. -1 if endof stream.
Throws:
java.io.IOException

unread

private void unread()
             throws java.io.IOException
Unread the bytes past the buffer

Throws:
java.io.IOException

boundaryPosition

protected int boundaryPosition(byte[] searchbuf,
                               int start,
                               int end)
                        throws java.io.IOException
Read from the boundary delimited stream.

Parameters:
searchbuf -
start -
end -
Returns:
The position of the boundary.
Throws:
java.io.IOException

getBoundaryStatus

public boolean getBoundaryStatus()

toString

public java.lang.String toString()
toString dumps state information. Effective for debug trace.

Overrides:
toString in class java.lang.Object