com.ibm.etill.kitcashcassette.io
Class MimeOutputStream

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

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

This class defines a Mime wrapped OutputStream. It has methods to fill in fields of a MimeHeader, then it takes all the fields filled in and composes a Mime header, adds the message if any and sends everything trought a DataOutput stream.
HOW TO USE
- connect this class to a DataOutputStream (done in the constructor)
- set the Mime fields using the setters writeXxxx()
- call writeMime() to really build the Mime header and write it to the DataOutputStream followed by a message
The message is a byte array.
BEWARE this class doesn't reset the fields if it is used to send a second message, it is up to the user to do so or to add a reset method.


Field Summary
protected  byte[] baMsg
           
protected  java.lang.String content
           
protected  java.lang.String ctClass
           
protected  java.lang.String ctControl
           
protected  int ctDelay
           
protected  java.lang.String ctMsgTag
           
protected  java.io.OutputStream dos
           
protected  java.lang.String encoding
           
protected  int length
           
 
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
MimeOutputStream(java.io.DataOutputStream dos)
          Creates a new MimeOutput stream to write data to a DataOutputStream.
 
Method Summary
 void setContentType(java.lang.String content)
          Stores the content-type field to be used when the writeMime() method is called.
 void setContentTypeClass(java.lang.String ctClass)
          Stores the content-type class field to be used when the writeMime() method is called.
 void setContentTypeControl(java.lang.String ctControl)
          Stores the content-type control field to be used when the writeMime() method is called.
 void setContentTypeDelay(int ctDelay)
          Stores the content-type delay field to be used when the writeMime() method is called.
 void setContentTypeMsgTag(java.lang.String ctMsgTag)
          Stores the content-type message tag field to be used when the writeMime() method is called.
 void setEncoding(java.lang.String encoding)
          Stores the Encoding field to be used when the writeMime() method is called.
 void setLength(int length)
          Stores the Length field to be used when the writeMime() method is called.
 void setMessage(byte[] baMsg)
          Stores the byte array containing the message to be used when the writeMime() method is called.
 void writeMime()
          This method takes Mime fields and converts them into an OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dos

protected java.io.OutputStream dos

content

protected java.lang.String content

ctMsgTag

protected java.lang.String ctMsgTag

ctControl

protected java.lang.String ctControl

ctClass

protected java.lang.String ctClass

ctDelay

protected int ctDelay

encoding

protected java.lang.String encoding

length

protected int length

baMsg

protected byte[] baMsg
Constructor Detail

MimeOutputStream

public MimeOutputStream(java.io.DataOutputStream dos)
Creates a new MimeOutput stream to write data to a DataOutputStream.
Parameters:
dos - the DataOutput stream
Method Detail

setContentType

public void setContentType(java.lang.String content)
Stores the content-type field to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
content - The content-type field

setContentTypeClass

public void setContentTypeClass(java.lang.String ctClass)
Stores the content-type class field to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
ctClass - The content-type class field

setContentTypeControl

public void setContentTypeControl(java.lang.String ctControl)
Stores the content-type control field to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
ctControl - The content-type control field

setContentTypeDelay

public void setContentTypeDelay(int ctDelay)
Stores the content-type delay field to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
ctDelay - The content-type delay field

setContentTypeMsgTag

public void setContentTypeMsgTag(java.lang.String ctMsgTag)
Stores the content-type message tag field to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
ctMsgTag - The content-type message tag field

setEncoding

public void setEncoding(java.lang.String encoding)
Stores the Encoding field to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
encoding - The Encoding field

setLength

public void setLength(int length)
Stores the Length field to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
length - The Length field

setMessage

public void setMessage(byte[] baMsg)
Stores the byte array containing the message to be used when the writeMime() method is called. Call it before writeMime().
Parameters:
baMsg - The byte array

writeMime

public void writeMime()
               throws java.io.IOException
This method takes Mime fields and converts them into an OutputStream. At least the content-type field has to be filled in. This method must be called after all the desired fields have been filled in. An IOException is thrown if the "content-type" is missing or if an error occured when writing to the DataOutputStream.