Mobile Sensor API Version 1.2

javax.microedition.sensor
Class LimitCondition

java.lang.Object
  extended by javax.microedition.sensor.LimitCondition
All Implemented Interfaces:
Condition

public final class LimitCondition
extends java.lang.Object
implements Condition

LimitCondition is a Condition intended for numeric data to set various kind of conditions. The operator has an important role in defining the LimitCondition. The meaning of the LimitCondition can change totally by changing the operator, for example, from OP_LESS_THAN to OP_GREATER_THAN.

One of the following operators must be used:

  1. Condition.OP_EQUALS - equals
  2. Condition.OP_LESS_THAN_OR_EQUALS - less than or equals
  3. Condition.OP_LESS_THAN - less than
  4. Condition.OP_GREATER_THAN - greater than
  5. Condition.OP_GREATER_THAN_OR_EQUALS - greater than or equals

Examples of setting LimitCondition objects, where temperature and pitch are Channel objects.

 temperature.addCondition(listener,
      new LimitCondition(50,Condition.GREATER_THAN));
 

Temperatures over 50 degrees are being notified. The unit of the degree can be discovered by obtaining the ChannelInfo object and using the ChannelInfo.getUnit() method.

 pitch.addCondition(listener,
      new LimitCondition(-45, Condition.LESS_THAN));
 pitch.addCondition(listener,
      new LimitCondition(45, Condition.GREATER_THAN));

The ConditionListener of pitch will be notified when value is < -45 or > 45.

If the Channel, where this Condition is to be set, uses scaling, the limit values should be given in the scaled format. See method ChannelInfo.getScale() for more details.

LimitCondition MUST be immutable.


Field Summary
 
Fields inherited from interface javax.microedition.sensor.Condition
OP_EQUALS, OP_GREATER_THAN, OP_GREATER_THAN_OR_EQUALS, OP_LESS_THAN, OP_LESS_THAN_OR_EQUALS
 
Constructor Summary
LimitCondition(double limit, java.lang.String operator)
          The constructor for creating a new LimitCondition object instance.
 
Method Summary
 double getLimit()
          Returns the limit set in the constructor.
 java.lang.String getOperator()
          Returns the comparison operator of the LimitCondition set in the constructor.
 boolean isMet(double value)
          Method tests if the value parameter meets the condition.
 boolean isMet(java.lang.Object value)
          Method tests if the value given as a parameter meets the condition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LimitCondition

public LimitCondition(double limit,
                      java.lang.String operator)

The constructor for creating a new LimitCondition object instance.

Parameters:
limit - the limit value to be set
operator - the operator defining the type of the condition
Throws:
java.lang.NullPointerException - if the operator is null
java.lang.IllegalArgumentException - if the operator is none of the operators listed in the class Condition
Method Detail

getLimit

public final double getLimit()

Returns the limit set in the constructor.

Returns:
the limit

getOperator

public final java.lang.String getOperator()

Returns the comparison operator of the LimitCondition set in the constructor.

Returns:
the comparison operator

isMet

public boolean isMet(double value)

Method tests if the value parameter meets the condition.

Specified by:
isMet in interface Condition
Parameters:
value - measured data value that is checked
Returns:
true if Condition is met, false otherwise

isMet

public boolean isMet(java.lang.Object value)

Method tests if the value given as a parameter meets the condition.

Specified by:
isMet in interface Condition
Parameters:
value - the measured data value as Object that is checked
Returns:
false always, for Objects ObjectCondition should be used

Mobile Sensor API Version 1.2

Copyright © 2005-2008 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.