moteaccess
Class Condition

java.lang.Object
  extended bymoteaccess.Condition
All Implemented Interfaces:
java.io.Serializable

public class Condition
extends java.lang.Object
implements java.io.Serializable

Class representing a range condition on a sensor reading. Used in conjunction with the MoteReaction class to describe the conditions under which a reaction fires.

Version:
1.0
Author:
Carlo Curino, Matteo Giani, Marco Giorgetta, Alessandro Giusti
See Also:
Serialized Form

Field Summary
static int ANY
          Constant that indicates the unspecified operation.
static int BETWEEN
          Constant that indicates the between operation.
static int EQUAL_TO
          Constant that indicates the equal to operation.
static int GREATER_THAN
          Constant that indicates the greater than operation.
static int LESS_THAN
          Constant that indicates the less than operation.
private  int lower
          Lower bound of a between operation.
private  int type
          Int value that indicates the type of the instantiation's operation.
private  int upper
          Upper bound of a between operation.
 
Constructor Summary
Condition()
          Public constructor for an unspecified condition.
Condition(int type, int lower, int upper)
          Public constructor that builds a condition from the type, lower bound and upper bound.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 int getLower()
          Getter for the lower attribute.
 int getType()
          Getter for the type attribute.
 int getUpper()
          Getter for the upper attribute.
 int hashCode()
          The hashCode function is implemented to return the type of the condition.
 java.lang.String toReadableString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LESS_THAN

public static final int LESS_THAN
Constant that indicates the less than operation.

See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
Constant that indicates the greater than operation.

See Also:
Constant Field Values

EQUAL_TO

public static final int EQUAL_TO
Constant that indicates the equal to operation.

See Also:
Constant Field Values

BETWEEN

public static final int BETWEEN
Constant that indicates the between operation.

See Also:
Constant Field Values

ANY

public static final int ANY
Constant that indicates the unspecified operation.

See Also:
Constant Field Values

type

private int type
Int value that indicates the type of the instantiation's operation.


lower

private int lower
Lower bound of a between operation.


upper

private int upper
Upper bound of a between operation.

Constructor Detail

Condition

public Condition(int type,
                 int lower,
                 int upper)
Public constructor that builds a condition from the type, lower bound and upper bound.

Parameters:
type - the type of the condition.
lower - the lower bound; not used if it's a less than
upper - the upper bound of the condition; not used if it's a greater than.

Condition

public Condition()
Public constructor for an unspecified condition.

Method Detail

equals

public boolean equals(java.lang.Object o)

getType

public int getType()
Getter for the type attribute.

Returns:
the type attribute's value.

getUpper

public int getUpper()
Getter for the upper attribute.

Returns:
the upper attribute's value.

getLower

public int getLower()
Getter for the lower attribute.

Returns:
the lower attribute's value.

hashCode

public int hashCode()
The hashCode function is implemented to return the type of the condition. It returns the same value in case of two different conditions that have the same type (e.g. greater than 500 and greater than 200), but the equals method is precise enough so that the matching will be correct.


toReadableString

public java.lang.String toReadableString()