SonicMQ API

progress.message.jclient
Interface Part

All Known Subinterfaces:
MessagePart

public interface Part

The Part is a part of a MultipartMessage. Each part has an associated Header and Content.

The Header contains header fields, such as Content-Type and Content-Id.

The content of the part is accessed through a javax.activation.DataHandler. The "content" of a part is available in various formats:

  • As a DataHandler - using the getDataHandler() method. The "content" of a Part is also available through a javax.activation.DataHandler object. The DataHandler object allows clients to discover the operations available on the content, and to instantiate the appropriate component to perform those operations.
  • As an input stream - using the getInputStream() method.
  • As a Java object - using the getContent() method. This method returns the "content" as a Java object. The returned object is of course dependent on the content itself.


    Method Summary
     java.lang.Object getContent()
              Gets the content of the part as an Object.
     byte[] getContentBytes()
              Gets the content of the part as a byte array.
     javax.activation.DataHandler getDataHandler()
              This method provides the mechanism to get this part's content.
     Header getHeader()
              Gets the Header for the Part.
     java.io.InputStream getInputStream()
              Return an input stream for this part's "content".
     java.io.OutputStream getOutputStream()
              Return an output stream for writing this part's "content".
     boolean isMessagePart()
               
     void setContent(byte[] content)
              A convenience method for setting this part's content.
     void setContent(java.lang.Object object, java.lang.String type)
              A convenience method for setting this part's content.
     void setDataHandler(javax.activation.DataHandler dataHandler)
              This method provides the mechanism to set this part's content.
     

    Method Detail

    getHeader

    Header getHeader()
    Gets the Header for the Part. The Header provides access to the header fields as name/value pairs.

    Throws:
    JMSException - If operation failed due to some internal error.

    getDataHandler

    javax.activation.DataHandler getDataHandler()
                                                throws JMSException
    This method provides the mechanism to get this part's content. The DataHandler wraps around the actual content.

    Returns:
    DataHandler for the Part.
    Throws:
    JMSException - If operation failed due to some internal error.

    setDataHandler

    void setDataHandler(javax.activation.DataHandler dataHandler)
                        throws JMSException
    This method provides the mechanism to set this part's content. The DataHandler wraps around the actual content.

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

    getInputStream

    java.io.InputStream getInputStream()
                                       throws JMSException
    Return an input stream for this part's "content". Any encodings will be decoded before the input stream is provided.

    This is a convenience method that just invokes the DataHandler's getInputStream() method.

    Returns:
    An InputStream.
    Throws:
    java.io.IOException - this is typically thrown by the DataHandler. Refer to the documentation for javax.activation.DataHandler for more details.
    JMSException - If operation failed due to some internal error.

    getOutputStream

    java.io.OutputStream getOutputStream()
                                         throws JMSException
    Return an output stream for writing this part's "content".

    This is typically a convenience method that just invokes the DataHandler's getOuputStream() method. &return An InputStream.

    This is a convenience method that just invokes the DataHandler's getInputStream() method.

    Returns:
    An OutputStream.
    Throws:
    java.io.IOException - this is typically thrown by the DataHandler. Refer to the documentation for javax.activation.DataHandler for more details.
    JMSException - If operation failed due to some internal error.

    getContent

    java.lang.Object getContent()
    Gets the content of the part as an Object.

    Returns:
    The Object. Note that when a part is creted as a DataHandler of a FileDataSource, before sending the part to the broker, if this method is called upon the part, the file will be locked.

    getContentBytes

    byte[] getContentBytes()
    Gets the content of the part as a byte array.

    Returns:
    The Object. Note that when a part is creted as a DataHandler of a FileDataSource, before sending the part to the broker, if this method is called upon the part, the file will be locked.

    setContent

    void setContent(java.lang.Object object,
                    java.lang.String type)
                    throws JMSException
    A convenience method for setting this part's content. The part internally wraps the content in a DataHandler.

    Note that a DataContentHandler class for the specified type should be available for this to work right. i.e., to do setContent(mycontents, "application/x-mytype"), a DataContentHandler for "application/x-mytype" should be installed.

    Refer to the Java Activation Framework for more information.

    Parameters:
    object - A Java Object.
    type - The Content-Type of this object
    Throws:
    JMSException - If operation failed due to some internal error.
    MessageNotWriteableException - If message is in read-only mode.

    setContent

    void setContent(byte[] content)
                    throws JMSException
    A convenience method for setting this part's content. The part internally wraps the content in a DataHandler.

    Parameters:
    content - The byte array of content to be set.
    Throws:
    JMSException - If operation failed due to some internal error.
    MessageNotWriteableException - If message is in read-only mode.

    isMessagePart

    boolean isMessagePart()
    Returns:
    true, if this part is a JMS message, else return false

    SonicMQ API

    Copyright © 1999-2012 Progress Software Corporation. All Rights Reserved.
    HTML formatted on 13-March-2012.