rdr.core
Class Condition

java.lang.Object
  extended by rdr.core.Condition
All Implemented Interfaces:
java.io.Serializable

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

A single condition of a rule Comprised of an attribute, an operator (==, !=, >= etc.), and a comparison value. i.e. "attrA == 5"

Author:
Ivan Bindoff
See Also:
Serialized Form

Constructor Summary
Condition(Attribute attr, int op, int valueType, java.lang.Object value)
          Constructor.
Condition(Attribute attr, int op, Value value)
          Constructor.
Condition(Attribute attr, Operator op, int valueType, java.lang.Object value)
          Constructor.
Condition(Attribute attr, Operator op, Value value)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object c)
          Returns true if the parameter c has the same values as this object
 Attribute getAttribute()
           
 Operator getOperator()
           
 int getOperatorOpposite()
          Gets the opposite value for the operator
 int getType()
          Get the type code of this attribute's value
 Value getValue()
           
 boolean isBooleanAttributeSatisfied(Case c)
          Is the boolean attribute in case c satisfied by this condition
 boolean isNominalAttributeSatisfied(Case c)
          Is the nominal attribute in this condition satisfied by the case c TODO: method is untested.
 boolean isNumericAttributeSatisfied(Case c)
          is the numeric attribute in case c satisfied by this condition
 boolean isSatisfied(Case c)
          Check to see if a case satisfies this condition
 void setAttribute(Attribute attr)
          Set the attribute
 void setOperator(int op)
          Set the operator
 void setValue(Value comparisonValue)
          set the value of this condition
 void setValueType(int comparisonValueType)
          Sets the type of the value
 java.lang.String toString()
          Convert this condition into a readable string
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Condition

public Condition(Attribute attr,
                 int op,
                 Value value)
Constructor. To be used when you don't yet have an actual Operator object, but do have a Value.

Parameters:
attr - the attribute i.e. age
op - the operator code i.e. Operator.EQUALS
value - the comparison value i.e. 25

Condition

public Condition(Attribute attr,
                 int op,
                 int valueType,
                 java.lang.Object value)
Constructor. To be used when you don't yet have an actual Operator or Value object.

Parameters:
attr - the attribute i.e. age
op - the operator code i.e. Operator.EQUALS
valueType - the type of the comparison value i.e. Type.NUMERIC
value - the comparison value i.e. 25

Condition

public Condition(Attribute attr,
                 Operator op,
                 Value value)
Constructor. To be used when you already have constructed or know the actual Operator and Value objects.

Parameters:
attr - the attribute i.e. age
op - the actual operator object
value - the actual value object

Condition

public Condition(Attribute attr,
                 Operator op,
                 int valueType,
                 java.lang.Object value)
Constructor. To be used when you have the Operator object, but don't have a Value object.

Parameters:
attr - the attribute i.e. age
op - the actual operator
valueType - the type code of the value i.e. Type.NUMERIC
value - the value i.e. 25
Method Detail

getAttribute

public Attribute getAttribute()
Returns:
the attribute of this condition

setAttribute

public void setAttribute(Attribute attr)
Set the attribute

Parameters:
attr - the attribute to set

getOperator

public Operator getOperator()
Returns:
the operator

setOperator

public void setOperator(int op)
Set the operator

Parameters:
op - the operator code i.e. Operator.LESS_THAN

getValue

public Value getValue()
Returns:
the comparison value of this condition

setValue

public void setValue(Value comparisonValue)
set the value of this condition

Parameters:
comparisonValue - the comparison value you want

getType

public int getType()
Get the type code of this attribute's value

Returns:
type code

setValueType

public void setValueType(int comparisonValueType)
Sets the type of the value

Parameters:
comparisonValueType - the type code for the comparison value

equals

public boolean equals(java.lang.Object c)
Returns true if the parameter c has the same values as this object

Overrides:
equals in class java.lang.Object
Parameters:
c - the condition to compare against
Returns:
true if the parameter c has the same values as this object

toString

public java.lang.String toString()
Convert this condition into a readable string

Overrides:
toString in class java.lang.Object

getOperatorOpposite

public int getOperatorOpposite()
Gets the opposite value for the operator

Returns:
the opposite operator code i.e. if this condition uses == then it will return the code for !=

isSatisfied

public boolean isSatisfied(Case c)
Check to see if a case satisfies this condition

Parameters:
c - the case
Returns:
true if the case c satisfies this condition, false otherwise

isNumericAttributeSatisfied

public boolean isNumericAttributeSatisfied(Case c)
is the numeric attribute in case c satisfied by this condition

Parameters:
c - the case to check satisfaction with
Returns:
true if the case is satisfied, false otherwise

isNominalAttributeSatisfied

public boolean isNominalAttributeSatisfied(Case c)
Is the nominal attribute in this condition satisfied by the case c TODO: method is untested.

Parameters:
c - the case to test
Returns:
true if the case is satisfied, false otherwise

isBooleanAttributeSatisfied

public boolean isBooleanAttributeSatisfied(Case c)
Is the boolean attribute in case c satisfied by this condition

Parameters:
c - the case to test
Returns:
true if the case is satisfied, false otherwise