Class BoundaryDelimitedStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.axis.attachments.BoundaryDelimitedStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class BoundaryDelimitedStream extends FilterInputStream
This class takes the input stream and turns it multiple streams.
Author:
Rick Rineholt
  • Field Details

    • log

      protected static org.apache.commons.logging.Log log
      The Log that this class should log all events to.
    • boundary

      protected byte[] boundary
    • BOUNDARY_NOT_FOUND

      protected static final int BOUNDARY_NOT_FOUND
      Field BOUNDARY_NOT_FOUND.
      See Also:
    • streamNo

      protected int streamNo
      Field streamNo.
  • Constructor Details

    • BoundaryDelimitedStream

      protected BoundaryDelimitedStream(BoundaryDelimitedStream prev, int readbufsz) throws IOException
      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:
      IOException - if there was a problem reading data from prev
  • Method Details

    • newStreamNo

      protected static int newStreamNo()
      Signal that a new stream has been created.
      Returns:
    • getNextStream

      public BoundaryDelimitedStream getNextStream() throws IOException
      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

      protected BoundaryDelimitedStream getNextStream(int readbufsz) throws IOException
      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

      public int read(byte[] b, int off, int len) throws IOException
      Read from the boundary delimited stream.
      Overrides:
      read in class FilterInputStream
      Parameters:
      b - is the array to read into.
      off - is the offset
      len -
      Returns:
      the number of bytes read. -1 if endof stream.
      Throws:
      IOException
    • read

      public int read(byte[] b) throws IOException
      Read from the boundary delimited stream.
      Overrides:
      read in class FilterInputStream
      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

      public int read() throws IOException
      Read from the boundary delimited stream.
      Overrides:
      read in class FilterInputStream
      Returns:
      The byte read, or -1 if endof stream.
      Throws:
      IOException
    • close

      public void close() throws IOException
      Closes the stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class FilterInputStream
      Throws:
      IOException
    • mark

      public void mark(int readlimit)
      mark the stream. This is not supported.
      Overrides:
      mark in class FilterInputStream
      Parameters:
      readlimit -
    • reset

      public void reset() throws IOException
      reset the stream. This is not supported.
      Overrides:
      reset in class FilterInputStream
      Throws:
      IOException
    • markSupported

      public boolean markSupported()
      markSupported return false;
      Overrides:
      markSupported in class FilterInputStream
      Returns:
    • available

      public int available() throws IOException
      Overrides:
      available in class FilterInputStream
      Throws:
      IOException
    • boundaryPosition

      protected int boundaryPosition(byte[] searchbuf, int start, int end) throws IOException
      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:
      IOException - if there was an error manipulating the underlying stream
    • finalClose

      protected void finalClose() throws IOException
      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 -