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

  1. public interface MQHeader
  2. 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 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

Modifier and Type Interface and Description
  1. static interface
MQHeader.Field
Interface representing an individual header field.

Method Summary

Modifier and Type Method and Description
  1. java.util.List
fields()
Returns a list of the fields in this header.
  1. java.lang.Object
getValue(java.lang.String name)
Returns the value of the named field.
  1. void
setValue(java.lang.String name,java.lang.Object value)
Sets the value of the named field.
  1. java.lang.String
type()
Returns the type name of this header.
Methods inherited from interface com.ibm.mq.headers.MQData
read, read, size, write, write

Method Detail

getValue

  1. java.lang.Object getValue(java.lang.String 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.
Parameters:
name - the field name.

setValue

  1. void setValue(java.lang.String name,
  2. 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.

type

  1. 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

  1. 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: