Class MQRFH2

java.lang.Object
com.ibm.mq.jmqi.JmqiObject
com.ibm.mq.headers.internal.Header
com.ibm.mq.headers.MQRFH2
All Implemented Interfaces:
MQChainable, MQData, MQHeader

public class MQRFH2 extends com.ibm.mq.headers.internal.Header implements MQChainable
Header class representing the MQRFH2 structure. As well as providing access to the structure-defined header fields, this class provides methods to retrieve and set fields from XML format folders contained in the NameValueData variable-length field.
  • Constructor Details

    • MQRFH2

      public MQRFH2()
      Constructs an MQRFH2 instance with default field values.
    • MQRFH2

      public MQRFH2(DataInput message) throws MQDataException, IOException
      Constructs an MQRFH2 instance populated from an MQMessage.
      Parameters:
      message - the message to read
      Throws:
      MQDataException - if the message content does not yield a valid MQRFH2 stucture
      IOException - if there is a problem reading the message content
    • MQRFH2

      public MQRFH2(DataInput message, int encoding, int characterSet) throws MQDataException, IOException
      Constructs an MQRFH2 instance populated from a DataInput source.
      Parameters:
      message - the MQMessage or other DataInput source to read
      encoding - the initial numeric encoding of the data in the message
      characterSet - the initial CCSID of the data in the message
      Throws:
      MQDataException - if the message content does not yield a valid MQRFH2 stucture
      IOException - if there is a problem reading the message content
  • Method Details

    • read

      public int read(DataInput input, int encoding, int characterSet) throws IOException, MQDataException
      Initialise this Header from the specified data source
      Specified by:
      read in interface MQData
      Overrides:
      read in class com.ibm.mq.headers.internal.Header
      Parameters:
      input - the data source
      encoding - the encoding mechanism for integer data
      characterSet - the CCSID applied to data in the source
      Returns:
      the amount of data read
      Throws:
      IOException - if an error occurs reading message content.
      MQDataException - if there is a problem reading the message content
    • write

      public int write(DataOutput outputP, int encoding, int characterSet) throws IOException
      write this Header to the specified location
      Specified by:
      write in interface MQData
      Overrides:
      write in class com.ibm.mq.headers.internal.Header
      Parameters:
      outputP - the data location
      encoding - the encoding mechanism for integer data
      characterSet - the CCSID applied to data in the data location
      Returns:
      the amount of data written
      Throws:
      IOException - if an error occurs writing message content.
    • size

      public int size()
      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()
    • nextEncoding

      public int nextEncoding()
      Specified by:
      nextEncoding in interface MQChainable
      Returns:
      the numeric encoding of the next header or message content.
      See Also:
    • nextEncoding

      public void nextEncoding(int value)
      Description copied from interface: MQChainable
      Sets the numeric encoding of the next header or message content.
      Specified by:
      nextEncoding in interface MQChainable
      Parameters:
      value - numeric encoding
      See Also:
    • nextCharacterSet

      public int nextCharacterSet()
      Specified by:
      nextCharacterSet in interface MQChainable
      Returns:
      the CCSID of the next header or message content.
      See Also:
    • nextCharacterSet

      public void nextCharacterSet(int value)
      Description copied from interface: MQChainable
      Sets the CCSID of the next header or message content.
      Specified by:
      nextCharacterSet in interface MQChainable
      Parameters:
      value - character set
      See Also:
    • nextFormat

      public String nextFormat()
      Specified by:
      nextFormat in interface MQChainable
      Returns:
      the format of the next header or message content.
      See Also:
    • nextFormat

      public void nextFormat(String value)
      Description copied from interface: MQChainable
      Sets the format of the next header or message content.
      Specified by:
      nextFormat in interface MQChainable
      Parameters:
      value - format of the header or message content
      See Also:
    • format

      public String format()
      Specified by:
      format in interface MQChainable
      Returns:
      the format associated with this header object or message content.
      See Also:
    • getStrucId

      public String getStrucId()
      Get the structure identifier; the value will be MQRFH_STRUC_ID
      Returns:
      the structure identifier
    • getVersion

      public int getVersion()
      Get the Structure version number
      Returns:
      the Structure version number
    • getStrucLength

      public int getStrucLength()
      Get the length of the structure.
      Returns:
      the structure length.
    • getEncoding

      public int getEncoding()
      Get the numeric encoding of the data that follows.
      Returns:
      the numeric encoding. A combination of MQENC_* values.
    • setEncoding

      public void setEncoding(int value)
      Set the numeric encoding of the data that follows.
      Parameters:
      value - the numeric encoding. A combination of MQENC_* values.
    • getCodedCharSetId

      public int getCodedCharSetId()
      Get the Character set identifier of data that follows.
      Returns:
      the Character set identifier.
    • setCodedCharSetId

      public void setCodedCharSetId(int value)
      Set the Character set identifier of data that follows. MQCCSI_Q_MGR is not allowable, so we map that to MQCCSI_INHERIT (I think this is the simplest fix)
      Parameters:
      value - the Character set identifier.
    • getFormat

      public String getFormat()
      Get the format name of data that follows NameValueString
      Returns:
      the format name
    • setFormat

      public void setFormat(String value)
      Set the format name of data that follows NameValueString
      Parameters:
      value - the format name
    • getFlags

      public int getFlags()
      get the flags from the header
      Returns:
      the flags
    • setFlags

      public void setFlags(int value)
      set the flags on the header
      Parameters:
      value - the flags
    • getNameValueCCSID

      public int getNameValueCCSID()
      get the coded character set for the NameValue data
      Returns:
      the NameValue data
    • setNameValueCCSID

      public void setNameValueCCSID(int value)
      set the coded character set for the NameValue data
      Parameters:
      value - the coded character set for the NameValue data
    • getNameValueLength

      public int getNameValueLength()
      Returns:
      the NameValueLength field value.

      Note: There is no setNameValueLength method. Setting the NameValueData field causes the NameValueLength and StrucLength field values to be updated accordingly.

    • getNameValueData

      public byte[] getNameValueData()
      get the NameValue data
      Returns:
      the NameValue data
    • setNameValueData

      public void setNameValueData(byte[] value)
      Sets the NameValueData field. This causes the NameValueLength and StrucLength field values to be updated accordingly, but the NameValueCCSID field is not modified.
      Parameters:
      value -
    • setNameValueData

      public void setNameValueData(String value) throws IOException
      Sets the NameValueData field. This causes the NameValueLength and StrucLength field values to be updated accordingly. The string data is converted to the CCSID indicated in the NameValueCCSID field.
      Parameters:
      value -
      Throws:
      IOException
    • getFolderStrings

      public String[] getFolderStrings() throws IOException
      Returns:
      the contents of the variable part of the structure as an array of Strings. This is equivalent to an array of NameValueData strings.
      Throws:
      IOException
    • setFolderStrings

      public void setFolderStrings(String[] folders) throws IOException
      Replaces content of the variable part of the MQRFH2 structure with the specified array of strings. The strucLength field is updated accordingly.
      Parameters:
      folders -
      Throws:
      IOException
    • getFolderContent

      public String getFolderContent(String name) throws IOException
      Deprecated.
      Parameters:
      name -
      Returns:
      a string from the MQRFH2 contents corresponding to the named folder, or null if no such folder is present. The content of the folder string (less the enclosing folder tags) is returned if there is a match.
      Throws:
      IOException
    • setFolderContent

      public void setFolderContent(String name, String content) throws IOException
      Deprecated.
      Sets the content of the named folder. If the folder exists, its content is replaced unless the content argument is null, in which case the folder is removed. If the folder does not exist, it is added unless the content argument is null.
      Parameters:
      name -
      content -
      Throws:
      IOException
    • getFieldValue

      public Object getFieldValue(String folder, String tag) throws IOException
      Parameters:
      folder -
      tag -
      Returns:
      the contents of the first field with the specified name from within a folder string, or null if no such field is present. The content of the field (less the enclosing field tags) is returned if there is a match.
      Throws:
      IOException
    • getFieldValue

      public Object getFieldValue(String folder, String field, int occurrenceP) throws IOException
      Parameters:
      folder -
      field -
      occurrenceP -
      Returns:
      the contents of the nth field with the specified name from within a folder string, or null if no such field is present. The content of the field (less the enclosing field tags) is returned if there is a match. An occurrence of zero gets the first occurrence of the the named field; occurrence of 1 get the next occurrence, and so forth.
      Throws:
      IOException
    • getFieldValues

      public List getFieldValues(String folder, String field) throws IOException
      Parameters:
      folder -
      field -
      Returns:
      a list containing all occurrences of field values matching the specified field name in the folder. The list is empty if there are no matching fields or the folder is not found.
      Throws:
      IOException
    • setFieldValue

      public void setFieldValue(String folder, String field, Object value) throws IOException
      set value of a field
      Parameters:
      folder - - the name of the folder containing the field
      field - - the field name
      value - - the field value
      Throws:
      IOException
    • setFieldValues

      public void setFieldValues(String folder, String field, List values) throws IOException
      set the values of a multi-valued field
      Parameters:
      folder - - the name of the folder containing the field
      field - - the field name
      values - - the field values
      Throws:
      IOException
    • getBooleanFieldValue

      public boolean getBooleanFieldValue(String folder, String field) throws IOException
      Get the boolean value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the boolean value
      Throws:
      IOException
    • getIntFieldValue

      public int getIntFieldValue(String folder, String field) throws IOException
      Get the integer value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the integer value
      Throws:
      IOException
    • setIntFieldValue

      public void setIntFieldValue(String folder, String field, int value) throws IOException
      Set the integer value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      value - the value to set
      Throws:
      IOException
    • getByteFieldValue

      public byte getByteFieldValue(String folder, String field) throws IOException
      Get the byte value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the byte value
      Throws:
      IOException
    • setByteFieldValue

      public void setByteFieldValue(String folder, String field, byte value) throws IOException
      Set the byte value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      value - the value to set
      Throws:
      IOException
    • getShortFieldValue

      public short getShortFieldValue(String folder, String field) throws IOException
      Get the short value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the short value
      Throws:
      IOException
    • setShortFieldValue

      public void setShortFieldValue(String folder, String field, short value) throws IOException
      Set the short value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      value - the value to set
      Throws:
      IOException
    • getCharFieldValue

      public char getCharFieldValue(String folder, String field) throws IOException
      Get the byte value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the byte value
      Throws:
      IOException
    • setCharFieldValue

      public void setCharFieldValue(String folder, String field, char value) throws IOException
      Set the short value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      value - the value to set
      Throws:
      IOException
    • getLongFieldValue

      public long getLongFieldValue(String folder, String field) throws IOException
      Get the long value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the long value
      Throws:
      IOException
    • setLongFieldValue

      public void setLongFieldValue(String folder, String field, long value) throws IOException
      Set the long value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      value - the value to set
      Throws:
      IOException
    • getFloatFieldValue

      public float getFloatFieldValue(String folder, String field) throws IOException
      Get the floating point value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the floating point value
      Throws:
      IOException
    • setFloatFieldValue

      public void setFloatFieldValue(String folder, String field, float value) throws IOException
      Set the floating point value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      value - the value to set
      Throws:
      IOException
    • getDoubleFieldValue

      public double getDoubleFieldValue(String folder, String field) throws IOException
      Get the double precision floating point value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the double precision floating point value
      Throws:
      IOException
    • setDoubleFieldValue

      public void setDoubleFieldValue(String folder, String field, double value) throws IOException
      Set the double precision floating point value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      value - the value to set
      Throws:
      IOException
    • getBytesFieldValue

      public byte[] getBytesFieldValue(String folder, String field) throws IOException
      Get the byte array value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the byte array
      Throws:
      IOException
    • getStringFieldValue

      public String getStringFieldValue(String folder, String field) throws IOException
      Get the String value of the specified field
      Parameters:
      folder - the folder name in the Header
      field - the field name in the Header
      Returns:
      the String value
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class com.ibm.mq.headers.internal.Header
      See Also: