public class ExpressionManager
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ACTION_NEW_TRISTATE
Action to filter on with a broadcast receiver that indicates the arrival
of a new tristate for a
TristateExpression. |
static java.lang.String |
ACTION_NEW_VALUES
Action to filter on with a broadcast receiver that indicates the arrival
of new values for a
ValueExpression. |
static java.lang.String |
ACTION_REGISTER
Action to be used to register an
Expression with an
Intent. |
static java.lang.String |
ACTION_UNREGISTER
Action to be used to unregister an
Expression with an
Intent. |
static java.lang.String |
EXTRA_INTENT_TYPE
The extra key that can be used with
registerExpression(Context, String, Expression, Intent, Intent, Intent, Intent)
intents to indicate what type the intents are. |
static java.lang.String |
EXTRA_NEW_TRISTATE
The extra key that contains the new
TriState. |
static java.lang.String |
EXTRA_NEW_TRISTATE_TIMESTAMP
The extra key that contains the timestamp of when the evaluation
resulting in the
TriState happened. |
static java.lang.String |
EXTRA_NEW_VALUES
The extra key that contains the Parcelable[] with the new
TimestampedValues. |
static java.lang.String |
INTENT_TYPE_ACTIVITY
Extra value for key
EXTRA_INTENT_TYPE that indicates that the
intent should start an activity |
static java.lang.String |
INTENT_TYPE_BROADCAST
Extra value for key
EXTRA_INTENT_TYPE that indicates that the
intent should be broadcast |
static java.lang.String |
INTENT_TYPE_SERVICE
Extra value for key
EXTRA_INTENT_TYPE that indicates that the
intent should start a service |
| Constructor and Description |
|---|
ExpressionManager() |
| Modifier and Type | Method and Description |
|---|---|
static SensorInfo |
getSensor(android.content.Context context,
java.lang.String name)
Returns the information about a sensor with a specific name or throws a
SwanException if the sensor is not installed on the device. |
static java.util.List<SensorInfo> |
getSensors(android.content.Context context)
Returns all the information about the sensors known to SWAN.
|
static void |
registerExpression(android.content.Context context,
java.lang.String id,
Expression expression,
ExpressionListener expressionListener)
Registers an
Expression for evaluation. |
static void |
registerTriStateExpression(android.content.Context context,
java.lang.String id,
TriStateExpression expression,
android.content.Intent onTrue,
android.content.Intent onFalse,
android.content.Intent onUndefined)
Registers a
TriStateExpression for evaluation. |
static void |
registerTriStateExpression(android.content.Context context,
java.lang.String id,
TriStateExpression expression,
TriStateExpressionListener listener)
Registers a
TriStateExpression for evaluation. |
static void |
registerValueExpression(android.content.Context context,
java.lang.String id,
TriStateExpression expression,
android.content.Intent onNewValues)
Registers a
ValueExpression for evaluation. |
static void |
registerValueExpression(android.content.Context context,
java.lang.String id,
ValueExpression expression,
ValueExpressionListener listener)
Registers a
ValueExpression for evaluation. |
static void |
unregisterExpression(android.content.Context context,
java.lang.String id)
Unregisters a previously registered
Expression for evaluation. |
public static final java.lang.String ACTION_REGISTER
Expression with an
Intent. Registration should preferably be done with the
registerExpression(Context, String, Expression, ExpressionListener)
,
registerTriStateExpression(Context, String, TriStateExpression, TriStateExpressionListener)
,
registerValueExpression(Context, String, ValueExpression, ValueExpressionListener)
convenience methods.public static final java.lang.String ACTION_UNREGISTER
Expression with an
Intent. Unregistration should preferably be done with the
unregisterExpression(Context, String) convenience method.public static final java.lang.String ACTION_NEW_VALUES
ValueExpression. The
ValueExpressionListener already listens to these broadcasts and
forwards them to the listener.public static final java.lang.String ACTION_NEW_TRISTATE
TristateExpression. The
TristateExpressionListener already listens to these broadcasts
and forwards them to the listener.public static final java.lang.String EXTRA_NEW_VALUES
TimestampedValues. Cast the array items one by one, rather than
the entire array, since this will throw a ClassCastException.public static final java.lang.String EXTRA_NEW_TRISTATE
TriState.public static final java.lang.String EXTRA_NEW_TRISTATE_TIMESTAMP
TriState happened.public static final java.lang.String EXTRA_INTENT_TYPE
registerExpression(Context, String, Expression, Intent, Intent, Intent, Intent)
intents to indicate what type the intents are. Possible values are
INTENT_TYPE_ACTIVITY, INTENT_TYPE_BROADCAST (default),
INTENT_TYPE_SERVICE.public static final java.lang.String INTENT_TYPE_BROADCAST
EXTRA_INTENT_TYPE that indicates that the
intent should be broadcastpublic static final java.lang.String INTENT_TYPE_ACTIVITY
EXTRA_INTENT_TYPE that indicates that the
intent should start an activitypublic static final java.lang.String INTENT_TYPE_SERVICE
EXTRA_INTENT_TYPE that indicates that the
intent should start a servicepublic static java.util.List<SensorInfo> getSensors(android.content.Context context)
context - public static SensorInfo getSensor(android.content.Context context, java.lang.String name) throws SwanException
SwanException if the sensor is not installed on the device.context - name - the entity name of the sensorSwanExceptionpublic static void registerTriStateExpression(android.content.Context context,
java.lang.String id,
TriStateExpression expression,
TriStateExpressionListener listener)
throws SwanException
TriStateExpression for evaluation.context - id - the user provided unique id of the expression. Should not
contain Expression#SEPARATOR or end with any of the
Expression#RESERVED_SUFFIXES.expression - the TriStateExpression that should be evaluatedlistener - a TriStateExpressionListener that receives the
evaluation results. If this parameter is null, it is also
possible to listen for the results using a
BroadcastReceiver. Filter on datascheme
"swan://ACTION_NEW_TRISTATE.SwanException - if id is null or invalidpublic static void registerValueExpression(android.content.Context context,
java.lang.String id,
ValueExpression expression,
ValueExpressionListener listener)
throws SwanException
ValueExpression for evaluation.context - id - the user provided unique id of the expression. Should not
contain Expression#SEPARATOR or end with any of the
Expression#RESERVED_SUFFIXES.expression - the ValueExpression that should be evaluatedlistener - a ValueExpressionListener that receives the evaluation
results. If this parameter is null, it is also possible to
listen for the results using a BroadcastReceiver.
Filter on datascheme
"swan://ACTION_NEW_VALUES.SwanException - if id is null or invalidpublic static void registerExpression(android.content.Context context,
java.lang.String id,
Expression expression,
ExpressionListener expressionListener)
throws SwanException
Expression for evaluation.context - id - the user provided unique id of the expression. Should not
contain Expression#SEPARATOR or end with any of the
Expression#RESERVED_SUFFIXES.expression - the ValueExpression that should be evaluatedlistener - a ValueExpressionListener that receives the evaluation
results. If this parameter is null, it is also possible to
listen for the results using a BroadcastReceiver.
Filter on datascheme
"swan://ACTION_NEW_VALUES or ACTION_NEW_TRISTATE.SwanException - if id is null or invalidpublic static void registerTriStateExpression(android.content.Context context,
java.lang.String id,
TriStateExpression expression,
android.content.Intent onTrue,
android.content.Intent onFalse,
android.content.Intent onUndefined)
TriStateExpression for evaluation.context - id - the user provided unique id of the expression. Should not
contain Expression#SEPARATOR or end with any of the
Expression#RESERVED_SUFFIXES.expression - the TriStateExpression that should be evaluatedonTrue - Intent that should be fired when state changes to true. By
default the Intent is used to send a broadcast. Add
EXTRA_INTENT_TYPE with any of the values
INTENT_TYPE_ACTIVITY, INTENT_TYPE_SERVICE to
have Swan launch an activity or service.onFalse - Intent that should be fired when state changes to false. By
default the Intent is used to send a broadcast. Add
EXTRA_INTENT_TYPE with any of the values
INTENT_TYPE_ACTIVITY, INTENT_TYPE_SERVICE to
have Swan launch an activity or service.onUndefined - Intent that should be fired when state changes to undefined.
By default the Intent is used to send a broadcast. Add
EXTRA_INTENT_TYPE with any of the values
INTENT_TYPE_ACTIVITY, INTENT_TYPE_SERVICE to
have Swan launch an activity or service.public static void registerValueExpression(android.content.Context context,
java.lang.String id,
TriStateExpression expression,
android.content.Intent onNewValues)
ValueExpression for evaluation.context - id - the user provided unique id of the expression. Should not
contain Expression#SEPARATOR or end with any of the
Expression#RESERVED_SUFFIXES.expression - the ValueExpression that should be evaluatedonNewValues - Intent that should be fired when new values are available. Add
EXTRA_INTENT_TYPE with any of the values
INTENT_TYPE_ACTIVITY, INTENT_TYPE_SERVICE to
have Swan launch an activity or service.public static void unregisterExpression(android.content.Context context,
java.lang.String id)
Expression for evaluation.context - id - the id with which the expression was registered.