SonicMQ API

progress.message.jclient
Interface Header


public interface Header

The Header stores name/value pairs associated with a MultipartMessage Part.

Two header fields, 'Content-Type' and 'Content-ID', have special status and are normally accessed via dedicated get/set methods. The user can create any additional custom name/value pairs they choose.


Field Summary
static java.lang.String CONTENT_ID
          Name of Content-ID header field.
static java.lang.String CONTENT_TYPE
          Name of Content-Type header field.
 
Method Summary
 java.lang.String getContentId()
          Gets the value of the Content-ID header field.
 java.lang.String getContentType()
          Gets the value of the Content-Type header field.
 java.lang.String getHeaderField(java.lang.String name)
          Gets the value of a header field, or null if it does not exist.
 java.lang.String getHeaderField(java.lang.String name, java.lang.String value)
          Gets the value of a header field, or returns the default value if it does not exist.
 java.util.Enumeration getHeaderFieldNames()
          Returns an enumeration of all the header field names.
 void removeAllHeaders()
          Removes all the header fields except 'Content-Type' and 'Content-ID' - these two are left untouched.
 void removeHeaderField(java.lang.String name)
          Removes the header from the part.
 void setContentId(java.lang.String cid)
          Sets the Content-ID header field.
 void setContentType(java.lang.String type)
          Sets the Content-Type header field.
 void setHeaderField(java.lang.String name, java.lang.String value)
          Sets a header field (name/value pair).
 

Field Detail

CONTENT_TYPE

static final java.lang.String CONTENT_TYPE
Name of Content-Type header field. May be used with getHeaderField() and setHeaderField() as an alternative to getContentType() and setContentType().

See Also:
Constant Field Values

CONTENT_ID

static final java.lang.String CONTENT_ID
Name of Content-ID header field. May be used with getHeaderField() and setHeaderField() as an alternative to getContentId() and setContentId().

See Also:
Constant Field Values
Method Detail

getContentId

java.lang.String getContentId()
Gets the value of the Content-ID header field. Returns null if the Content-ID is not set.

Returns:
The Content-ID of the header/part.

setContentId

void setContentId(java.lang.String cid)
                  throws JMSException
Sets the Content-ID header field. Content-ID is not a pre-defined property with a particular syntax. It is whatever the user sets via this method. It can be null for more than one parts. However if it is non-null then it must be unique within that MQ MultiPart message.

Parameters:
cid - The value of the Content-ID
Throws:
MessageNotWriteableException - If message is in read-only mode.
JMSException - If operation failed because the same Content-Id already exists for another part in the message associated with this header.

setContentType

void setContentType(java.lang.String type)
                    throws JMSException
Sets the Content-Type header field.

Parameters:
type - The value of the Content-Type
Throws:
JMSException - If operation failed due to some internal error.
MessageNotWriteableException - If message is in read-only mode.

getContentType

java.lang.String getContentType()
Gets the value of the Content-Type header field. Returns null if the Content-Type could not be determined.

Returns:
The Content-Type of the header/part.

getHeaderFieldNames

java.util.Enumeration getHeaderFieldNames()
Returns an enumeration of all the header field names. The result includes 'Content-Type' and 'Content-ID' (if set).

Returns:
The enumeration of header fields.

getHeaderField

java.lang.String getHeaderField(java.lang.String name)
Gets the value of a header field, or null if it does not exist. If called for 'Content-Type' or 'Content-ID' the result is the same as calling getContentType() or getContentId() respectively.

Parameters:
name - The name of the header field.
Returns:
The value of the header field, or null.
See Also:
CONTENT_TYPE, CONTENT_ID

getHeaderField

java.lang.String getHeaderField(java.lang.String name,
                                java.lang.String value)
Gets the value of a header field, or returns the default value if it does not exist.

Parameters:
name - The name of the header field.
value - Default value if the header does not exist.
Returns:
The value of the header field, or specified default.
See Also:
CONTENT_TYPE, CONTENT_ID

setHeaderField

void setHeaderField(java.lang.String name,
                    java.lang.String value)
                    throws JMSException
Sets a header field (name/value pair). Overwrites headers of the same name. If called for 'Content-Type' or 'Content-ID' the result is the same as calling setContentType() or setContentId() respectively. With the exception of 'Content-Type' and 'Content-ID', setting a header's value to null is equivalent to removing that header.

Parameters:
name - The name of the header field to set.
value - The value to set.
Throws:
JMSException - If operation failed due to some internal error.
MessageNotWriteableException - If message is in read-only mode.
See Also:
CONTENT_TYPE, CONTENT_ID

removeHeaderField

void removeHeaderField(java.lang.String name)
                       throws JMSException
Removes the header from the part. The 'Content-Type' and 'Content-ID' headers cannot be removed; calling removeHeaderField() for either of these fields sets the associated value to null - use of setContentType() and setContentId() is preferred.

Parameters:
name - Name of the header to remove.
Throws:
JMSException - If operation failed due to some internal error.
MessageNotWriteableException - If message is in read-only mode.
See Also:
CONTENT_TYPE, CONTENT_ID

removeAllHeaders

void removeAllHeaders()
                      throws JMSException
Removes all the header fields except 'Content-Type' and 'Content-ID' - these two are left untouched.

Throws:
JMSException - If operation failed due to some internal error.
MessageNotWriteableException - If message is in read-only mode.

SonicMQ API

Copyright © 1999-2010 Progress Software Corporation. All Rights Reserved.
HTML formatted on 15-September-2010.