com.ibm.mq.headers

Interface MQHeader

  • All Superinterfaces:
    MQData
    All Known Implementing Classes:
    com.ibm.mq.headers.internal.Header, MQCFBF, MQCFBF, MQCFBS, MQCFBS, MQCFGR, MQCFGR, MQCFH, MQCFH, MQCFIF, MQCFIF, MQCFIL, MQCFIL, MQCFIL64, MQCFIL64, MQCFIN, MQCFIN, MQCFIN64, MQCFIN64, MQCFSF, MQCFSF, MQCFSL, MQCFSL, MQCFST, MQCFST, MQCIH, MQDH, MQDLH, MQEPH, MQIIH, MQMD, MQMD1, MQMDE, MQRFH, MQRFH2, MQRMH, MQSAPH, MQTM, MQTM2, MQTMC2, MQWIH, MQXQH, PCFFilterParameter, PCFFilterParameter, PCFHeader, PCFHeader, PCFMessage, PCFMessage, PCFParameter, PCFParameter


    public interface MQHeader
    extends MQData
    Interface representing an MQ header. A header object can be read from or written to a message and contains named fields. The methods defined on this interface provide generic access to field content, and are intended for use by applications such as tooling that perform dynamic introspection of arbitrary headers. These methods provide facilities to
    • discover the fields in a given header instance using the fields method
    • get or set the value of a field using the getValue and setValue methods
    Individual header classes implementing particular header types provide specific getter/setter methods named and typed for each of their fields, and these are more efficient than the generic methods. For example, an application handling messages on a dead-letter queue will process MQDLH (dead-letter) headers. Given an instance of MQDLH, the following two field accesses give the same result:
       MQDLH dlh = ...
       int reasonCode;
       
       reasonCode = ((Integer) dlh.getValue ("ReasonCode")).intValue ();  // Generic field access.
       reasonCode = dlh.getReasonCode ();   // Type-specific field access.
     
    The type-specific field access method is much more efficient than the generic field access method. The same applies to set operations.

    If the application is one that is introspecting or composing messages dynamically, such as a message browser, then the generic approach is more flexible, and avoids having to detect the header type and then cast to a specific class. This suits tasks such as displaying all the headers in a message, or building new messages under user control.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface and Description
      static interface  MQHeader.Field
      Interface representing an individual header field.
    • Method Detail

      • getValue

        java.lang.Object getValue(java.lang.String name)
        Parameters:
        name - the field name.
        Returns:
        the value of the named field. The value will be a String, String [], Integer, int [], byte [] or MQHeader according to the field type. Individual header implementation classes provide convenience methods for field access, so this method is only used for dynamic access by applications manipulating arbitrary headers.
      • setValue

        void setValue(java.lang.String name,
                      java.lang.Object value)
        Sets the value of the named field. The value will be a String, String [], Integer, int [], byte [] or MQHeader according to the field type. Individual header implementation classes provide convenience methods for field access, so this method is only used for dynamic access by applications manipulating arbitrary headers.
        Parameters:
        name - the field name.
        value -
      • type

        java.lang.String type()
        Returns:
        the type name of this header. The type name will be equivalent to the C typedef for the structure, if applicable -- for example, MQDLH, MQRFH2, MQXQH and so on.
      • fields

        java.util.List<?> fields()
        Returns:
        a list of the fields in this header. The contents of the list are instances of MQHeader.Field. This method is only used for dynamic introspection by applications manipulating arbitrary headers.
        See Also:
        MQHeader.Field
(c) Copyright IBM Corp. 2008, 2016. All Rights Reserved.