com.ibm.etill.kitcashcassette
Class KitCashMessageWrapper

java.lang.Object
  |
  +--com.ibm.etill.kitcashcassette.KitCashMessageWrapper

public class KitCashMessageWrapper
extends java.lang.Object


Constructor Summary
KitCashMessageWrapper(java.lang.String receiver, java.lang.String senderID, KitCashException error)
          Constructs a new KitCashMessageWrapper object containing a KitCash error message.
KitCashMessageWrapper(java.lang.String receiver, java.lang.String senderID, KitCashMessage contents)
          Constructs a new KitCashMessageWrapper object containing the KitCash protocol message.
 
Method Summary
 int getAmount()
          Returns the cash transfer amount from the message wrapper
 KitCashMessage getContents()
          Returns the KitCash message inside this wrapper
 KitCashException getError()
          Returns the KitCash error message inside this wrapper
 java.lang.String getReceiver()
          Returns the ID of the receiver of the message
 KitCashMessageWrapper getResponse(java.lang.String host, int port)
          Wraps the message or error message in a MIME message, sends it to the specified port and returns the response message.
 java.lang.String getSenderID()
          Returns the ID of the sender of the message as designated by the receiver.
static KitCashMessageWrapper readMessage(java.io.InputStream is)
          Reads a MIME message from the input stream and returns the KitCashMessage contained in that stream.
 void setAmount(int amount)
          Sets the amount of the cash transfer in the message wrapper.
 java.lang.String toString()
          Returns a string representation of the KitCashMessageWrapper.
 void writeMessage(java.io.OutputStream os)
          Wraps the KitCash protocol message in a MIME message and writes it to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KitCashMessageWrapper

public KitCashMessageWrapper(java.lang.String receiver,
                             java.lang.String senderID,
                             KitCashException error)
Constructs a new KitCashMessageWrapper object containing a KitCash error message.
Parameters:
error - the error message to be sent
receiver - the receiver of the message
senderID - the receiver's ID for the sender (e.g. order number or account number)

KitCashMessageWrapper

public KitCashMessageWrapper(java.lang.String receiver,
                             java.lang.String senderID,
                             KitCashMessage contents)
Constructs a new KitCashMessageWrapper object containing the KitCash protocol message.
Parameters:
contents - the KitCash protocol message
receiver - the receiver of the message
senderID - the receiver's ID for the sender (e.g. order number or account number)
Method Detail

getAmount

public int getAmount()
Returns the cash transfer amount from the message wrapper
Returns:
the KitCash error message

getContents

public KitCashMessage getContents()
Returns the KitCash message inside this wrapper
Returns:
the KitCash message

getError

public KitCashException getError()
Returns the KitCash error message inside this wrapper
Returns:
the KitCash error message

getReceiver

public java.lang.String getReceiver()
Returns the ID of the receiver of the message
Returns:
the ID of the receiver of the message (e.g. the merchant number of the bank ID)

getResponse

public KitCashMessageWrapper getResponse(java.lang.String host,
                                         int port)
                                  throws java.io.IOException
Wraps the message or error message in a MIME message, sends it to the specified port and returns the response message.
Parameters:
host - the hostname of the receiver
port - the port number of the receiver
Throws:
java.io.IOException - if the communication fails

getSenderID

public java.lang.String getSenderID()
Returns the ID of the sender of the message as designated by the receiver.

When sending a KitCash message from consumer to merchant, this should be the order number. When sending a KitCash message from merchant to bank, this should be the account number.

Returns:
the sender ID

readMessage

public static KitCashMessageWrapper readMessage(java.io.InputStream is)
                                         throws java.io.IOException
Reads a MIME message from the input stream and returns the KitCashMessage contained in that stream.
Parameters:
is - the input stream from which to read the MIME message
Throws:
java.io.IOException - if the communication fails

setAmount

public void setAmount(int amount)
Sets the amount of the cash transfer in the message wrapper.
Parameters:
amount - the amount to transfer

toString

public java.lang.String toString()
Returns a string representation of the KitCashMessageWrapper.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the KitCashMessageWrapper

writeMessage

public void writeMessage(java.io.OutputStream os)
                  throws java.io.IOException
Wraps the KitCash protocol message in a MIME message and writes it to the given output stream.
Parameters:
os - the output stream to which to write the message
Throws:
java.io.IOException - if the communication fails