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.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, 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)
          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, IOBase.Event eventType, java.lang.String contentID, long contentCreationTime)
          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)
          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, getDatatype, getPeriod, getSource, getTimeToLive, initialise, isEventBased, isPeriodic, main, sendTextMessage, sendTextMessage, sendTextMessage, sendTextMessage, setEventBased, setPeriodic, setTimeToLive
 
Methods inherited from class eu.semaine.jms.IOBase
getConnection, getJMSUrl, getSession, getTopic, getTopicName, startConnection
 
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 javax.jms.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.
javax.jms.JMSException

FeatureSender

public FeatureSender(java.lang.String topicName,
                     java.lang.String datatype,
                     java.lang.String source,
                     int period)
              throws javax.jms.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.
javax.jms.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 javax.jms.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:
javax.jms.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 javax.jms.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:
javax.jms.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 javax.jms.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 1970.
Throws:
javax.jms.JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              boolean sendBinary)
                       throws javax.jms.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 1970.
Throws:
javax.jms.JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              IOBase.Event eventType,
                              java.lang.String contentID,
                              long contentCreationTime)
                       throws javax.jms.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 1970.
Throws:
javax.jms.JMSException

sendFeatureVector

public void sendFeatureVector(float[] features,
                              long usertime,
                              boolean sendBinary,
                              IOBase.Event eventType,
                              java.lang.String contentID,
                              long contentCreationTime)
                       throws javax.jms.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 1970.
Throws:
javax.jms.JMSException

sendBinaryFeatureVector

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

Parameters:
features -
usertime -
Throws:
javax.jms.JMSException

sendBinaryFeatureVector

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

Parameters:
features -
usertime -
Throws:
javax.jms.JMSException

sendTextFeatureVector

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

Parameters:
features -
usertime -
Throws:
javax.jms.JMSException

sendTextFeatureVector

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

Parameters:
features -
usertime -
eventType -
contentID -
contentCreationTime -
Throws:
javax.jms.JMSException