eu.semaine.jms.sender
Class FeatureSender

java.lang.Object
  extended by eu.semaine.jms.IOBase
      extended by eu.semaine.jms.sender.Sender
          extended by eu.semaine.jms.sender.FeatureSender

public class FeatureSender
extends Sender

An abstraction of Sender for feature vectors.

Author:
marc

Nested Class Summary
 
Nested classes/interfaces inherited from class eu.semaine.jms.IOBase
IOBase.ConnectionStatus, IOBase.Event
 
Field Summary
protected  java.lang.String[] featureNames
           
 
Fields inherited from class eu.semaine.jms.sender.Sender
datatype, period, producer, source
 
Fields inherited from class eu.semaine.jms.IOBase
connection, exception, isConnectionStarted, jmsPassword, jmsUrl, jmsUser, session, topic, topicName
 
Constructor Summary
FeatureSender(java.lang.String topicName, java.lang.String datatype, java.lang.String source)
          Create a new event-based FeatureSender to the given topic on the default JMS server.
FeatureSender(java.lang.String topicName, java.lang.String datatype, java.lang.String source, int period)
          Create a new periodic FeatureSender to the given topic on the default JMS server.
FeatureSender(java.lang.String jmsUrl, java.lang.String jmsUser, java.lang.String jmsPassword, java.lang.String topicName, java.lang.String datatype, java.lang.String source)
          Create a new event-based FeatureSender to the given topic on the given JMS server.
FeatureSender(java.lang.String jmsUrl, java.lang.String jmsUser, java.lang.String jmsPassword, java.lang.String topicName, java.lang.String datatype, java.lang.String source, int period)
          Create a new periodic FeatureSender to the given topic on the given JMS server.
 
Method Summary
 java.lang.String[] getFeatureNames()
          Provides access to the array of feature names.
protected  void sendBinaryFeatureVector(float[] features, long usertime)
          For periodic messages
protected  void sendBinaryFeatureVector(float[] features, long usertime, IOBase.Event eventType, java.lang.String contentID, long contentCreationTime, java.lang.String contentType)
          For event-based messages
 void sendFeatureVector(float[] features, long usertime)
          Send a vector of float features as a text message.
 void sendFeatureVector(float[] features, long usertime, boolean sendBinary)
          Send a vector of float features.
 void sendFeatureVector(float[] features, long usertime, boolean sendBinary, IOBase.Event eventType, java.lang.String contentID, long contentCreationTime)
          Send a vector of float features.
 void sendFeatureVector(float[] features, long usertime, boolean sendBinary, IOBase.Event eventType, java.lang.String contentID, long contentCreationTime, java.lang.String contentType)
          Send a vector of float features.
 void sendFeatureVector(float[] features, long usertime, IOBase.Event eventType, java.lang.String contentID, long contentCreationTime)
          Send a vector of float features as a text message.
 void sendFeatureVector(float[] features, long usertime, IOBase.Event eventType, java.lang.String contentID, long contentCreationTime, java.lang.String contentType)
          Send a vector of float features as a text message.
protected  void sendTextFeatureVector(float[] features, long usertime)
          For periodic messages
protected  void sendTextFeatureVector(float[] features, long usertime, IOBase.Event eventType, java.lang.String contentID, long contentCreationTime, java.lang.String contentType)
          For event-based messages
 void setFeatureNames(java.lang.String[] aFeatureNames)
          Initiate the list of feature names to use.
 
Methods inherited from class eu.semaine.jms.sender.Sender
fillMessageProperties, fillMessageProperties, fillMessageProperties, getDatatype, getPeriod, getSource, getTimeToLive, initialise, isEventBased, isPeriodic, main, sendTextMessage, sendTextMessage, sendTextMessage, sendTextMessage, sendTextMessage, sendTextMessage, setEventBased, setPeriodic, setTimeToLive
 
Methods inherited from class eu.semaine.jms.IOBase
createConnection, getConnection, getConnection, getConnectionStatus, getJMSPassword, getJMSUrl, getJMSUser, getSession, getTopic, getTopicName, isEmbeddedBroker, startConnection, useEmbeddedBroker
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

featureNames

protected java.lang.String[] featureNames
Constructor Detail

FeatureSender

public FeatureSender(java.lang.String topicName,
                     java.lang.String datatype,
                     java.lang.String source)
              throws JMSException
Create a new event-based FeatureSender to the given topic on the default JMS server. The default JMS server is determined as follows: Datatype and source will be sent with every message.

Parameters:
topic - the name of the topic to send to.
datatype - the name of the type of data being sent.
source - the name of the component sending the data.
the - period in which we intend to send data, in milliseconds
Throws:
java.lang.NullPointerException - if any of the parameters topicName, datatype, or source are null.
java.lang.IllegalArgumentException - if period is <= 0.
JMSException

FeatureSender

public FeatureSender(java.lang.String topicName,
                     java.lang.String datatype,
                     java.lang.String source,
                     int period)
              throws JMSException
Create a new periodic FeatureSender to the given topic on the default JMS server. The default JMS server is determined as follows: Datatype and source will be sent with every message.

Parameters:
topic - the name of the topic to send to.
datatype - the name of the type of data being sent.
source - the name of the component sending the data.
the - period in which we intend to send data, in milliseconds
Throws:
java.lang.NullPointerException - if any of the parameters topicName, datatype, or source are null.
java.lang.IllegalArgumentException - if period is <= 0.
JMSException

FeatureSender

public FeatureSender(java.lang.String jmsUrl,
                     java.lang.String jmsUser,
                     java.lang.String jmsPassword,
                     java.lang.String topicName,
                     java.lang.String datatype,
                     java.lang.String source)
              throws JMSException
Create a new event-based FeatureSender to the given topic on the given JMS server. Datatype and source will be sent with every message.

Parameters:
jmsUrl - the url where to contact the JMS server
jmsUser - the username to use (can be null)
jmsPassword - the password to use (can be null)
topic - the name of the topic to send to.
datatype - the name of the type of data being sent.
source - the name of the component sending the data.
the - period in which we intend to send data, in milliseconds
Throws:
JMSException
java.lang.NullPointerException - if any of the parameters jmsUrl, topicName, datatype, or source are null.
java.lang.IllegalArgumentException - if period is <= 0.

FeatureSender

public FeatureSender(java.lang.String jmsUrl,
                     java.lang.String jmsUser,
                     java.lang.String jmsPassword,
                     java.lang.String topicName,
                     java.lang.String datatype,
                     java.lang.String source,
                     int period)
              throws JMSException
Create a new periodic FeatureSender to the given topic on the given JMS server. Datatype and source will be sent with every message.

Parameters:
jmsUrl - the url where to contact the JMS server
jmsUser - the username to use (can be null)
jmsPassword - the password to use (can be null)
topic - the name of the topic to send to.
datatype - the name of the type of data being sent.
source - the name of the component sending the data.
the - period in which we intend to send data, in milliseconds
Throws:
JMSException
java.lang.NullPointerException - if any of the parameters jmsUrl, topicName, datatype, or source are null.
java.lang.IllegalArgumentException - if period is <= 0.
Method Detail

setFeatureNames

public void setFeatureNames(java.lang.String[] aFeatureNames)
Initiate the list of feature names to use. This method must be called exactly once, after the creation of the object and before the first send operation.

Parameters:
aFeatureNames - the feature names, in exactly the same order as the features that will be sent.
Throws:
java.lang.IllegalStateException - if feature names have been set before.
java.lang.NullPointerException - if aFeatureNames is null.

getFeatureNames

public java.lang.String[] getFeatureNames()
Provides access to the array of feature names. May be useful for debugging.

Returns:
the internal feature names array.

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime)
                       throws JMSException
Send a vector of float features as a text message. This is for periodic feature vectors. Before sending features, {@link #setFeatureNames(String[]) must be called, and the names must correspond to the features passed in the argument.

Parameters:
features - the features to send.
usertime - the "user" time at which this message is being sent, in milliseconds since system startup.
Throws:
JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              boolean sendBinary)
                       throws JMSException
Send a vector of float features. This is for periodic feature vectors. Before sending features, {@link #setFeatureNames(String[]) must be called, and the names must correspond to the features passed in the argument.

Parameters:
features - the features to send.
usertime - the "user" time at which this message is being sent, in milliseconds since system startup.
sendBinary - if true, send as binary feature vector, else send as textual feature vector
Throws:
JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              IOBase.Event eventType,
                              java.lang.String contentID,
                              long contentCreationTime)
                       throws JMSException
Send a vector of float features as a text message. This is for event-based feature vectors. Before sending features, {@link #setFeatureNames(String[]) must be called, and the names must correspond to the features passed in the argument.

Parameters:
features - the features to send.
usertime - the "user" time at which this message is being sent, in milliseconds since system startup.
eventType - the type of event represented by this message.
contentID - a unique identifier for the message's content. If this is not null, it will cause the addition of the String property content-id in the message.
contentCreationTime - the time when the content in this message was created. If this is not negative, it will cause the addition of the Long property content-creation-time in the message.
Throws:
JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              IOBase.Event eventType,
                              java.lang.String contentID,
                              long contentCreationTime,
                              java.lang.String contentType)
                       throws JMSException
Send a vector of float features as a text message. This is for event-based feature vectors. Before sending features, {@link #setFeatureNames(String[]) must be called, and the names must correspond to the features passed in the argument.

Parameters:
features - the features to send.
usertime - the "user" time at which this message is being sent, in milliseconds since system startup.
eventType - the type of event represented by this message.
contentID - a unique identifier for the message's content. If this is not null, it will cause the addition of the String property content-id in the message.
contentCreationTime - the time when the content in this message was created. If this is not negative, it will cause the addition of the Long property content-creation-time in the message.
contentType - an optional content type for the message's content; The value may be one of SEMAINEMessage.CONTENT_TYPE_UTTERANCE, SEMAINEMessage.CONTENT_TYPE_LISTENERVOCALISATION, SEMAINEMessage.CONTENT_TYPE_VISUALONLY, or any other string. Can be null, in which case no content type will be sent.
Throws:
JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              boolean sendBinary,
                              IOBase.Event eventType,
                              java.lang.String contentID,
                              long contentCreationTime)
                       throws JMSException
Send a vector of float features. This is for event-based feature vectors. Before sending features, {@link #setFeatureNames(String[]) must be called, and the names must correspond to the features passed in the argument.

Parameters:
features - the features to send.
usertime - the "user" time at which this message is being sent, in milliseconds since system startup.
sendBinary - if true, send as binary feature vector, else send as textual feature vector
eventType - the type of event represented by this message.
contentID - a unique identifier for the message's content. If this is not null, it will cause the addition of the String property content-id in the message.
contentCreationTime - the time when the content in this message was created. If this is not negative, it will cause the addition of the Long property content-creation-time in the message.
Throws:
JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              boolean sendBinary,
                              IOBase.Event eventType,
                              java.lang.String contentID,
                              long contentCreationTime,
                              java.lang.String contentType)
                       throws JMSException
Send a vector of float features. This is for event-based feature vectors. Before sending features, {@link #setFeatureNames(String[]) must be called, and the names must correspond to the features passed in the argument.

Parameters:
features - the features to send.
usertime - the "user" time that this message refers to, in milliseconds since system startup.
sendBinary - if true, send as binary feature vector, else send as textual feature vector
eventType - the type of event represented by this message.
contentID - a unique identifier for the message's content. If this is not null, it will cause the addition of the String property content-id in the message.
contentCreationTime - the time when the content in this message was created. If this is not negative, it will cause the addition of the Long property content-creation-time in the message.
contentType - an optional content type for the message's content; The value may be one of SEMAINEMessage.CONTENT_TYPE_UTTERANCE, SEMAINEMessage.CONTENT_TYPE_LISTENERVOCALISATION, SEMAINEMessage.CONTENT_TYPE_VISUALONLY, or any other string. Can be null, in which case no content type will be sent.
Throws:
JMSException

sendBinaryFeatureVector

protected void sendBinaryFeatureVector(float[] features,
                                       long usertime)
                                throws JMSException
For periodic messages

Parameters:
features -
usertime -
Throws:
JMSException

sendBinaryFeatureVector

protected void sendBinaryFeatureVector(float[] features,
                                       long usertime,
                                       IOBase.Event eventType,
                                       java.lang.String contentID,
                                       long contentCreationTime,
                                       java.lang.String contentType)
                                throws JMSException
For event-based messages

Parameters:
features -
usertime -
Throws:
JMSException

sendTextFeatureVector

protected void sendTextFeatureVector(float[] features,
                                     long usertime)
                              throws JMSException
For periodic messages

Parameters:
features -
usertime -
Throws:
JMSException

sendTextFeatureVector

protected void sendTextFeatureVector(float[] features,
                                     long usertime,
                                     IOBase.Event eventType,
                                     java.lang.String contentID,
                                     long contentCreationTime,
                                     java.lang.String contentType)
                              throws JMSException
For event-based messages

Parameters:
features -
usertime -
eventType -
contentID -
contentCreationTime -
Throws:
JMSException