eu.semaine.jms.message
Class SEMAINEMessage

java.lang.Object
  extended by eu.semaine.jms.message.SEMAINEMessage
Direct Known Subclasses:
SEMAINEBytesMessage, SEMAINEFeatureMessage, SEMAINEXMLMessage

public class SEMAINEMessage
extends java.lang.Object

A representation of a message as used in SEMAINE code. It is a higher-level access method for JMS messages, providing interpretations of information accessible in the message headers. This base class provides access to the Message body only as plain text (for text messages). Subclasses should:

Author:
marc

Field Summary
static java.lang.String CONTENT_CREATION_TIME
          The name of the property used for the content's creation time, if given.
static java.lang.String CONTENT_ID
          The name of the property used for the content's unique identifier, if any.
static java.lang.String CONTENT_TYPE
          The name of the property used for the content's type, if any.
static java.lang.String CONTENT_TYPE_LISTENERVOCALISATION
          A possible value of the CONTENT_TYPE property, representing a listener vocalisation.
static java.lang.String CONTENT_TYPE_UTTERANCE
          A possible value of the CONTENT_TYPE property, representing a speaker utterance.
static java.lang.String CONTENT_TYPE_VISUALONLY
          A possible value of the CONTENT_TYPE property, representing a visual-only agent behaviour.
static java.lang.String DATATYPE
          The name of the property used for the type of data being sent.
static java.lang.String EVENT
          The name of the property used for the type of event being sent (for event-based messages).
protected  Message message
           
static java.lang.String PERIOD
          The name of the property used for the period length, in milliseconds (for periodic messages).
static java.lang.String SOURCE
          The name of the property used for the component that sent the data.
static java.lang.String USERTIME
          The name of the property used for time in "user" time that the message refers to.
 
Constructor Summary
SEMAINEMessage(Message message)
          Create a SEMAINE specific abstraction from the given message.
 
Method Summary
 long getContentCreationTime()
          Get the time when the content was originally created.
 java.lang.String getContentID()
          Get the unique ID of the content in the message, if any.
 java.lang.String getContentType()
          Get the type of the content in the message, if any.
 java.lang.String getDatatype()
          Get the name of the data type received.
 IOBase.Event getEventType()
          For event-based messages, determine the event type.
 Message getMessage()
          Provide access to the low-level message encapsulated in this object.
 int getPeriod()
          For periodic messages, determine the period length.
 java.lang.String getSource()
          Get the name of the source component that sent the data.
 java.lang.String getText()
          For text messages, provide access to the text sent.
 java.lang.String getTopicName()
          Get the name of the topic to which this message had been sent.
 long getUsertime()
          Get the user time that the message refers to, in milliseconds since 1970.
 boolean isBytesMessage()
          Determine whether the message is a bytes message.
 boolean isEventBased()
          Determine whether the message is event-based.
 boolean isPeriodic()
          Determine whether the message is periodic.
 boolean isTextMessage()
          Determine whether the message is a text message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USERTIME

public static final java.lang.String USERTIME
The name of the property used for time in "user" time that the message refers to.

See Also:
Constant Field Values

DATATYPE

public static final java.lang.String DATATYPE
The name of the property used for the type of data being sent.

See Also:
Constant Field Values

SOURCE

public static final java.lang.String SOURCE
The name of the property used for the component that sent the data.

See Also:
Constant Field Values

EVENT

public static final java.lang.String EVENT
The name of the property used for the type of event being sent (for event-based messages).

See Also:
Constant Field Values

PERIOD

public static final java.lang.String PERIOD
The name of the property used for the period length, in milliseconds (for periodic messages).

See Also:
Constant Field Values

CONTENT_ID

public static final java.lang.String CONTENT_ID
The name of the property used for the content's unique identifier, if any.

See Also:
Constant Field Values

CONTENT_CREATION_TIME

public static final java.lang.String CONTENT_CREATION_TIME
The name of the property used for the content's creation time, if given.

See Also:
Constant Field Values

CONTENT_TYPE

public static final java.lang.String CONTENT_TYPE
The name of the property used for the content's type, if any.

See Also:
Constant Field Values

CONTENT_TYPE_UTTERANCE

public static final java.lang.String CONTENT_TYPE_UTTERANCE
A possible value of the CONTENT_TYPE property, representing a speaker utterance.

See Also:
Constant Field Values

CONTENT_TYPE_LISTENERVOCALISATION

public static final java.lang.String CONTENT_TYPE_LISTENERVOCALISATION
A possible value of the CONTENT_TYPE property, representing a listener vocalisation.

See Also:
Constant Field Values

CONTENT_TYPE_VISUALONLY

public static final java.lang.String CONTENT_TYPE_VISUALONLY
A possible value of the CONTENT_TYPE property, representing a visual-only agent behaviour.

See Also:
Constant Field Values

message

protected Message message
Constructor Detail

SEMAINEMessage

public SEMAINEMessage(Message message)
               throws MessageFormatException
Create a SEMAINE specific abstraction from the given message.

Parameters:
message - a message containing SEMAINE-specific properties.
Throws:
java.lang.NullPointerException - if message is null.
MessageFormatException - if the message does not have the proper format
Method Detail

getUsertime

public long getUsertime()
                 throws JMSException
Get the user time that the message refers to, in milliseconds since 1970.

Returns:
the user time
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.
MessageFormatException - if the message property exists but has the wrong type.

getDatatype

public java.lang.String getDatatype()
                             throws JMSException
Get the name of the data type received.

Returns:
a string containing the name of the data type
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.

getSource

public java.lang.String getSource()
                           throws JMSException
Get the name of the source component that sent the data.

Returns:
a string containing the name of the source component
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.

isPeriodic

public boolean isPeriodic()
                   throws JMSException
Determine whether the message is periodic. This is determined by the presence of the period property.

Returns:
true if message is periodic, false if message is event-based.
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.

isEventBased

public boolean isEventBased()
                     throws JMSException
Determine whether the message is event-based. This is determined by the presence of the event property.

Returns:
true if message is event-based, false if message is periodic.
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.

getEventType

public IOBase.Event getEventType()
                          throws JMSException,
                                 java.lang.IllegalArgumentException,
                                 java.lang.IllegalStateException,
                                 MessageFormatException
For event-based messages, determine the event type.

Returns:
an Event object representing the event type.
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.
MessageFormatException - if the message contains an event property, but the value is not known.
java.lang.IllegalStateException - if the message is not event-based.
java.lang.IllegalArgumentException

getPeriod

public int getPeriod()
              throws JMSException,
                     java.lang.IllegalStateException
For periodic messages, determine the period length.

Returns:
the period length, in milliseconds.
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.
java.lang.IllegalStateException - if the message is not periodic.

getContentID

public java.lang.String getContentID()
                              throws JMSException
Get the unique ID of the content in the message, if any.

Returns:
the content ID as a string, or null if the message doesn't have a content ID.
Throws:
JMSException

getContentCreationTime

public long getContentCreationTime()
                            throws JMSException
Get the time when the content was originally created.

Returns:
the time in user time, or -1 if the message doesn't contain this property.
Throws:
JMSException

getContentType

public java.lang.String getContentType()
                                throws JMSException
Get the type of the content in the message, if any.

Returns:
the content type as a string, or the empty string if the message doesn't have a content type. The value may be one of CONTENT_TYPE_UTTERANCE, CONTENT_TYPE_LISTENERVOCALISATION, CONTENT_TYPE_VISUALONLY, or any other string, or null if the message doesn't have a content ID.
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.

isTextMessage

public boolean isTextMessage()
Determine whether the message is a text message.

Returns:
true if the message is a text message, false otherwise.

isBytesMessage

public boolean isBytesMessage()
Determine whether the message is a bytes message.

Returns:
true if the message is a bytes message, false otherwise.

getText

public java.lang.String getText()
                         throws JMSException
For text messages, provide access to the text sent.

Returns:
the text sent in the body of the message.
Throws:
JMSException - if the JMS provider fails to get the property value due to some internal error.
java.lang.IllegalStateException - if the message is not a text message.

getTopicName

public java.lang.String getTopicName()
                              throws JMSException
Get the name of the topic to which this message had been sent.

Returns:
Throws:
JMSException

getMessage

public Message getMessage()
Provide access to the low-level message encapsulated in this object.

Returns:
the low-level message object.