com.ibm.mq.pcf
Class PCFMessage

java.lang.Object
  |
  +--com.ibm.mq.pcf.PCFHeader
        |
        +--com.ibm.mq.pcf.PCFMessage
All Implemented Interfaces:
java.io.Serializable

public class PCFMessage
extends PCFHeader
implements java.io.Serializable

Class encapsulating a PCF message. A PCFMessage typically represents a PCF request or response or an event message, which consists of an MQCFH header followed by a set of PCFParameter structures (type MQCFIN, MQCFIL, MQCFST or MQCFSL). A PCFMessage instance can be constructed and manipulated without direct reference to the PCF header and parameter structures themselves.

A PCFMessage instance can be repopulated for reuse using its initialize methods.

Version:
2.2
Author:
Chris Markes
See Also:
PCFMessageAgent, Serialized Form

Field Summary
static java.lang.String copyright
           
 
Constructor Summary
PCFMessage(int command)
          Initializes a PCFMessage as a PCF request with the specified MQCFH command identifier.
PCFMessage(int type, int command, int msgSeqNumber, boolean last)
          Initializes a PCFMessage with the specified MQCFH type, command identifier, sequence number and control indicator.
PCFMessage(com.ibm.mq.MQMessage message)
          Initializes a PCFMessage from the contents of an MQMessage.
 
Method Summary
 void addParameter(int parameter, int value)
          Adds an integer parameter to the PCFMessage.
 void addParameter(int parameter, int[] values)
          Adds an integer list parameter to the PCFMessage.
 void addParameter(int parameter, java.lang.String value)
          Adds a string parameter to the PCFMessage.
 void addParameter(int parameter, java.lang.String[] values)
          Adds a string list parameter to the PCFMessage.
 void addParameter(PCFParameter parameter)
          Adds a PCFParameter to the PCFMessage.
 int getCommand()
          Returns the PCF command identifier
 int getCompCode()
          Returns the completion code in the MQCFH.
 int getControl()
          Returns the PCF header control indicator.
 int[] getIntListParameterValue(int parameter)
          Returns the value of the specified integer list parameter (MQCFIL) as an array of integers.
 int getIntParameterValue(int parameter)
          Returns the value of the specified integer parameter (MQCFIN) as an integer.
 int getMsgSeqNumber()
          Returns the PCF message sequence number
 int getParameterCount()
          Returns the number of parameter structures in the PCF message.
 java.util.Enumeration getParameters()
          Returns an enumeration of the parameters in the PCFMessage.
 java.lang.Object getParameterValue(int parameter)
          Returns the value of the specified parameter, or null if the parameter is not found.
 int getReason()
          Returns the reason code in the MQCFH.
 java.lang.String[] getStringListParameterValue(int parameter)
          Returns the value of the specified string list parameter (MQCFSL) as an array of strings.
 java.lang.String getStringParameterValue(int parameter)
          Returns the value of the specified string parameter (MQCFST) as a string.
 void initialize(int command)
          Initializes a PCFMessage for re-use with the specified command identifier and no parameters.
 void initialize(int type, int command, int msgSeqNumber, boolean last)
          Initializes a PCFMessage for re-use with the specified type, command identifier, sequence number, control indicator and no parameters.
 void initialize(com.ibm.mq.MQMessage message)
          Initializes the contents of a PCFHeader by reading from an MQMessage.
 int size()
          Returns the size in bytes of a PCFHeader
 java.lang.String toString()
           
 int write(com.ibm.mq.MQMessage message)
          Writes the contents of a PCFHeader to an MQMessage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

copyright

public static final java.lang.String copyright
Constructor Detail

PCFMessage

public PCFMessage(int command)
Initializes a PCFMessage as a PCF request with the specified MQCFH command identifier. The parameter count is incremented from zero as parameters are added.
Parameters:
command - the PCF command identifier

PCFMessage

public PCFMessage(int type,
                  int command,
                  int msgSeqNumber,
                  boolean last)
Initializes a PCFMessage with the specified MQCFH type, command identifier, sequence number and control indicator. The parameter count is incremented from zero as parameters are added.

Most applications will not need to use this constructor. PCF request messages, which always have type MQCFT_COMMAND, sequence number 1 and control indicator set to MQCFC_LAST, are more easily constructed using the PCFMessage(int command) form instead.

Parameters:
type - the PCF message type
command - the PCF command identifier
msgSeqNumber - the sequence number of the message
last - if set, indicates this message is the last in a sequence

PCFMessage

public PCFMessage(com.ibm.mq.MQMessage message)
           throws com.ibm.mq.MQException,
                  java.io.IOException
Initializes a PCFMessage from the contents of an MQMessage.
Parameters:
message - the message to read from
Throws:
com.ibm.mq.MQException - if the message contents do not yield a valid PCFMessage
java.io.IOException - if there is a problem reading the message
Method Detail

initialize

public void initialize(int command)
Initializes a PCFMessage for re-use with the specified command identifier and no parameters.
Parameters:
command - the PCF command identifier

initialize

public void initialize(int type,
                       int command,
                       int msgSeqNumber,
                       boolean last)
Initializes a PCFMessage for re-use with the specified type, command identifier, sequence number, control indicator and no parameters.

Most applications will not need to use this method. PCF request messages, which always have type MQCFT_COMMAND, sequence number 1 and control indicator set to MQCFC_LAST, can more easily be initialized using the initialize(int command) form instead.

Parameters:
type - the PCF message type
command - the PCF command identifier
msgSeqNumber - the sequence number of the message
last - if set, indicates this message is the last in a sequence

addParameter

public void addParameter(PCFParameter parameter)
Adds a PCFParameter to the PCFMessage.
Parameters:
the - parameter structure to add (MQCFIN, MQCFIL, MQCFST or MQCFSL)

addParameter

public void addParameter(int parameter,
                         int value)
Adds an integer parameter to the PCFMessage.
Parameters:
parameter - the integer parameter identifier
value - the integer value

addParameter

public void addParameter(int parameter,
                         int[] values)
Adds an integer list parameter to the PCFMessage.
Parameters:
parameter - the integer list parameter identifier
value - the array of integer values

addParameter

public void addParameter(int parameter,
                         java.lang.String value)
Adds a string parameter to the PCFMessage.
Parameters:
parameter - the string parameter identifier
value - the string value

addParameter

public void addParameter(int parameter,
                         java.lang.String[] values)
Adds a string list parameter to the PCFMessage.
Parameters:
parameter - the string list parameter identifier
value - the array of string values

getCommand

public int getCommand()
Returns the PCF command identifier
Returns:
the value of the command field from the MQCFH

getMsgSeqNumber

public int getMsgSeqNumber()
Returns the PCF message sequence number
Returns:
the value of the msgSeqNumber field from the MQCFH

getControl

public int getControl()
Returns the PCF header control indicator.
Returns:
the value of the control field from the MQCFH

getCompCode

public int getCompCode()
Returns the completion code in the MQCFH.
Returns:
the value of the compCode field from the MQCFH

getReason

public int getReason()
Returns the reason code in the MQCFH.
Returns:
the value of the reason field from the MQCFH

getParameterCount

public int getParameterCount()
Returns the number of parameter structures in the PCF message.
Returns:
the value of the parameterCount field from the MQCFH

getParameters

public java.util.Enumeration getParameters()
Returns an enumeration of the parameters in the PCFMessage. The elements of the Enumeration returned are individual PCFParameter instances (instances of MQCFIN, MQCFIL, MQCFST or MQCFSL).
Returns:
the PCF message parameter structures

getParameterValue

public java.lang.Object getParameterValue(int parameter)
Returns the value of the specified parameter, or null if the parameter is not found. The object returned is a single Integer, a single String, an array of integers or array of Strings depending on the type of PCFParameter. The caller can infer the expected return type from the supplied parameter identifier.
Returns:
the specified parameter value

getIntParameterValue

public int getIntParameterValue(int parameter)
                         throws PCFException
Returns the value of the specified integer parameter (MQCFIN) as an integer.
Parameters:
parameter - the integer parameter identifier
Returns:
the integer parameter value
Throws:
PCFException - if the specified parameter does not exist in the message (the reason code given is MQRCCF_CFIN_PARM_ID_ERROR)

getIntListParameterValue

public int[] getIntListParameterValue(int parameter)
                               throws PCFException
Returns the value of the specified integer list parameter (MQCFIL) as an array of integers.
Parameters:
parameter - the integer list parameter identifier
Returns:
the integer list parameter values
Throws:
PCFException - if the specified parameter does not exist in the message (the reason code given is MQRCCF_CFIL_PARM_ID_ERROR)

getStringParameterValue

public java.lang.String getStringParameterValue(int parameter)
                                         throws PCFException
Returns the value of the specified string parameter (MQCFST) as a string.
Parameters:
parameter - the string parameter identifier
Returns:
the string parameter value
Throws:
PCFException - if the specified parameter does not exist in the message (the reason code given is MQRCCF_CFST_PARM_ID_ERROR)

getStringListParameterValue

public java.lang.String[] getStringListParameterValue(int parameter)
                                               throws PCFException
Returns the value of the specified string list parameter (MQCFSL) as an array of strings.
Parameters:
parameter - the string list parameter identifier
Returns:
the string list parameter values
Throws:
PCFException - if the specified parameter does not exist in the message (the reason code given is MQRC_CFSL_ERROR; no more specific error code is defined)

initialize

public void initialize(com.ibm.mq.MQMessage message)
                throws com.ibm.mq.MQException,
                       java.io.IOException
Description copied from class: PCFHeader
Initializes the contents of a PCFHeader by reading from an MQMessage.
Overrides:
initialize in class PCFHeader
Following copied from class: com.ibm.mq.pcf.PCFHeader
Parameters:
message - the message to read from
Throws:
com.ibm.mq.MQException - if the message does contain appropriate data for the header
java.io.IOException - if there is a problem reading the message

write

public int write(com.ibm.mq.MQMessage message)
          throws java.io.IOException
Description copied from class: PCFHeader
Writes the contents of a PCFHeader to an MQMessage.
Overrides:
write in class PCFHeader
Following copied from class: com.ibm.mq.pcf.PCFHeader
Parameters:
message - the message to write to
Throws:
java.io.IOException - if there is a problem writing the message

size

public int size()
Description copied from class: PCFHeader
Returns the size in bytes of a PCFHeader
Overrides:
size in class PCFHeader

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object