ch.epfl.lsr.apex
Class APEXMessage

java.lang.Object
  extended bych.epfl.lsr.apex.APEXMessage
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
APEXAttachMessage, APEXBindMessage, APEXDataMessage, APEXTerminateMessage

public abstract class APEXMessage
extends Object
implements Cloneable

An APEXMessage is an abstract class identifying an APEX message.

In order to obtain a data message to send over the APEX mesh, a new APEXDataMessage must be instantiated.

A APEXMessage is either:

Author:
Marc Stoecklin
See Also:
APEXAttachMessage, APEXBindMessage, APEXTerminateMessage, APEXDataMessage, APEXDataMessage.getContentType()

Field Summary
static String APPBEEPXML
          MIME identifier for APPLICATION/BEEP+XML messages
static int ATTACH
          Message type: attach message
static String BEEPXML
          MIME identifier for BEEP+XML messages
static int BIND
          Message type: bind message
static String CONTENTTRANSFERENCODING
          Content-Transfer-Encoding identifier
static String CONTENTTYPE
          Content-Type identifier
static int DATA
          Message type: data message
static String ENC_7BIT
          Encoding type for 7 bit
static String ENC_8BIT
          Encoding type for 8 bit
static String ENC_BASE64
          Encoding type for base 64
static String ENC_BINARY
          Encoding type for binary content
static String ENC_QUOTEDPRINTABLE
          Encoding type for quoted printable
static String ENC_UUENCODE
          Encoding type for UUEncode
static int ERROR
          Message type: error message
static String FILENAME
          Filename identifier
protected  MessageMSG message
          the received org.beepcore.beep.core.MessageMSG message
static int MIMECONTENT
          Content Type of this message: MIME Multipart structured content
static String MIMECONTENT_HASHKEY
          Table key for MIME content
static int OK
          Message type: ok message
static String RELATED
          MIME identifier for multipart/related
static String START
          start identifier
static String START_HASHKEY
          Table key for start identifier
protected  APEXStatus status
          an optional APEX status associated to this message
static int STRINGCONTENT
          Content Type of this message: String content (only for instantiation)
static String STRINGCONTENT_HASHKEY
          Table key for String content
static int TERMINATE
          Message type: terminate message
static String TYPE
          type identifier
static int XMLCONTENT
          Content Type of this message: XML content
static String XMLCONTENT_HASHKEY
          Table key for XML content
 
Constructor Summary
APEXMessage()
           
 
Method Summary
static APEXMessage apexMessageFactory(MessageMSG message)
           Accepts an incoming org.beepcore.beep.core.MessageMSG and parses this object in order to extract a complete APEXMessage.
static MimeBodyPart buildMimeBodyPart(String content)
          Builds a MIME body part of a textual String and adds the BEEP headers (beep-xml) for Content-Type
 OutputDataStream getDataStream()
          Returns the whole message as an OutputDataStream which is accepted by the Channel.sendMessage method to send a message over the channel.
 MessageMSG getMessage()
          Returns the org.beepcore.beep.core.MessageMSG associated to this message (used internally for processing).
static MimeMessage getMimeMessage(MimeMultipart mmp)
          Converts a MIME Multipart in a fully defined MIME message.
static MimeMultipart getMimeMultipart(MimeBodyPart part1, MimeBodyPart part2)
          Relates (multipart/related) two MIME body parts in one MIME Multipart.
 APEXStatus getStatus()
          Returns the status listener for this message.
abstract  String getXMLMessage()
          Returns an XML message of this operation.
static APEXEndpointAddress[] hashset2AddressTable(HashSet recipientSet)
          Converts a HashSet containing APEXEndpointAddresses into an array.
static String MimeBodyPartToString(MimeBodyPart mbp)
          Converts a MimeBodyPart to a String.
 void setMessage(MessageMSG m)
          Adds a org.beepcore.beep.core.MessageMSG message to this message (used internally for processing).
 void setStatus(APEXStatus s)
          Sets a status listener for this message.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BEEPXML

public static final String BEEPXML
MIME identifier for BEEP+XML messages

See Also:
Constant Field Values

APPBEEPXML

public static final String APPBEEPXML
MIME identifier for APPLICATION/BEEP+XML messages

See Also:
Constant Field Values

START

public static final String START
start identifier

See Also:
Constant Field Values

TYPE

public static final String TYPE
type identifier

See Also:
Constant Field Values

CONTENTTYPE

public static final String CONTENTTYPE
Content-Type identifier

See Also:
Constant Field Values

RELATED

public static final String RELATED
MIME identifier for multipart/related

See Also:
Constant Field Values

CONTENTTRANSFERENCODING

public static final String CONTENTTRANSFERENCODING
Content-Transfer-Encoding identifier

See Also:
Constant Field Values

FILENAME

public static final String FILENAME
Filename identifier

See Also:
Constant Field Values

ENC_BASE64

public static final String ENC_BASE64
Encoding type for base 64

See Also:
Constant Field Values

ENC_7BIT

public static final String ENC_7BIT
Encoding type for 7 bit

See Also:
Constant Field Values

ENC_8BIT

public static final String ENC_8BIT
Encoding type for 8 bit

See Also:
Constant Field Values

ENC_BINARY

public static final String ENC_BINARY
Encoding type for binary content

See Also:
Constant Field Values

ENC_UUENCODE

public static final String ENC_UUENCODE
Encoding type for UUEncode

See Also:
Constant Field Values

ENC_QUOTEDPRINTABLE

public static final String ENC_QUOTEDPRINTABLE
Encoding type for quoted printable

See Also:
Constant Field Values

ATTACH

public static final int ATTACH
Message type: attach message

See Also:
Constant Field Values

BIND

public static final int BIND
Message type: bind message

See Also:
Constant Field Values

TERMINATE

public static final int TERMINATE
Message type: terminate message

See Also:
Constant Field Values

DATA

public static final int DATA
Message type: data message

See Also:
Constant Field Values

OK

public static final int OK
Message type: ok message

See Also:
Constant Field Values

ERROR

public static final int ERROR
Message type: error message

See Also:
Constant Field Values

XMLCONTENT

public static final int XMLCONTENT
Content Type of this message: XML content

See Also:
Constant Field Values

STRINGCONTENT

public static final int STRINGCONTENT
Content Type of this message: String content (only for instantiation)

See Also:
Constant Field Values

MIMECONTENT

public static final int MIMECONTENT
Content Type of this message: MIME Multipart structured content

See Also:
Constant Field Values

XMLCONTENT_HASHKEY

public static final String XMLCONTENT_HASHKEY
Table key for XML content

See Also:
Constant Field Values

STRINGCONTENT_HASHKEY

public static final String STRINGCONTENT_HASHKEY
Table key for String content

See Also:
Constant Field Values

MIMECONTENT_HASHKEY

public static final String MIMECONTENT_HASHKEY
Table key for MIME content

See Also:
Constant Field Values

START_HASHKEY

public static final String START_HASHKEY
Table key for start identifier

See Also:
Constant Field Values

message

protected MessageMSG message
the received org.beepcore.beep.core.MessageMSG message


status

protected APEXStatus status
an optional APEX status associated to this message

Constructor Detail

APEXMessage

public APEXMessage()
Method Detail

setMessage

public void setMessage(MessageMSG m)
Adds a org.beepcore.beep.core.MessageMSG message to this message (used internally for processing).

Parameters:
m - The received messageMSG

getMessage

public MessageMSG getMessage()
Returns the org.beepcore.beep.core.MessageMSG associated to this message (used internally for processing).

Returns:
The received messageMSG

setStatus

public void setStatus(APEXStatus s)
Sets a status listener for this message.

Parameters:
s - The status listener

getStatus

public APEXStatus getStatus()
Returns the status listener for this message.

Returns:
The status listener

getXMLMessage

public abstract String getXMLMessage()
Returns an XML message of this operation.

Returns:
A XML message

hashset2AddressTable

public static APEXEndpointAddress[] hashset2AddressTable(HashSet recipientSet)
Converts a HashSet containing APEXEndpointAddresses into an array.

Parameters:
recipientSet - The APEXEndpointAddress HashSet
Returns:
An array of APEXEndpointAddresseses

buildMimeBodyPart

public static MimeBodyPart buildMimeBodyPart(String content)
                                      throws MessagingException
Builds a MIME body part of a textual String and adds the BEEP headers (beep-xml) for Content-Type

Parameters:
content - The String
Returns:
A MIME bodypart
Throws:
MessagingException

getMimeMultipart

public static MimeMultipart getMimeMultipart(MimeBodyPart part1,
                                             MimeBodyPart part2)
                                      throws MessagingException
Relates (multipart/related) two MIME body parts in one MIME Multipart.

Parameters:
part1 - First MIME body part
part2 - Second MIME body part
Returns:
The resulting MIME Multipart
Throws:
MessagingException - Thrown on exceptions in MimeMultipart

MimeBodyPartToString

public static String MimeBodyPartToString(MimeBodyPart mbp)
Converts a MimeBodyPart to a String.

Parameters:
mbp - The MimeBodyPart
Returns:
The String

getDataStream

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

Returns:
the data stream

getMimeMessage

public static MimeMessage getMimeMessage(MimeMultipart mmp)
                                  throws MessagingException
Converts a MIME Multipart in a fully defined MIME message.

Parameters:
mmp - The MIME Multipart
Returns:
The MIME message
Throws:
MessagingException - Thrown on conversion by the javax.mail.mime package

apexMessageFactory

public static APEXMessage apexMessageFactory(MessageMSG message)
                                      throws APEXParsingException

Accepts an incoming org.beepcore.beep.core.MessageMSG and parses this object in order to extract a complete APEXMessage.

This method either generates

Parameters:
message - The MessageMSG message
Returns:
The APEX message
Throws:
APEXParsingException - Thrown if the format of the message is not valid
See Also:
APEXAttachMessage, APEXBindMessage, APEXTerminateMessage, APEXDataMessage, APEXDataMessage.getContentType()

toString

public String toString()