Package org.apache.axis.attachments
Class BoundaryDelimitedStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.axis.attachments.BoundaryDelimitedStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
This class takes the input stream and turns it multiple streams.
- Author:
- Rick Rineholt
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
protected static final int
Field BOUNDARY_NOT_FOUND.protected static org.apache.commons.logging.Log
TheLog
that this class should log all events to.protected int
Field streamNo.Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BoundaryDelimitedStream
(BoundaryDelimitedStream prev, int readbufsz) Constructor to create the next stream from the previous one. -
Method Summary
Modifier and TypeMethodDescriptionint
protected int
boundaryPosition
(byte[] searchbuf, int start, int end) Read from the boundary delimited stream.void
close()
Closes the stream.protected void
Close the underlying stream and remove all references to it.Gets the next stream.protected BoundaryDelimitedStream
getNextStream
(int readbufsz) Gets the next stream.void
mark
(int readlimit) mark the stream.boolean
markSupported return false;protected static int
Signal that a new stream has been created.static void
printarry
(byte[] b, int start, int end) Method printarryint
read()
Read from the boundary delimited stream.int
read
(byte[] b) Read from the boundary delimited stream.int
read
(byte[] b, int off, int len) Read from the boundary delimited stream.void
reset()
reset the stream.Methods inherited from class java.io.FilterInputStream
skip
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
log
protected static org.apache.commons.logging.Log logTheLog
that this class should log all events to. -
boundary
protected byte[] boundary -
BOUNDARY_NOT_FOUND
protected static final int BOUNDARY_NOT_FOUNDField BOUNDARY_NOT_FOUND.- See Also:
-
streamNo
protected int streamNoField streamNo.
-
-
Constructor Details
-
BoundaryDelimitedStream
Constructor to create the next stream from the previous one.- Parameters:
prev
- the previous streamreadbufsz
- how many bytes to make the read buffer- Throws:
IOException
- if there was a problem reading data fromprev
-
-
Method Details
-
newStreamNo
protected static int newStreamNo()Signal that a new stream has been created.- Returns:
-
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:
IOException
- if there was an error loading the data for the next stream
-
getNextStream
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:
IOException
- if there was an error loading the data for the next stream
-
read
Read from the boundary delimited stream.- Overrides:
read
in classFilterInputStream
- Parameters:
b
- is the array to read into.off
- is the offsetlen
-- Returns:
- the number of bytes read. -1 if endof stream.
- Throws:
IOException
-
read
Read from the boundary delimited stream.- Overrides:
read
in classFilterInputStream
- 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:
IOException
-
read
Read from the boundary delimited stream.- Overrides:
read
in classFilterInputStream
- Returns:
- The byte read, or -1 if endof stream.
- Throws:
IOException
-
close
Closes the stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit) mark the stream. This is not supported.- Overrides:
mark
in classFilterInputStream
- Parameters:
readlimit
-
-
reset
reset the stream. This is not supported.- Overrides:
reset
in classFilterInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()markSupported return false;- Overrides:
markSupported
in classFilterInputStream
- Returns:
-
available
- Overrides:
available
in classFilterInputStream
- Throws:
IOException
-
boundaryPosition
Read from the boundary delimited stream.- Parameters:
searchbuf
- buffer to read fromstart
- starting indexend
- ending index- Returns:
- The position of the boundary. Detects the end of the source stream.
- Throws:
IOException
- if there was an error manipulating the underlying stream
-
finalClose
Close the underlying stream and remove all references to it.- Throws:
IOException
- if the stream could not be closed
-
printarry
public static void printarry(byte[] b, int start, int end) Method printarry- Parameters:
b
-start
-end
-
-