org.locomotive.commerce.ics
Class SCMPMessage

java.lang.Object
  |
  +--org.locomotive.commerce.ics.SCMPMessage

public class SCMPMessage
extends java.lang.Object

A wrapper for the CyberSource C-Library ics_msg API funtions essentially mirror their C counterparts. Used by ICSRequest and ICSReply. Most often an implementor will not need to use this lower level interface, but it is provided for additional flexibility. Please see the Cybersource CommerceFLEX API documentation for more information.


Constructor Summary
SCMPMessage(boolean debug_on)
          Creates a new SCMPMessage.
 
Method Summary
 int addField(java.lang.String name, java.lang.String value)
          Adds a name value pair to the message.
protected  void finalize()
          When the SCMPMessages are unreferenced, the garbage collector eventually comes along to free the memory.
 int getFieldCount()
          Gets the field count.
 java.lang.String getName(int field_index)
          gets the field name at index postion field_index.
 java.lang.String getValue(int field_index)
          gets the field value at index postion field_index.
 java.lang.String getValueByName(java.lang.String name)
          Gets the field for a specified name.
 int removeField(java.lang.String name)
          removes a field of the specified name
 SCMPMessage send()
          sends a message to the ICS gateway.
 java.lang.String toString()
          Provides debugging information and complete message contents, as a String.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SCMPMessage

public SCMPMessage(boolean debug_on)
            throws SCMPException
Creates a new SCMPMessage.
Parameters:
debug_on - if true, turns on debugging to the stdout of the C based ics_msg library.
Method Detail

addField

public int addField(java.lang.String name,
                    java.lang.String value)
Adds a name value pair to the message. If the name match a name currently specified in the message, the name value pair will be overwritten. As of version2.4 of the Cybersource libraries, there is a limit of 64 name value pairs.
Parameters:
name - - the name of the field. Should not be null or ""
value - - the field value. Can be nullstring. ("")

getFieldCount

public int getFieldCount()
Gets the field count. The entire list of name-value pairs can be iterated using a 'for' loop and this number.

getName

public java.lang.String getName(int field_index)
gets the field name at index postion field_index. Returns null if the index is out of range. Field postions start at index 0.

getValue

public java.lang.String getValue(int field_index)
gets the field value at index postion field_index. Returns null if the index is out of range. Field postions start at index 0.

getValueByName

public java.lang.String getValueByName(java.lang.String name)
Gets the field for a specified name. If the name does not exist in the message, null is returned
Parameters:
name - - the name of the name value pair

removeField

public int removeField(java.lang.String name)
removes a field of the specified name

send

public SCMPMessage send()
                 throws SCMPException
sends a message to the ICS gateway. The message returned is the reply.
Throws:
SCMPException - if the message cannot be sent, if the reply cannot be created if this message is a response

toString

public java.lang.String toString()
Provides debugging information and complete message contents, as a String.
Overrides:
toString in class java.lang.Object

finalize

protected void finalize()
When the SCMPMessages are unreferenced, the garbage collector eventually comes along to free the memory. We need to make sure that the memory allocated in the native libraries is freed too. Once this occurs, we can make the 'indirect handle' or index available again via the stack.
Overrides:
finalize in class java.lang.Object