Class PCFMessage

java.lang.Object
com.ibm.mq.jmqi.JmqiObject
com.ibm.mq.headers.internal.Header
com.ibm.mq.headers.pcf.PCFHeader
com.ibm.mq.headers.pcf.PCFMessage
All Implemented Interfaces:
MQData, MQHeader, PCFContent

public class PCFMessage extends PCFHeader implements PCFContent
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 and so on). A PCFMessage instance can be constructed and manipulated without direct reference to the PCF header and parameter structures themselves.
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.ibm.mq.headers.MQHeader

    MQHeader.Field
  • Field Summary

    Fields inherited from class com.ibm.mq.headers.internal.Header

    DEFAULT_CCSID, DEFAULT_ENCODING, delegate

    Fields inherited from class com.ibm.mq.jmqi.JmqiObject

    COMP_JM, COMP_JN, COMP_JO
  • Constructor Summary

    Constructors
    Constructor
    Description
    PCFMessage(int command)
    Deprecated.
    PCFMessage(int type, int command, int msgSeqNumber, boolean last)
    Initializes a PCFMessage with the specified MQCFH type, command identifier, sequence number and control indicator.
    Initializes a PCFMessage from the contents of an MQMessage.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFilterParameter(int parameter, int operator, byte[] value)
    Adds a bytes string filter parameter to the group.
    void
    addFilterParameter(int parameter, int operator, int value)
    Adds an integer filter parameter to the group.
    void
    addFilterParameter(int parameter, int operator, String value)
    Adds a string filter parameter to the group.
    void
    addParameter(int parameter, byte[] value)
    Adds a byte array parameter to the group.
    void
    addParameter(int parameter, int value)
    Adds an integer parameter to the group.
    void
    addParameter(int parameter, int[] values)
    Adds an integer list parameter to the group.
    void
    addParameter(int parameter, long value)
    Adds a 64-bit integer parameter to the group.
    void
    addParameter(int parameter, long[] values)
    Adds a 64-bit integer list parameter to the group.
    void
    addParameter(int parameter, String value)
    Adds a string parameter to the group.
    void
    addParameter(int parameter, String[] values)
    Adds a string list parameter to the group.
    void
    Adds a PCFParameter to the PCFMessage.
    boolean
    Returns true when invoked with another PCFMessage instance with matching header and equivalent parameters in the same order.
    byte[]
    getBytesParameterValue(int parameter)
    Returns the value of the specified byte array parameter (MQCFBS).
    int
    Returns the PCF command identifier
    int
    Returns the completion code in the MQCFH.
    int
    Returns the PCF header control indicator.
    long
    getInt64ParameterValue(int parameter)
    Returns the value of the specified integer parameter (MQCFIN64) as an integer.
    long[]
    Returns the value of the specified integer list parameter (MQCFIL64) as an array of integers.
    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
    Returns the PCF message sequence number
    getParameter(int parameter)
    Returns the PCFParameter structure for the specified parameter, or null if the parameter is not found.
    int
    Returns the number of parameter structures in the PCF message.
    Returns an enumeration of the parameters in the group.
    getParameterValue(int parameter)
    Returns the value of the specified parameter, or null if the parameter is not found.
    int
    Returns the reason code in the MQCFH.
    Returns the value of the specified string list parameter (MQCFSL) as an array of strings.
    getStringParameterValue(int parameter)
    Returns the value of the specified string parameter (MQCFST) as a string.
    int
    Returns the PCF type identifier
    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
    setHeader(MQCFH header)
    Set the PCFHeader Can only be an MQCFH, so it's not clear why the previous method existed.
    void
    Deprecated.
    int
    Returns the size of this PCFMessage in bytes.
    Returns the string representation of the class instance
    int
    write(DataOutput message)
    Writes the content of this PCFMessage to, e.g., an MQMessage.
    int
    write(DataOutput message, int encoding, int characterSet)
    Writes the content of this PCFMessage to, e.g., an MQMessage, in the specified Encoding and CCSID

    Methods inherited from class com.ibm.mq.headers.internal.Header

    characterSet, encoding, fields, getBytesValue, getCharValue, getCharValue, getIntValue, getJmqiEnv, getStringValue, getValue, headerType, read, read, read, setBytesValue, setCharValue, setCharValue, setIntValue, setStringValue, setValue, store, store, type, validate

    Methods inherited from class com.ibm.mq.jmqi.JmqiObject

    getJmqiEnvironment

    Methods inherited from class java.lang.Object

    getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PCFMessage

      public PCFMessage(int command)
      Deprecated.
      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(DataInput message) throws MQDataException, IOException
      Initializes a PCFMessage from the contents of an MQMessage.
      Parameters:
      message - the message to read from
      Throws:
      MQDataException - if the message contents do not yield a valid PCFMessage
      IOException - if there is a problem reading the message
  • Method Details

    • 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. The MQCFH version is updated automatically if necessary to correspond with the parameter type. (For example, the version must be set to MQCFH_VERSION_3 if a PCF filter parameter is added.)
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the parameter structure to add (MQCFIN, MQCFIL, MQCFST and so on)
      See Also:
    • addParameter

      public void addParameter(int parameter, int value)
      Description copied from interface: PCFContent
      Adds an integer parameter to the group.
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the integer parameter identifier
      value - the integer value
      See Also:
    • addParameter

      public void addParameter(int parameter, int[] values)
      Description copied from interface: PCFContent
      Adds an integer list parameter to the group.
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the integer list parameter identifier
      values - the array of integer values
      See Also:
    • addParameter

      public void addParameter(int parameter, long value)
      Description copied from interface: PCFContent
      Adds a 64-bit integer parameter to the group.
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the integer parameter identifier
      value - the integer value
      See Also:
    • addParameter

      public void addParameter(int parameter, long[] values)
      Description copied from interface: PCFContent
      Adds a 64-bit integer list parameter to the group.
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the integer list parameter identifier
      values - the array of integer values
      See Also:
    • addParameter

      public void addParameter(int parameter, String value)
      Description copied from interface: PCFContent
      Adds a string parameter to the group.
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the string parameter identifier
      value - the string value
      See Also:
    • addParameter

      public void addParameter(int parameter, String[] values)
      Description copied from interface: PCFContent
      Adds a string list parameter to the group.
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the string list parameter identifier
      values - the array of string values
      See Also:
    • addParameter

      public void addParameter(int parameter, byte[] value)
      Description copied from interface: PCFContent
      Adds a byte array parameter to the group.
      Specified by:
      addParameter in interface PCFContent
      Parameters:
      parameter - the string list parameter identifier
      value - the array of string values
      See Also:
    • addFilterParameter

      public void addFilterParameter(int parameter, int operator, int value)
      Description copied from interface: PCFContent
      Adds an integer filter parameter to the group.
      Specified by:
      addFilterParameter in interface PCFContent
      Parameters:
      parameter - the filter parameter identifier
      operator - one of the MQCFOP_* filter operator constants
      value - the filter value
      See Also:
    • addFilterParameter

      public void addFilterParameter(int parameter, int operator, String value)
      Description copied from interface: PCFContent
      Adds a string filter parameter to the group.
      Specified by:
      addFilterParameter in interface PCFContent
      Parameters:
      parameter - the filter parameter identifier
      operator - one of the MQCFOP_* filter operator constants
      value - the filter value
      See Also:
    • addFilterParameter

      public void addFilterParameter(int parameter, int operator, byte[] value)
      Description copied from interface: PCFContent
      Adds a bytes string filter parameter to the group.
      Specified by:
      addFilterParameter in interface PCFContent
      Parameters:
      parameter - the filter parameter identifier
      operator - one of the MQCFOP_* filter operator constants
      value - the filter value
      See Also:
    • getType

      public int getType()
      Returns the PCF type identifier
      Specified by:
      getType in class PCFHeader
      Returns:
      the value of the type field from the MQCFH
    • 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.
      Specified by:
      getParameterCount in interface PCFContent
      Returns:
      the value of the parameterCount field from the MQCFH
      See Also:
    • getParameters

      public Enumeration getParameters()
      Description copied from interface: PCFContent
      Returns an enumeration of the parameters in the group. The elements of the Enumeration returned are individual PCFParameter instances (instances of MQCFIN, MQCFIL, MQCFST or MQCFSL etc.).
      Specified by:
      getParameters in interface PCFContent
      Returns:
      the PCF message parameter structures
      See Also:
    • setHeader

      public void setHeader(PCFHeader header)
      Deprecated.
      Set the PCFHeader
      Parameters:
      header - The value to set
    • setHeader

      public void setHeader(MQCFH header)
      Set the PCFHeader Can only be an MQCFH, so it's not clear why the previous method existed. This is preferred.
      Parameters:
      header - The value to set
    • getParameter

      public PCFParameter getParameter(int parameter)
      Description copied from interface: PCFContent
      Returns the PCFParameter structure for the specified parameter, or null if the parameter is not found.
      Specified by:
      getParameter in interface PCFContent
      Parameters:
      parameter - identifier whose details to be returned.
      Returns:
      the specified parameter object
      See Also:
    • getParameterValue

      public Object getParameterValue(int parameter)
      Description copied from interface: PCFContent
      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.
      Specified by:
      getParameterValue in interface PCFContent
      Parameters:
      parameter - identifier whose details to be returned
      Returns:
      the specified parameter value
      See Also:
    • getIntParameterValue

      public int getIntParameterValue(int parameter) throws PCFException
      Description copied from interface: PCFContent
      Returns the value of the specified integer parameter (MQCFIN) as an integer.
      Specified by:
      getIntParameterValue in interface PCFContent
      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)
      See Also:
    • getIntListParameterValue

      public int[] getIntListParameterValue(int parameter) throws PCFException
      Description copied from interface: PCFContent
      Returns the value of the specified integer list parameter (MQCFIL) as an array of integers.
      Specified by:
      getIntListParameterValue in interface PCFContent
      Parameters:
      parameter - the integer list parameter identifier
      Returns:
      the integer list parameter values
      Throws:
      PCFException - if the specified parameter does not exist in the group (the reason code given is MQRCCF_CFIL_PARM_ID_ERROR)
      See Also:
    • getInt64ParameterValue

      public long getInt64ParameterValue(int parameter) throws PCFException
      Description copied from interface: PCFContent
      Returns the value of the specified integer parameter (MQCFIN64) as an integer.
      Specified by:
      getInt64ParameterValue in interface PCFContent
      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)
      See Also:
    • getIntList64ParameterValue

      public long[] getIntList64ParameterValue(int parameter) throws PCFException
      Description copied from interface: PCFContent
      Returns the value of the specified integer list parameter (MQCFIL64) as an array of integers.
      Specified by:
      getIntList64ParameterValue in interface PCFContent
      Parameters:
      parameter - the integer list parameter identifier
      Returns:
      the integer list parameter values
      Throws:
      PCFException - if the specified parameter does not exist in the group (the reason code given is MQRCCF_CFIL_PARM_ID_ERROR)
      See Also:
    • getStringParameterValue

      public String getStringParameterValue(int parameter) throws PCFException
      Description copied from interface: PCFContent
      Returns the value of the specified string parameter (MQCFST) as a string.
      Specified by:
      getStringParameterValue in interface PCFContent
      Parameters:
      parameter - the string parameter identifier
      Returns:
      the string parameter value
      Throws:
      PCFException - if the specified parameter does not exist in the group (the reason code given is MQRCCF_CFST_PARM_ID_ERROR)
      See Also:
    • getStringListParameterValue

      public String[] getStringListParameterValue(int parameter) throws PCFException
      Description copied from interface: PCFContent
      Returns the value of the specified string list parameter (MQCFSL) as an array of strings.
      Specified by:
      getStringListParameterValue in interface PCFContent
      Parameters:
      parameter - the string list parameter identifier
      Returns:
      the string list parameter values
      Throws:
      PCFException - if the specified parameter does not exist in the group (the reason code given is MQRCCF_CFSL_PARM_ID_ERROR; no more specific error code is defined)
      See Also:
    • getBytesParameterValue

      public byte[] getBytesParameterValue(int parameter) throws PCFException
      Description copied from interface: PCFContent
      Returns the value of the specified byte array parameter (MQCFBS).
      Specified by:
      getBytesParameterValue in interface PCFContent
      Parameters:
      parameter - the byte array parameter identifier
      Returns:
      the byte array parameter value
      Throws:
      PCFException - if the specified parameter does not exist in the group (the reason code given is MQRCCF_CFBS_PARM_ID_ERROR)
      See Also:
    • write

      public int write(DataOutput message) throws IOException
      Writes the content of this PCFMessage to, e.g., an MQMessage.
      Specified by:
      write in interface MQData
      Overrides:
      write in class com.ibm.mq.headers.internal.Header
      Parameters:
      message - the message.
      Returns:
      the number of bytes written
      Throws:
      IOException - if an error occurs writing message content.
      See Also:
      • Header.write(DataOutput)
    • write

      public int write(DataOutput message, int encoding, int characterSet) throws IOException
      Writes the content of this PCFMessage to, e.g., an MQMessage, in the specified Encoding and CCSID
      Specified by:
      write in interface MQData
      Overrides:
      write in class com.ibm.mq.headers.internal.Header
      Parameters:
      message - the DataOutput object to write the bytes to
      encoding - the numerical encoding scheme to use
      characterSet - the CodedCharacterSetIdentifier to encode character data in
      Returns:
      the number of bytes written into the DataOutput object
      Throws:
      IOException - if an error occurs writing message content.
      See Also:
      • Header.write(DataOutput)
    • size

      public int size()
      Returns the size of this PCFMessage in bytes.
      Specified by:
      size in interface MQData
      Overrides:
      size in class com.ibm.mq.headers.internal.Header
      Returns:
      the size in bytes occupied by this data element in a message.
      See Also:
      • Header.size()
    • equals

      public boolean equals(Object obj)
      Returns true when invoked with another PCFMessage instance with matching header and equivalent parameters in the same order.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare against
      Returns:
      true of the object equals this one
    • toString

      public String toString()
      Returns the string representation of the class instance
      Overrides:
      toString in class com.ibm.mq.headers.internal.Header
      Returns:
      The string representation