org.epics.pvmanager
Class ExpressionLanguage

java.lang.Object
  extended by org.epics.pvmanager.ExpressionLanguage

public class ExpressionLanguage
extends java.lang.Object

Operators to constructs expression of PVs that the PVManager will be able to monitor.

Author:
carcassi

Nested Class Summary
static class ExpressionLanguage.Filter<T>
          Filters a data stream, removing updates that match the given function.
static interface ExpressionLanguage.OneArgFunction<R,A>
          A user provided single argument function.
static interface ExpressionLanguage.TwoArgFunction<R,A1,A2>
          A user provided double argument function.
 
Method Summary
static ChannelExpression<java.lang.Object,java.lang.Object> channel(java.lang.String name)
          A channel with the given name of any type.
static
<R,W> ChannelExpression<R,W>
channel(java.lang.String name, java.lang.Class<R> readType, java.lang.Class<W> writeType)
          A channel with the given name and type.
static ChannelExpressionList<java.lang.Object,java.lang.Object> channels(java.util.Collection<java.lang.String> names)
          A list of channels with the given names of any type.
static
<R,W> ChannelExpressionList<R,W>
channels(java.util.Collection<java.lang.String> names, java.lang.Class<R> readType, java.lang.Class<W> writeType)
          A list of channels with the given names and type.
static ChannelExpressionList<java.lang.Object,java.lang.Object> channels(java.lang.String... names)
          A list of channels with the given names of any type.
static
<T> DesiredRateExpression<T>
constant(T value)
          Creates a constant expression that always return that object.
static
<T> DesiredRateExpression<T>
constant(T value, java.lang.String name)
          Creates a constant expression that always return that object, with the given name for the expression.
static
<T> DesiredRateExpression<java.util.List<T>>
filterBy(ExpressionLanguage.Filter<?> filter, DesiredRateExpression<java.util.List<T>> expression)
          Filters a stream of updates with the given filter.
static
<T> DesiredRateExpression<T>
latestValueOf(SourceRateExpression<T> expression)
          Expression that returns (only) the latest value computed from a SourceRateExpression.
static
<T> DesiredRateExpressionList<T>
latestValueOf(SourceRateExpressionList<T> expressions)
          Expression that returns (only) the latest value computed from a SourceRateExpression.
static
<R,W> DesiredRateReadWriteExpression<R,W>
latestValueOf(SourceRateReadWriteExpression<R,W> expression)
          For reads, returns (only) the latest value computed from a SourceRateReadWriteExpression; for writes, same as the given expression.
static
<R,W> DesiredRateReadWriteExpressionList<R,W>
latestValueOf(SourceRateReadWriteExpressionList<R,W> expressions)
          For reads, returns (only) the latest value computed from a SourceRateReadWriteExpression; for writes, same as the given expression.
static
<T> DesiredRateExpression<java.util.List<T>>
listOf(DesiredRateExpressionList<T> expressions)
          Converts a list of expressions to an expression that returns the list of results.
static
<T> DesiredRateExpression<java.util.Map<java.lang.String,T>>
mapOf(DesiredRateExpressionList<T> expressions)
          Converts a list of expressions to an expression that returns the map from the name to the results.
static
<R,W> DesiredRateReadWriteExpression<java.util.Map<java.lang.String,R>,java.util.Map<java.lang.String,W>>
mapOf(DesiredRateReadWriteExpressionList<R,W> expressions)
          Converts a list of expressions to an expression that returns the map from the name to the results.
static
<T> WriteExpression<java.util.Map<java.lang.String,T>>
mapOf(WriteExpressionList<T> expressions)
          Converts a list of expressions to an expression that returns the map from the name to the results.
static
<T> DesiredRateExpression<java.util.List<T>>
newValuesOf(SourceRateExpression<T> expression)
          Returns all the new values generated by the expression source rate.
static
<T> DesiredRateExpression<java.util.List<T>>
newValuesOf(SourceRateExpression<T> expression, int maxValues)
          Returns up to maxValues new values generated by the expression source rate.
static
<T> DesiredRateExpressionList<java.util.List<T>>
newValuesOf(SourceRateExpressionList<T> expressions)
          Returns all the new values generated by the expression source rate.
static
<R,A> DesiredRateExpression<R>
resultOf(ExpressionLanguage.OneArgFunction<R,A> function, DesiredRateExpression<A> argExpression)
          An expression that represents the result of a user provided function.
static
<R,A1,A2> DesiredRateExpression<R>
resultOf(ExpressionLanguage.TwoArgFunction<R,A1,A2> function, DesiredRateExpression<? extends A1> arg1Expression, DesiredRateExpression<? extends A2> arg2Expression)
          An expression that represents the result of a user provided function.
static
<R,A1,A2> DesiredRateExpression<R>
resultOf(ExpressionLanguage.TwoArgFunction<R,A1,A2> function, DesiredRateExpression<? extends A1> arg1Expression, DesiredRateExpression<? extends A2> arg2Expression, java.lang.String name)
          An expression that represents the result of a user provided function.
static
<T> DesiredRateExpression<java.util.List<T>>
timedCacheOf(SourceRateExpression<T> expression, TimeDuration maxIntervalBetweenSamples)
          Returns all the values starting the latest value and older up to the time different given by the interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

constant

public static <T> DesiredRateExpression<T> constant(T value)
Creates a constant expression that always return that object. This is useful to test expressions or to introduce data that is available at connection time at that will not change.

Type Parameters:
T - type of the value
Parameters:
value - the actual value
Returns:
an expression that is always going to return the given value

constant

public static <T> DesiredRateExpression<T> constant(T value,
                                                    java.lang.String name)
Creates a constant expression that always return that object, with the given name for the expression. This is useful to test expressions or to introduce data that is available at connection time at that will not change.

Type Parameters:
T - type of the value
Parameters:
value - the actual value
name - the name of the expression
Returns:
an expression that is always going to return the given value

channel

public static ChannelExpression<java.lang.Object,java.lang.Object> channel(java.lang.String name)
A channel with the given name of any type. This expression can be used both in a read and a write expression.

Parameters:
name - the channel name
Returns:
an expression representing the channel

channel

public static <R,W> ChannelExpression<R,W> channel(java.lang.String name,
                                                   java.lang.Class<R> readType,
                                                   java.lang.Class<W> writeType)
A channel with the given name and type. This expression can be used both in a read and a write expression.

Type Parameters:
R - read payload
W - write payload
Parameters:
name - the channel name
readType - type being read
writeType - type being written
Returns:
an expression representing the channel

channels

public static ChannelExpressionList<java.lang.Object,java.lang.Object> channels(java.lang.String... names)
A list of channels with the given names of any type. This expression can be used both in a read and a write expression.

Parameters:
names - the channel names; can't be null
Returns:
an list of expressions representing the channels

channels

public static <R,W> ChannelExpressionList<R,W> channels(java.util.Collection<java.lang.String> names,
                                                        java.lang.Class<R> readType,
                                                        java.lang.Class<W> writeType)
A list of channels with the given names and type. This expression can be used both in a read and a write expression.

Type Parameters:
R - read payload
W - write payload
Parameters:
readType - type being read
writeType - type being written
names - the channel names; can't be null
Returns:
an list of expressions representing the channels

channels

public static ChannelExpressionList<java.lang.Object,java.lang.Object> channels(java.util.Collection<java.lang.String> names)
A list of channels with the given names of any type. This expression can be used both in a read and a write expression.

Parameters:
names - the channel names; can't be null
Returns:
an list of expressions representing the channels

newValuesOf

public static <T> DesiredRateExpressionList<java.util.List<T>> newValuesOf(SourceRateExpressionList<T> expressions)
Returns all the new values generated by the expression source rate.

Type Parameters:
T - type being read
Parameters:
expressions - source rate expressions
Returns:
a new expression

newValuesOf

public static <T> DesiredRateExpression<java.util.List<T>> newValuesOf(SourceRateExpression<T> expression)
Returns all the new values generated by the expression source rate.

Type Parameters:
T - type being read
Parameters:
expression - source rate expression
Returns:
a new expression

newValuesOf

public static <T> DesiredRateExpression<java.util.List<T>> newValuesOf(SourceRateExpression<T> expression,
                                                                       int maxValues)
Returns up to maxValues new values generated by the expression source rate.

Type Parameters:
T - type being read
Parameters:
expression - source rate expression
maxValues - maximum number of values to send with each notification
Returns:
a new expression

timedCacheOf

public static <T> DesiredRateExpression<java.util.List<T>> timedCacheOf(SourceRateExpression<T> expression,
                                                                        TimeDuration maxIntervalBetweenSamples)
Returns all the values starting the latest value and older up to the time different given by the interval.

Type Parameters:
T - type being read
Parameters:
expression - expression to read
maxIntervalBetweenSamples - maximum time difference between values
Returns:
a new expression

latestValueOf

public static <T> DesiredRateExpression<T> latestValueOf(SourceRateExpression<T> expression)
Expression that returns (only) the latest value computed from a SourceRateExpression.

Type Parameters:
T - type being read
Parameters:
expression - expression read at the source rate
Returns:
a new expression

latestValueOf

public static <T> DesiredRateExpressionList<T> latestValueOf(SourceRateExpressionList<T> expressions)
Expression that returns (only) the latest value computed from a SourceRateExpression.

Type Parameters:
T - type being read
Parameters:
expressions - expressions read at the source rate
Returns:
an expression list

latestValueOf

public static <R,W> DesiredRateReadWriteExpression<R,W> latestValueOf(SourceRateReadWriteExpression<R,W> expression)
For reads, returns (only) the latest value computed from a SourceRateReadWriteExpression; for writes, same as the given expression.

Type Parameters:
R - read payload
W - write payload
Parameters:
expression - expression read at the source rate
Returns:
a new expression

latestValueOf

public static <R,W> DesiredRateReadWriteExpressionList<R,W> latestValueOf(SourceRateReadWriteExpressionList<R,W> expressions)
For reads, returns (only) the latest value computed from a SourceRateReadWriteExpression; for writes, same as the given expression.

Type Parameters:
R - read payload
W - write payload
Parameters:
expressions - expressions read at the source rate
Returns:
a new expression

resultOf

public static <R,A> DesiredRateExpression<R> resultOf(ExpressionLanguage.OneArgFunction<R,A> function,
                                                      DesiredRateExpression<A> argExpression)
An expression that represents the result of a user provided function.

Type Parameters:
R - result type
A - argument type
Parameters:
function - the user provided function
argExpression - expression for the function argument
Returns:
a new expression

resultOf

public static <R,A1,A2> DesiredRateExpression<R> resultOf(ExpressionLanguage.TwoArgFunction<R,A1,A2> function,
                                                          DesiredRateExpression<? extends A1> arg1Expression,
                                                          DesiredRateExpression<? extends A2> arg2Expression)
An expression that represents the result of a user provided function.

Type Parameters:
R - result type
A1 - first argument type
A2 - second argument type
Parameters:
function - the user provided function
arg1Expression - expression for the first argument
arg2Expression - expression for the second argument
Returns:
a new expression

resultOf

public static <R,A1,A2> DesiredRateExpression<R> resultOf(ExpressionLanguage.TwoArgFunction<R,A1,A2> function,
                                                          DesiredRateExpression<? extends A1> arg1Expression,
                                                          DesiredRateExpression<? extends A2> arg2Expression,
                                                          java.lang.String name)
An expression that represents the result of a user provided function.

Type Parameters:
R - result type
A1 - first argument type
A2 - second argument type
Parameters:
function - the user provided function
arg1Expression - expression for the first argument
arg2Expression - expression for the second argument
name - expression name
Returns:
a new expression

filterBy

public static <T> DesiredRateExpression<java.util.List<T>> filterBy(ExpressionLanguage.Filter<?> filter,
                                                                    DesiredRateExpression<java.util.List<T>> expression)
Filters a stream of updates with the given filter.

Type Parameters:
T - the type of data streaming in and out
Parameters:
filter - the filtering function
expression - the argument expression
Returns:
a new expression for the filtering result

listOf

public static <T> DesiredRateExpression<java.util.List<T>> listOf(DesiredRateExpressionList<T> expressions)
Converts a list of expressions to an expression that returns the list of results.

Type Parameters:
T - type being read
Parameters:
expressions - a list of expressions
Returns:
an expression representing the list of results

mapOf

public static <T> DesiredRateExpression<java.util.Map<java.lang.String,T>> mapOf(DesiredRateExpressionList<T> expressions)
Converts a list of expressions to an expression that returns the map from the name to the results.

Type Parameters:
T - type being read
Parameters:
expressions - a list of expressions
Returns:
an expression representing a map from name to results

mapOf

public static <T> WriteExpression<java.util.Map<java.lang.String,T>> mapOf(WriteExpressionList<T> expressions)
Converts a list of expressions to an expression that returns the map from the name to the results.

Type Parameters:
T - type being read
Parameters:
expressions - a list of expressions
Returns:
an expression representing a map from name to results

mapOf

public static <R,W> DesiredRateReadWriteExpression<java.util.Map<java.lang.String,R>,java.util.Map<java.lang.String,W>> mapOf(DesiredRateReadWriteExpressionList<R,W> expressions)
Converts a list of expressions to an expression that returns the map from the name to the results.

Type Parameters:
R - read payload
W - write payload
Parameters:
expressions - a list of expressions
Returns:
an expression representing a map from name to results