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 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  javax.jms.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(javax.jms.Message message)
          Create a SEMAINE specific abstraction from the given message.
 
Method Summary
 java.lang.String getDatatype()
          Get the name of the data type received.
 IOBase.Event getEventType()
          For event-based messages, determine the event type.
 javax.jms.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

message

protected javax.jms.Message message
Constructor Detail

SEMAINEMessage

public SEMAINEMessage(javax.jms.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 javax.jms.JMSException
Get the user time that the message refers to, in milliseconds since 1970.

Returns:
the user time
Throws:
javax.jms.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 javax.jms.JMSException
Get the name of the data type received.

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

getSource

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

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

isPeriodic

public boolean isPeriodic()
                   throws javax.jms.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:
javax.jms.JMSException - if the JMS provider fails to get the property value due to some internal error.

isEventBased

public boolean isEventBased()
                     throws javax.jms.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:
javax.jms.JMSException - if the JMS provider fails to get the property value due to some internal error.

getEventType

public IOBase.Event getEventType()
                          throws javax.jms.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:
javax.jms.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 javax.jms.JMSException,
                     java.lang.IllegalStateException
For periodic messages, determine the period length.

Returns:
the period length, in milliseconds.
Throws:
javax.jms.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.

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 javax.jms.JMSException
For text messages, provide access to the text sent.

Returns:
the text sent in the body of the message.
Throws:
javax.jms.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 javax.jms.JMSException
Get the name of the topic to which this message had been sent.

Returns:
Throws:
javax.jms.JMSException

getMessage

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

Returns:
the low-level message object.