org.jboss.axis.attachments
Class DimeDelimitedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.jboss.axis.attachments.DimeDelimitedInputStream
All Implemented Interfaces:
Closeable

public class DimeDelimitedInputStream
extends FilterInputStream

This class takes the input stream and turns it multiple streams. DIME version 0 format

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  ---
 | VERSION |B|E|C| TYPE_T| OPT_T |         OPTIONS_LENGTH        |   A
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |          ID_LENGTH          |             TYPE_LENGTH         |   Always present 12 bytes
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+   even on chunked data.
 |                          DATA_LENGTH                          |   V
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+  ---
 |                                                               /
 /                       OPTIONS + PADDING                       /
 /                     (absent for version 0)                    |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               /
 /                        ID + PADDING                           /
 /                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               /
 /                        TYPE + PADDING                         /
 /                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 |                                                               /
 /                        DATA + PADDING                         /
 /                                                               |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 

Author:
Rick Rineholt

Field Summary
protected static int streamCount
           
protected  IOException streamInError
           
protected  int streamNo
           
 
Fields inherited from class java.io.FilterInputStream
in
 
Method Summary
protected  int _read(byte[] b, int off, int len)
           
 int available()
           
 void close()
          Closes the stream.
protected  void finalClose()
           
 String getContentId()
          Get the id for this stream part.
 DimeTypeNameFormat getDimeTypeNameFormat()
          Read from the boundary delimited stream.
 String getType()
          get type.
 void mark(int readlimit)
          mark the stream.
 boolean markSupported()
          markSupported return false;
protected static int newStreamNo()
           
 int read()
          Read from the boundary delimited stream.
 int read(byte[] b)
          Read from the delimited stream.
 int read(byte[] b, int off, int len)
          Read from the DIME stream.
 void reset()
          reset the stream.
 
Methods inherited from class java.io.FilterInputStream
skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

streamNo

protected int streamNo

streamInError

protected IOException streamInError

streamCount

protected static int streamCount
Method Detail

newStreamNo

protected static int newStreamNo()

getContentId

public String getContentId()
Get the id for this stream part.

Returns:
the id;

getDimeTypeNameFormat

public DimeTypeNameFormat getDimeTypeNameFormat()
Read from the boundary delimited stream.

Parameters:
b - is the array to read into.
off - is the offset
Returns:
the number of bytes read. -1 if endof stream.

getType

public String getType()
get type.

Parameters:
b - is the array to read into.
off - is the offset
Returns:
the number of bytes read. -1 if endof stream.

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Read from the DIME stream.

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

_read

protected int _read(byte[] b,
                    int off,
                    int len)
             throws IOException
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Read from the 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 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

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

available

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

finalClose

protected void finalClose()
                   throws IOException
Throws:
IOException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.