org.dawb.passerelle.common.message
Class MessageUtils

java.lang.Object
  extended by org.dawb.passerelle.common.message.MessageUtils

public class MessageUtils
extends java.lang.Object

Class to encapsulate messages and data methods sent around the network.

Author:
gerring

Constructor Summary
MessageUtils()
           
 
Method Summary
static java.util.Map<java.lang.String,java.lang.Object> coerceData(com.isencia.passerelle.message.ManagedMessage message)
          Method used to get data into map of data sets.
static DataMessageComponent coerceMessage(com.isencia.passerelle.message.ManagedMessage message)
          Extracts or creates a DataMessageComponent from a message
static uk.ac.diamond.scisoft.analysis.io.IMetaData coerceMeta(com.isencia.passerelle.message.ManagedMessage message)
          Attempts to get the IMetaData from the message if it exists.
static DataMessageComponent copy(java.util.List<DataMessageComponent> cache)
           
static double evaluateExpression(java.lang.String expression, DataMessageComponent comp)
          JEP evaluation based on scalar values.
static com.isencia.passerelle.message.ManagedMessage getDataMessage(DataMessageComponent despatch)
           
static java.util.List<uk.ac.diamond.scisoft.analysis.dataset.IDataset> getDatasets(DataMessageComponent comp)
          List of all the data sets contained in the DataMessageComponent(s) Does not try and make data sets out of primitive arrays
static java.util.List<uk.ac.diamond.scisoft.analysis.dataset.IDataset> getDatasets(java.util.List<DataMessageComponent> data)
          List of all the data sets contained in the DataMessageComponent(s) Does not try and make data sets out of primitive arrays
static uk.ac.diamond.scisoft.analysis.io.IMetaData getMeta(java.util.List<DataMessageComponent> cache)
          Attempts to determine meta data to be passed on from range of inputs.
static java.lang.String getNames(java.util.Collection<uk.ac.diamond.scisoft.analysis.dataset.IDataset> sets)
           
static java.lang.String getNames(uk.ac.diamond.scisoft.analysis.dataset.IDataset... sets)
           
static java.util.Map<java.lang.String,java.lang.String> getScalar(java.util.List<DataMessageComponent> cache)
           
static java.util.Map<java.lang.String,java.lang.String> getValues(DataMessageComponent comp, java.util.Collection vars, ptolemy.kernel.util.NamedObj actor)
          Returns a map of the values of vars contained in DataMessageComponent
static java.util.Map<java.lang.String,java.lang.String> getValues(DataMessageComponent comp, ptolemy.kernel.util.NamedObj actor)
           
static java.util.Map<java.lang.String,java.lang.String> getValues(java.util.List<DataMessageComponent> cache, java.util.Collection vars, ptolemy.kernel.util.NamedObj actor)
           
static java.util.Map<java.lang.String,java.lang.String> getValues(java.util.List<DataMessageComponent> cache, ptolemy.kernel.util.NamedObj actor)
           
static boolean isDataMessage(com.isencia.passerelle.message.ManagedMessage message)
          Return true if content is DataMessageComponent
static boolean isExpressionTrue(java.lang.String expression, DataMessageComponent comp)
          JEP evaluation based on scalar values.
static boolean isExpressionTrue(java.lang.String expression, com.isencia.passerelle.message.ManagedMessage message)
          JEP evaluation based on scalar values.
static boolean isScalarOnly(java.util.Collection<DataMessageComponent> cache)
           
static DataMessageComponent mergeAll(java.util.Collection<DataMessageComponent> cache)
           
static java.util.List<DataMessageComponent> mergeScalar(java.util.List<DataMessageComponent> cache)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageUtils

public MessageUtils()
Method Detail

coerceMessage

public static DataMessageComponent coerceMessage(com.isencia.passerelle.message.ManagedMessage message)
                                          throws java.lang.Exception
Extracts or creates a DataMessageComponent from a message

Parameters:
message -
Returns:
Throws:
java.lang.Exception

coerceMeta

public static uk.ac.diamond.scisoft.analysis.io.IMetaData coerceMeta(com.isencia.passerelle.message.ManagedMessage message)
                                                              throws java.lang.Exception
Attempts to get the IMetaData from the message if it exists. Otherwise will return an IMetaData based on the message headers.

Parameters:
message -
Returns:
Throws:
java.lang.Exception

coerceData

public static java.util.Map<java.lang.String,java.lang.Object> coerceData(com.isencia.passerelle.message.ManagedMessage message)
                                                                   throws java.lang.Exception
Method used to get data into map of data sets. Can check ManagedMessage for various content and return it has maps of Datasets or primitive arrays

Parameters:
message -
Returns:
Throws:
java.lang.Exception

getDatasets

public static java.util.List<uk.ac.diamond.scisoft.analysis.dataset.IDataset> getDatasets(java.util.List<DataMessageComponent> data)
List of all the data sets contained in the DataMessageComponent(s) Does not try and make data sets out of primitive arrays

Parameters:
data -
Returns:

getDatasets

public static java.util.List<uk.ac.diamond.scisoft.analysis.dataset.IDataset> getDatasets(DataMessageComponent comp)
List of all the data sets contained in the DataMessageComponent(s) Does not try and make data sets out of primitive arrays

Parameters:
data -
Returns:

getMeta

public static uk.ac.diamond.scisoft.analysis.io.IMetaData getMeta(java.util.List<DataMessageComponent> cache)
Attempts to determine meta data to be passed on from range of inputs. If there is only one meta in the cache then that is returned otherwise it will return null.

Parameters:
cache -
Returns:

getScalar

public static java.util.Map<java.lang.String,java.lang.String> getScalar(java.util.List<DataMessageComponent> cache)
Parameters:
cache -
Returns:

getDataMessage

public static com.isencia.passerelle.message.ManagedMessage getDataMessage(DataMessageComponent despatch)
                                                                    throws java.lang.Exception
Parameters:
despatch -
Returns:
Throws:
java.lang.Exception

getNames

public static java.lang.String getNames(java.util.Collection<uk.ac.diamond.scisoft.analysis.dataset.IDataset> sets)

getNames

public static java.lang.String getNames(uk.ac.diamond.scisoft.analysis.dataset.IDataset... sets)
Parameters:
sets -
Returns:

getValues

public static java.util.Map<java.lang.String,java.lang.String> getValues(DataMessageComponent comp,
                                                                         ptolemy.kernel.util.NamedObj actor)

getValues

public static java.util.Map<java.lang.String,java.lang.String> getValues(DataMessageComponent comp,
                                                                         java.util.Collection vars,
                                                                         ptolemy.kernel.util.NamedObj actor)
Returns a map of the values of vars contained in DataMessageComponent

Parameters:
comp -
vars - may be null in which case all are sent.
Returns:

getValues

public static java.util.Map<java.lang.String,java.lang.String> getValues(java.util.List<DataMessageComponent> cache,
                                                                         ptolemy.kernel.util.NamedObj actor)

getValues

public static java.util.Map<java.lang.String,java.lang.String> getValues(java.util.List<DataMessageComponent> cache,
                                                                         java.util.Collection vars,
                                                                         ptolemy.kernel.util.NamedObj actor)
Parameters:
cache -
keySet -
Returns:

copy

public static DataMessageComponent copy(java.util.List<DataMessageComponent> cache)

isScalarOnly

public static boolean isScalarOnly(java.util.Collection<DataMessageComponent> cache)

mergeScalar

public static java.util.List<DataMessageComponent> mergeScalar(java.util.List<DataMessageComponent> cache)

mergeAll

public static DataMessageComponent mergeAll(java.util.Collection<DataMessageComponent> cache)

isDataMessage

public static boolean isDataMessage(com.isencia.passerelle.message.ManagedMessage message)
Return true if content is DataMessageComponent

Parameters:
message -
Returns:
Throws:
com.isencia.passerelle.message.MessageException

isExpressionTrue

public static boolean isExpressionTrue(java.lang.String expression,
                                       com.isencia.passerelle.message.ManagedMessage message)
                                throws java.lang.Exception
JEP evaluation based on scalar values.

Parameters:
expression -
message -
Returns:
Throws:
com.isencia.passerelle.message.MessageException
java.lang.Exception

isExpressionTrue

public static boolean isExpressionTrue(java.lang.String expression,
                                       DataMessageComponent comp)
                                throws java.lang.Exception
JEP evaluation based on scalar values.

Parameters:
expression -
comp -
Returns:
Throws:
com.isencia.passerelle.message.MessageException
java.lang.Exception

evaluateExpression

public static double evaluateExpression(java.lang.String expression,
                                        DataMessageComponent comp)
                                 throws java.lang.Exception
JEP evaluation based on scalar values.

Parameters:
expression -
comp -
Returns:
double value of evaluation
Throws:
com.isencia.passerelle.message.MessageException
java.lang.Exception