Mobile Sensor API Version 1.2

javax.microedition.sensor
Class RangeCondition

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

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

RangeCondition checks if the measured data value is within the defined range. RangeCondition encapsulates information about the range, i.e., the lower and the upper limit, and the operators for both ends. Four types of ranges can be defined with the operators:

  1. open range, (lowerLimit, upperLimit)
  2. closed range, [lowerLimit, upperLimit]
  3. half-closed half-open range, [lowerLimit, upperLimit)
  4. half-open half-closed range, (lowerLimit, upperLimit]

The construction of the corresponding RangeCondition objects is displayed below:

  1. new RangeCondition(lowerLimit, Condition.OP_GREATER_THAN,
          upperLimit, Condition.OP_LESS_THAN);
    ConditionListener will be notified when
    lowerLimit < value < upperLimit 
  2. new RangeCondition(lowerLimit, Condition.OP_GREATER_THAN_OR_EQUALS,
             upperLimit, Condition.OP_LESS_THAN_OR_EQUALS);
    ConditionListener will be notified when
    lowerLimit <= value <= upperLimit
  3. new RangeCondition(lowerLimit, Condition.OP_GREATER_THAN_OR_EQUALS,
          upperLimit, Condition.OP_LESS_THAN);
    ConditionListener will be notified when
    lowerLimit <= value < upperLimit
  4. new RangeCondition(lowerLimit, Condition.OP_GREATER_THAN,
          upperLimit, Condition.OP_LESS_THAN_OR_EQUALS);
    ConditionListener will be notified when
    lowerLimit < value <= upperLimit

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

RangeCondition 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
RangeCondition(double lowerLimit, java.lang.String lowerOp, double upperLimit, java.lang.String upperOp)
          The constructor of RangeCondition object.
 
Method Summary
 double getLowerLimit()
          Returns the lower limit of the monitored range, which is the same value as that set in the constructor.
 java.lang.String getLowerOp()
          Returns the operator checking the lower limit, which is the same value as that set in the constructor.
 double getUpperLimit()
          Returns the upper limit of the monitored range, which is the same value as that set in the constructor.
 java.lang.String getUpperOp()
          Returns operator checking the upper limit, which is the same value as that set in the constructor.
 boolean isMet(double doubleValue)
          The method tests if the doubleValue given as a parameter is within the given range.
 boolean isMet(java.lang.Object value)
          The method tests if the value given as a parameter is within the given range.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RangeCondition

public RangeCondition(double lowerLimit,
                      java.lang.String lowerOp,
                      double upperLimit,
                      java.lang.String upperOp)

The constructor of RangeCondition object. Valid values for lowerOp are:

Invalid combinationsx are:

  1. lowerLimit > upperLimit
  2. if lowerLimit == upperLimit but not (lowerOp==OP_GREATER_THAN_OR_EQUALS and upperOp==OP_LESS_THAN_OR_EQUALS)
  3. lowerOp/upperOp are not valid values

Parameters:
lowerLimit - the lower limit of the range
lowerOp - the comparison operator used to check the measured value against lower limit of the range.
upperLimit - the upper limit of the range
upperOp - the comparison operator used to check the measured value against the upper limit of the range.
Throws:
java.lang.IllegalArgumentException - if either the limits or operators are not valid, see above.
Method Detail

getLowerLimit

public final double getLowerLimit()

Returns the lower limit of the monitored range, which is the same value as that set in the constructor.

Returns:
the lower limit of the range

getLowerOp

public final java.lang.String getLowerOp()

Returns the operator checking the lower limit, which is the same value as that set in the constructor.

Returns:
the lower limit operator, either

getUpperLimit

public final double getUpperLimit()

Returns the upper limit of the monitored range, which is the same value as that set in the constructor.

Returns:
the upper limit of the range

getUpperOp

public final java.lang.String getUpperOp()

Returns operator checking the upper limit, which is the same value as that set in the constructor.

Returns:
the upper limit operator, either

isMet

public boolean isMet(double doubleValue)

The method tests if the doubleValue given as a parameter is within the given range.

Specified by:
isMet in interface Condition
Parameters:
doubleValue - the measured data value, which is checked against this RangeCondition object
Returns:
true if the RangeCondition is met, false otherwise

isMet

public boolean isMet(java.lang.Object value)

The method tests if the value given as a parameter is within the given range.

Specified by:
isMet in interface Condition
Parameters:
value - the measured data value as Object, which is checked against the condition
Returns:
false always. The ObjectCondition is the Condition to be used with the Object data type.

Mobile Sensor API Version 1.2

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