com.ibm.etill.kitcashcassette.io
Class MimeInputStream

java.lang.Object
  |
  +--com.ibm.etill.kitcashcassette.io.MimeInputStream
All Implemented Interfaces:
MimeConst

public final class MimeInputStream
extends java.lang.Object
implements MimeConst

This class defines a Mime wrapped InputStream. It reads data from an Input stream, looks for the Mime header, processes it to extract the known fields. When the length is found, it reads the message that is Mime wrapped.
HOW TO USE IT
- connect this class to a TimeOutInputStream (done in the constructor)
- call readMime() to process the stream. If the TimeOutInputStream doesn't contain any MimeHeader an IOException is thrown.
- if the TimeOutInputStream does contain a Mime Header the getters readXxxx() can be called to retrieved the values of the fields.


Field Summary
protected  TimeOutInputStream tois
           
 
Fields inherited from interface com.ibm.etill.kitcashcassette.io.MimeConst
MAX_SIZE_MIMEHEADER, MHL_CTENCODING, MHL_CTENCODING_7BIT, MHL_CTENCODING_BIN, MHL_CTYPE, MHL_CTYPE_APP, MHL_CTYPE_CLASS, MHL_CTYPE_CLASS_CLOSING, MHL_CTYPE_CLASS_FAILED, MHL_CTYPE_CLASS_INFO, MHL_CTYPE_CLASS_RETRY, MHL_CTYPE_CONTROL, MHL_CTYPE_CONTROL_CLOSE, MHL_CTYPE_CONTROL_CLOSER, MHL_CTYPE_CONTROL_ECHO, MHL_CTYPE_CONTROL_ECHOR, MHL_CTYPE_CONTROL_STATUS, MHL_CTYPE_DELAY, MHL_CTYPE_MSGTAG, MHL_CTYPE_SEP, MHL_CTYPE_TXT, MHL_EOHEADER, MHL_EOL, MHL_EQUAL, MHL_LENGTH, MHL_MVERSION, MHL_SEP, MHL_SPACE, MHL_VERSION
 
Constructor Summary
MimeInputStream(TimeOutInputStream tois)
          Creates a new Mime input stream to read data from the specified TimeOut input stream.
 
Method Summary
 java.lang.String getContentType()
          Returns the content-type field found after calling the readMime() method.
 java.lang.String getContentTypeClass()
          Returns the content-type class field found after calling the readMime() method.
 java.lang.String getContentTypeControl()
          Returns the content-type control field found after calling the readMime() method.
 int getContentTypeDelay()
          Returns the content-type delay field found after calling the readMime() method.
 java.lang.String getContentTypeMsgTag()
          Returns the content-type message tag field found after calling the readMime() method.
 java.lang.String getEncoding()
          Returns the encoding field found after calling the readMime() method.
 int getLength()
          Returns the Length field found after calling the readMime() method.
 byte[] getMessage()
          Returns the byte array containing the message found after calling the readMime() method.
 java.lang.String getMimeVersion()
          Returns the Mime version field found after calling the readMime() method.
 void readMime()
          This method reads and parses a Mime wrapped TimeOutInputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tois

protected TimeOutInputStream tois
Constructor Detail

MimeInputStream

public MimeInputStream(TimeOutInputStream tois)
Creates a new Mime input stream to read data from the specified TimeOut input stream.
Parameters:
tois - the TimeOut input stream
Method Detail

getContentType

public java.lang.String getContentType()
Returns the content-type field found after calling the readMime() method.
Returns:
The content-type field

getContentTypeClass

public java.lang.String getContentTypeClass()
Returns the content-type class field found after calling the readMime() method.
Returns:
The content-type class tag field

getContentTypeControl

public java.lang.String getContentTypeControl()
Returns the content-type control field found after calling the readMime() method.
Returns:
The content-type control tag field

getContentTypeDelay

public int getContentTypeDelay()
Returns the content-type delay field found after calling the readMime() method.
Returns:
The content-type delay tag field

getContentTypeMsgTag

public java.lang.String getContentTypeMsgTag()
Returns the content-type message tag field found after calling the readMime() method.
Returns:
The content-type message tag field

getEncoding

public java.lang.String getEncoding()
Returns the encoding field found after calling the readMime() method.
Returns:
The encoding field

getLength

public int getLength()
Returns the Length field found after calling the readMime() method.
Returns:
The length field

getMessage

public byte[] getMessage()
Returns the byte array containing the message found after calling the readMime() method.
Returns:
a reference to the byte array

getMimeVersion

public java.lang.String getMimeVersion()
Returns the Mime version field found after calling the readMime() method.
Returns:
The Mime Version field

readMime

public void readMime()
              throws java.io.IOException
This method reads and parses a Mime wrapped TimeOutInputStream. This method must be called before any other method of this class because it reads the input Stream, processes it and fills in the fields. An IOException is thrown if no Mime header is found before MAX_SIZE_MIMEHEADER bytes are read.