ch.epfl.lsr.apex
Class APEXDataMessage

java.lang.Object
  extended bych.epfl.lsr.apex.APEXMessage
      extended bych.epfl.lsr.apex.APEXDataMessage
All Implemented Interfaces:
Cloneable

public class APEXDataMessage
extends APEXMessage

An APEXDataMessage is the message sent for data containing operations and defines its syntax as it is specified in the Application Exchange (APEX) Protocol RFC3340 DTD.

A data opeartion may either contain XML or MIME Multipart structured content:

Author:
Marc Stoecklin
See Also:
getContentType()

Field Summary
static String ACTIVE
          internal option identifier status
static String FINAL
          internal option identifier status
static String NOTPROCESSING
          internal option identifier status
static String PASSIV
          internal option identifier status
 
Fields inherited from class ch.epfl.lsr.apex.APEXMessage
APPBEEPXML, ATTACH, BEEPXML, BIND, CONTENTTRANSFERENCODING, CONTENTTYPE, DATA, ENC_7BIT, ENC_8BIT, ENC_BASE64, ENC_BINARY, ENC_QUOTEDPRINTABLE, ENC_UUENCODE, ERROR, FILENAME, message, MIMECONTENT, MIMECONTENT_HASHKEY, OK, RELATED, START, START_HASHKEY, status, STRINGCONTENT, STRINGCONTENT_HASHKEY, TERMINATE, TYPE, XMLCONTENT, XMLCONTENT_HASHKEY
 
Constructor Summary
APEXDataMessage()
           Instantiates an empty APEXDataMessage.
APEXDataMessage(APEXEndpointAddress originator, APEXEndpointAddress[] recipients, byte[] byteContent, String contentType, String transferEncoding)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.
APEXDataMessage(APEXEndpointAddress originator, APEXEndpointAddress[] recipients, MimeBodyPart mpart)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content.
APEXDataMessage(APEXEndpointAddress originator, APEXEndpointAddress[] recipients, String xmlContent)
           Instantiates a new APEXDataMessage containing XML content.
APEXDataMessage(APEXEndpointAddress originator, APEXEndpointAddress recipient, byte[] byteContent, String contentType, String transferEncoding)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.
APEXDataMessage(APEXEndpointAddress originator, APEXEndpointAddress recipient, MimeBodyPart mpart)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content.
APEXDataMessage(APEXEndpointAddress originator, APEXEndpointAddress recipient, MimeMessage mimeContent)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content.
APEXDataMessage(APEXEndpointAddress originator, APEXEndpointAddress recipient, String xmlContent)
           Instantiates a new APEXDataMessage containing XML content.
APEXDataMessage(APEXEndpointAddress originator, HashSet recipients, byte[] byteContent, String contentType, String transferEncoding)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.
APEXDataMessage(APEXEndpointAddress originator, HashSet recipients, byte[] byteContent, String contentType, String transferEncoding, HashSet options)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.
APEXDataMessage(APEXEndpointAddress originator, HashSet recipients, MimeBodyPart mpart)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content.
APEXDataMessage(APEXEndpointAddress originator, HashSet recipients, MimeMessage mimeContent)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content.
APEXDataMessage(APEXEndpointAddress originator, HashSet recipients, MimeMessage mimeContent, HashSet options)
           Instantiates a new APEXDataMessage containing MIME Multipart structured content.
APEXDataMessage(APEXEndpointAddress originator, HashSet recipients, String xmlContent)
           Instantiates a new APEXDataMessage containing XML content.
APEXDataMessage(APEXEndpointAddress originator, HashSet recipients, String xmlContent, HashSet options)
           Instantiates a new APEXDataMessage containing XML content.
 
Method Summary
 void activateFinalAndNonProcessedOptions()
          Reactivates final and not processing options before sending a message (only active options are sent to the next hop).
 void addContent(Object key, Object value)
          Adds content with an associated key to the content table.
 void addOption(APEXOption option)
          Adds an option to this message
 void addRecipient(APEXEndpointAddress recipient)
          Sets the recipient of the message.
 Object clone()
           
 APEXOption[] getAllOptions()
          Returns an array containing all options of this message.
 APEXDataMessage getAPEXDataMessage(APEXEndpointAddress recipient)
          Returns a new APEXDataMessage addressed to the specified recipient endpoint address.
 APEXDataMessage getAPEXDataMessage(HashSet recipients)
          Returns a new APEXDataMessage addressed to the specified set of recipient endpoint addresses.
 Hashtable getContent()
          Returns the content table of this message.
 Object getContent(Object key)
          Returns the content in the content table associated to the key.
 String getContentID()
          Returns the content URI for the starting MIME part
 int getContentType()
          Returns the content type of this message.
 OutputDataStream getDataStream()
          Returns the whole message as an OutputDataStream which is accepted by the Channel.sendMessage method to send a message over the channel.
 MimeBodyPart getMimeContent()
          Returns the MIME body part specified by the content ID.
 HashSet getOptions()
          Returns all options of this message.
 APEXEndpointAddress getOriginator()
          Returns the originator endpoint address of this message.
 HashSet getRecipients()
          Returns a set of recpient endpoint addresses of this message.
 APEXEndpointAddress[] getRecipientsAddresses()
          Returns an array of recpient endpoint addresses of this message.
 Element getXMLContent()
          Returns the XML content of an XML data message (otherwise null)
 String getXMLMessage()
          Returns an XML message of this operation.
 String getXMLMessage(HashSet recipients)
          Returns an XML message of this data operation for the specified set of recipient endpoint addresses.
 boolean hasOriginator()
          Returns true if an originator is set, otherwise false.
 boolean hasRecipients()
          Returns true if at least one recipient is set, otherwise false.
 void removeOptionForProcessing(APEXOption o)
          Converts an option to a not processing option (not processed in hops).
 void removeOptionPermanently(APEXOption o)
          Removes an option from this message.
 void removeRecipient(APEXEndpointAddress aea)
          Removes a recipient endpoint address from this message.
 void setContentID(String contentURI)
          Sets the content URI for the starting MIME part.
 void setContentType(int type)
          Sets the content type of this message (@see APEXMessage).
 void setFinalOption(APEXOption o)
          Converts an option to a final option (not processed in intermediate hops).
 void setMimeContent(MimeMultipart mimeContent)
          Sets MIME Multipart content for this message
 void setOriginator(APEXEndpointAddress originator)
          Sets the originator of the message.
 void setPassiveOption(APEXOption o)
          Converts an option to a passive option (not sent to next hop).
 void setRecipients(HashSet recipients)
          Sets the recipients of the message.
 void setStringContent(String content)
          Sets string content for this message
 void setXMLContent(NodeList content)
          Sets XML content for this message
 
Methods inherited from class ch.epfl.lsr.apex.APEXMessage
apexMessageFactory, buildMimeBodyPart, getMessage, getMimeMessage, getMimeMultipart, getStatus, hashset2AddressTable, MimeBodyPartToString, setMessage, setStatus, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACTIVE

public static final String ACTIVE
internal option identifier status

See Also:
Constant Field Values

FINAL

public static final String FINAL
internal option identifier status

See Also:
Constant Field Values

PASSIV

public static final String PASSIV
internal option identifier status

See Also:
Constant Field Values

NOTPROCESSING

public static final String NOTPROCESSING
internal option identifier status

See Also:
Constant Field Values
Constructor Detail

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       HashSet recipients,
                       MimeMessage mimeContent,
                       HashSet options)

Instantiates a new APEXDataMessage containing MIME Multipart structured content.

Note: use javax.mail.internet.MimeBodyPart or javax.mail.internet.MimeMultipart for the MIME message.

Parameters:
originator - The originator endpoint address
recipients - A set of recipient endpoint addresses
mimeContent - The MIME content of this message
options - A set of options

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       HashSet recipients,
                       MimeMessage mimeContent)

Instantiates a new APEXDataMessage containing MIME Multipart structured content.

Note: use javax.mail.internet.MimeBodyPart or javax.mail.internet.MimeMultipart for the MIME message.

Parameters:
originator - The originator endpoint address
recipients - A set of recipient endpoint addresses
mimeContent - The MIME content of this message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       APEXEndpointAddress recipient,
                       MimeMessage mimeContent)

Instantiates a new APEXDataMessage containing MIME Multipart structured content.

Note: use javax.mail.internet.MimeBodyPart or javax.mail.internet.MimeMultipart for the MIME message.

Parameters:
originator - The originator endpoint address
recipient - A recipient endpoint address
mimeContent - The MIME content of this message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       HashSet recipients,
                       byte[] byteContent,
                       String contentType,
                       String transferEncoding,
                       HashSet options)
                throws APEXParsingException

Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.

Note: for a correct use, indicate the full transfer encoding used when building the byte array (see documentation).

Parameters:
originator - The originator endpoint address
recipients - A set of recipient endpoint addresses
byteContent - The byte content
contentType - The MIME content-type of the message
transferEncoding - The transfer encoding of the byte content
options - A set of options
Throws:
APEXParsingException - Thrown if an exception occurs while building the MIME Multipart message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       HashSet recipients,
                       byte[] byteContent,
                       String contentType,
                       String transferEncoding)
                throws APEXParsingException

Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.

Note: for a correct use, indicate the full transfer encoding used when building the byte array (see documentation).

Parameters:
originator - The originator endpoint address
recipients - A set of recipient endpoint addresses
byteContent - The byte content
contentType - The MIME content-type of the message
transferEncoding - The transfer encoding of the byte content
Throws:
APEXParsingException - Thrown if an exception occurs while building the MIME Multipart message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       APEXEndpointAddress[] recipients,
                       byte[] byteContent,
                       String contentType,
                       String transferEncoding)
                throws APEXParsingException

Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.

Note: for a correct use, indicate the full transfer encoding used when building the byte array (see documentation).

Parameters:
originator - The originator endpoint address
recipients - An array of recipient endpoint addresses
byteContent - The byte content
contentType - The MIME content-type of the message
transferEncoding - The transfer encoding of the byte content
Throws:
APEXParsingException - Thrown if an exception occurs while building the MIME Multipart message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       APEXEndpointAddress recipient,
                       byte[] byteContent,
                       String contentType,
                       String transferEncoding)
                throws APEXParsingException

Instantiates a new APEXDataMessage containing MIME Multipart structured content specified in a byte array.

Note: for a correct use, indicate the full transfer encoding used when building the byte array (see documentation).

Parameters:
originator - The originator endpoint address
recipient - A recipient endpoint address
byteContent - The byte content
contentType - The MIME content-type of the message
transferEncoding - The transfer encoding of the byte content
Throws:
APEXParsingException - Thrown if an exception occurs while building the MIME Multipart message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       HashSet recipients,
                       MimeBodyPart mpart)
                throws APEXParsingException

Instantiates a new APEXDataMessage containing MIME Multipart structured content.

Parameters:
originator - The originator endpoint address
recipients - A set of recipient endpoint addresses
mpart - The MIME content of this message
Throws:
APEXParsingException - Thrown if an exception occurs while building the MIME Multipart message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       APEXEndpointAddress recipient,
                       MimeBodyPart mpart)
                throws APEXParsingException

Instantiates a new APEXDataMessage containing MIME Multipart structured content.

Parameters:
originator - The originator endpoint address
recipient - A recipient endpoint address
mpart - The MIME content of this message
Throws:
APEXParsingException - Thrown if an exception occurs while building the MIME Multipart message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       APEXEndpointAddress[] recipients,
                       MimeBodyPart mpart)
                throws APEXParsingException

Instantiates a new APEXDataMessage containing MIME Multipart structured content.

Parameters:
originator - The originator endpoint address
recipients - An array of recipient endpoint addresses
mpart - The MIME content of this message
Throws:
APEXParsingException - Thrown if an exception occurs while building the MIME Multipart message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       HashSet recipients,
                       String xmlContent,
                       HashSet options)

Instantiates a new APEXDataMessage containing XML content.

Parameters:
originator - The originator endpoint address
recipients - A set of recipient endpoint addresses
xmlContent - The XML content of this message
options - A set of options

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       APEXEndpointAddress recipient,
                       String xmlContent)

Instantiates a new APEXDataMessage containing XML content.

Parameters:
originator - The originator endpoint address
recipient - A recipient endpoint address
xmlContent - The XML content of this message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       HashSet recipients,
                       String xmlContent)

Instantiates a new APEXDataMessage containing XML content.

Parameters:
originator - The originator endpoint address
recipients - A set of recipient endpoint addresses
xmlContent - The XML content of this message

APEXDataMessage

public APEXDataMessage(APEXEndpointAddress originator,
                       APEXEndpointAddress[] recipients,
                       String xmlContent)

Instantiates a new APEXDataMessage containing XML content.

Parameters:
originator - The originator endpoint address
recipients - An array of recipient endpoint addresses
xmlContent - The XML content of this message

APEXDataMessage

public APEXDataMessage()

Instantiates an empty APEXDataMessage.

Method Detail

getOriginator

public APEXEndpointAddress getOriginator()
Returns the originator endpoint address of this message.

Returns:
The originator endpoint address

getRecipients

public HashSet getRecipients()
Returns a set of recpient endpoint addresses of this message.

Returns:
The recipient endpoint addresses

getRecipientsAddresses

public APEXEndpointAddress[] getRecipientsAddresses()
Returns an array of recpient endpoint addresses of this message.

Returns:
The recipient endpoint addresses

getContent

public Hashtable getContent()
Returns the content table of this message.

Returns:
The content hash table

setContentID

public void setContentID(String contentURI)
Sets the content URI for the starting MIME part.

Parameters:
contentURI - The content URI

getContentID

public String getContentID()
Returns the content URI for the starting MIME part

Returns:
The content URI

getContent

public Object getContent(Object key)
Returns the content in the content table associated to the key.

Parameters:
key - The key in the content table
Returns:
the value to which the key is mapped in this content table; null if the key is not mapped to any value in this content table.

getContentType

public int getContentType()
Returns the content type of this message.

Returns:
The content URI
See Also:
APEXMessage.XMLCONTENT, APEXMessage.MIMECONTENT

setFinalOption

public void setFinalOption(APEXOption o)
Converts an option to a final option (not processed in intermediate hops).

Parameters:
o - The option to convert

setPassiveOption

public void setPassiveOption(APEXOption o)
Converts an option to a passive option (not sent to next hop). (@see #activateFinalAndNonProcessedOptions())

Parameters:
o - The option to convert

removeOptionForProcessing

public void removeOptionForProcessing(APEXOption o)
Converts an option to a not processing option (not processed in hops). (@see #activateFinalAndNonProcessedOptions())

Parameters:
o - The option to convert

activateFinalAndNonProcessedOptions

public void activateFinalAndNonProcessedOptions()
Reactivates final and not processing options before sending a message (only active options are sent to the next hop).


removeOptionPermanently

public void removeOptionPermanently(APEXOption o)
Removes an option from this message.

Parameters:
o - The option to be removed

removeRecipient

public void removeRecipient(APEXEndpointAddress aea)
Removes a recipient endpoint address from this message.

Parameters:
aea - The endpoint address to be removed

getOptions

public HashSet getOptions()
Returns all options of this message.

Returns:
A set containing all options

getAllOptions

public APEXOption[] getAllOptions()
Returns an array containing all options of this message.

Returns:
An array containing all options

getXMLContent

public Element getXMLContent()
Returns the XML content of an XML data message (otherwise null)

Returns:
The data element containing all elements

getMimeContent

public MimeBodyPart getMimeContent()
Returns the MIME body part specified by the content ID.

Returns:
The MIME body part of this message

setContentType

public void setContentType(int type)
Sets the content type of this message (@see APEXMessage).

Parameters:
type - The content type

addContent

public void addContent(Object key,
                       Object value)
Adds content with an associated key to the content table.

Parameters:
key - The key
value - The value of the content

addOption

public void addOption(APEXOption option)
Adds an option to this message

Parameters:
option - An option to be added

setOriginator

public void setOriginator(APEXEndpointAddress originator)
Sets the originator of the message.

Parameters:
originator - The originator endpoint address

setRecipients

public void setRecipients(HashSet recipients)
Sets the recipients of the message.

Parameters:
recipients - A set of recipient endpoint addresses

addRecipient

public void addRecipient(APEXEndpointAddress recipient)
Sets the recipient of the message.

Parameters:
recipient - The recipient endpoint address

hasOriginator

public boolean hasOriginator()
Returns true if an originator is set, otherwise false.

Returns:
Boolean indicator of the originator

hasRecipients

public boolean hasRecipients()
Returns true if at least one recipient is set, otherwise false.

Returns:
Boolean indicator of the recpients

getAPEXDataMessage

public APEXDataMessage getAPEXDataMessage(HashSet recipients)
Returns a new APEXDataMessage addressed to the specified set of recipient endpoint addresses.

Parameters:
recipients - A set of recpient endpoint addresses
Returns:
A new APEXDataMessage

getAPEXDataMessage

public APEXDataMessage getAPEXDataMessage(APEXEndpointAddress recipient)
Returns a new APEXDataMessage addressed to the specified recipient endpoint address.

Parameters:
recipient - The recpient endpoint address
Returns:
A new APEXDataMessage

clone

public Object clone()
             throws CloneNotSupportedException
Throws:
CloneNotSupportedException

getXMLMessage

public String getXMLMessage(HashSet recipients)
Returns an XML message of this data operation for the specified set of recipient endpoint addresses.

Parameters:
recipients - A set of recpient endpoint addresses
Returns:
The XML message

getXMLMessage

public String getXMLMessage()
Description copied from class: APEXMessage
Returns an XML message of this operation.

Specified by:
getXMLMessage in class APEXMessage
Returns:
A XML message

setStringContent

public void setStringContent(String content)
Sets string content for this message

Parameters:
content - The string content

setXMLContent

public void setXMLContent(NodeList content)
Sets XML content for this message

Parameters:
content - The XML (NodeList) content

setMimeContent

public void setMimeContent(MimeMultipart mimeContent)
Sets MIME Multipart content for this message

Parameters:
mimeContent - The MIME Multipart content

getDataStream

public OutputDataStream getDataStream()
Description copied from class: APEXMessage
Returns the whole message as an OutputDataStream which is accepted by the Channel.sendMessage method to send a message over the channel.

Overrides:
getDataStream in class APEXMessage
Returns:
the data stream