org.apache.axis.attachments

Class BoundaryDelimitedStream

public class BoundaryDelimitedStream extends FilterInputStream

This class takes the input stream and turns it multiple streams.

Author: Rick Rineholt

Field Summary
protected byte[]boundary
protected static intBOUNDARY_NOT_FOUND
Field BOUNDARY_NOT_FOUND.
protected static Loglog
The Log that this class should log all events to.
protected intstreamNo
Field streamNo.
Constructor Summary
protected BoundaryDelimitedStream(BoundaryDelimitedStream prev, int readbufsz)
Constructor to create the next stream from the previous one.
Method Summary
intavailable()
protected intboundaryPosition(byte[] searchbuf, int start, int end)
Read from the boundary delimited stream.
voidclose()
Closes the stream.
protected voidfinalClose()
Close the underlying stream and remove all references to it.
BoundaryDelimitedStreamgetNextStream()
Gets the next stream.
protected BoundaryDelimitedStreamgetNextStream(int readbufsz)
Gets the next stream.
voidmark(int readlimit)
mark the stream.
booleanmarkSupported()
markSupported return false;
protected static intnewStreamNo()
Signal that a new stream has been created.
static voidprintarry(byte[] b, int start, int end)
Method printarry
intread(byte[] b, int off, int len)
Read from the boundary delimited stream.
intread(byte[] b)
Read from the boundary delimited stream.
intread()
Read from the boundary delimited stream.
voidreset()
reset the stream.

Field Detail

boundary

protected byte[] boundary

BOUNDARY_NOT_FOUND

protected static final int BOUNDARY_NOT_FOUND
Field BOUNDARY_NOT_FOUND.

log

protected static Log log
The Log that this class should log all events to.

streamNo

protected int streamNo
Field streamNo.

Constructor Detail

BoundaryDelimitedStream

protected BoundaryDelimitedStream(BoundaryDelimitedStream prev, int readbufsz)
Constructor to create the next stream from the previous one.

Parameters: prev the previous stream readbufsz how many bytes to make the read buffer

Throws: java.io.IOException if there was a problem reading data from prev

Method Detail

available

public int available()

boundaryPosition

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

Parameters: searchbuf buffer to read from start starting index end ending index

Returns: The position of the boundary. Detects the end of the source stream.

Throws: java.io.IOException if there was an error manipulating the underlying stream

close

public void close()
Closes the stream.

Throws: java.io.IOException

finalClose

protected void finalClose()
Close the underlying stream and remove all references to it.

Throws: java.io.IOException if the stream could not be closed

getNextStream

public BoundaryDelimitedStream getNextStream()
Gets the next stream. From the previous using the same buffer size to read.

Returns: the boundary delmited stream, null if there are no more streams.

Throws: java.io.IOException if there was an error loading the data for the next stream

getNextStream

protected BoundaryDelimitedStream getNextStream(int readbufsz)
Gets the next stream. From the previous using new buffer reading size.

Parameters: readbufsz

Returns: the boundary delmited stream, null if there are no more streams.

Throws: java.io.IOException if there was an error loading the data for the next stream

mark

public void mark(int readlimit)
mark the stream. This is not supported.

Parameters: readlimit

markSupported

public boolean markSupported()
markSupported return false;

Returns:

newStreamNo

protected static int newStreamNo()
Signal that a new stream has been created.

Returns:

printarry

public static void printarry(byte[] b, int start, int end)
Method printarry

Parameters: b start end

read

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

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

read

public int read(byte[] b)
Read from the boundary delimited stream.

Parameters: b is the array to read into. Read as much as possible into the size of this array.

Returns: the number of bytes read. -1 if endof stream.

Throws: java.io.IOException

read

public int read()
Read from the boundary delimited stream.

Returns: The byte read, or -1 if endof stream.

Throws: java.io.IOException

reset

public void reset()
reset the stream. This is not supported.

Throws: java.io.IOException

Copyright B) 2005 Apache Web Services Project. All Rights Reserved.