com.miginfocom.util.expression
Class LogicalExpression

java.lang.Object
  extended by com.miginfocom.util.expression.LogicalExpression
All Implemented Interfaces:
Expression, java.io.Serializable

public class LogicalExpression
extends java.lang.Object
implements Expression

A generic evaluation of something. Basically a property that relates to a value in some way and that can evaluate to true or false.

It supports a number of different operations to compare the property values with the specified value. The property value is gotten from the PropertyProvider.

The values of the different fields in the command is a loose contract between the evaluation specifier and the value provider.

See Also:
Serialized Form

Field Summary
static int EMPTY_COLLECTION
           
static int EQUALS
           
static int EQUALS_IGNORE_CASE
           
static int FIRST_IN_COLLECTION
           
static int GREATER_THAN
           
static int IN_COLLECTION
           
static int IN_CS
           
static int IS_NULL
           
static int LAST_OPER
           
static int LESS_THAN
           
static int NOT_EMPTY_COLLECTION
           
static int NOT_EQUALS
           
static int NOT_FIRST_IN_COLLECTION
           
static int NOT_IN_COLLECTION
           
 
Constructor Summary
LogicalExpression(PropertyKey property, int oper, java.lang.Object value)
          Constructor.
LogicalExpression(java.lang.String propertyName, int oper, java.lang.Object value)
          Deprecated. Only provided for backwards compatibility.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 boolean evaluate(PropertyProvider provider)
          Gets the propName value from the provider and compare that to the value provided in the constructor.
 int getOperation()
          Returns the operation to use when evaluating.
 PropertyKey getProperty()
          Returns the property to evaluate.
 java.lang.Object getValue()
          Returns the value to compare to.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALS

public static final int EQUALS
See Also:
Constant Field Values

NOT_EQUALS

public static final int NOT_EQUALS
See Also:
Constant Field Values

EQUALS_IGNORE_CASE

public static final int EQUALS_IGNORE_CASE
See Also:
Constant Field Values

IN_CS

public static final int IN_CS
See Also:
Constant Field Values

GREATER_THAN

public static final int GREATER_THAN
See Also:
Constant Field Values

LESS_THAN

public static final int LESS_THAN
See Also:
Constant Field Values

IS_NULL

public static final int IS_NULL
See Also:
Constant Field Values

IN_COLLECTION

public static final int IN_COLLECTION
See Also:
Constant Field Values

NOT_IN_COLLECTION

public static final int NOT_IN_COLLECTION
See Also:
Constant Field Values

FIRST_IN_COLLECTION

public static final int FIRST_IN_COLLECTION
See Also:
Constant Field Values

NOT_FIRST_IN_COLLECTION

public static final int NOT_FIRST_IN_COLLECTION
See Also:
Constant Field Values

EMPTY_COLLECTION

public static final int EMPTY_COLLECTION
See Also:
Constant Field Values

NOT_EMPTY_COLLECTION

public static final int NOT_EMPTY_COLLECTION
See Also:
Constant Field Values

LAST_OPER

public static final int LAST_OPER
See Also:
Constant Field Values
Constructor Detail

LogicalExpression

public LogicalExpression(java.lang.String propertyName,
                         int oper,
                         java.lang.Object value)
Deprecated. Only provided for backwards compatibility.

Constructor.


LogicalExpression

public LogicalExpression(PropertyKey property,
                         int oper,
                         java.lang.Object value)
Constructor.

Parameters:
property - The property to evaluate. This name is used to get the value to compare value to. Not null.
oper - The operation to use when evaluating. E.g. EQUALS. Not null.
value - The value to compare to. May be anything, including null.
Method Detail

evaluate

public boolean evaluate(PropertyProvider provider)
Gets the propName value from the provider and compare that to the value provided in the constructor.

Specified by:
evaluate in interface Expression
Parameters:
provider - The provider that returns the value of the propName specified in the constructor.
Returns:
If the value returned from the provider relates to the value provided in the constructor in the way that oper specifies. Something like:
provider.getProperty(propName).equals(value) for oper LogicalExpression.EQUALS.

getProperty

public PropertyKey getProperty()
Returns the property to evaluate. This name is used to get the value to compare value to.

Returns:
The name of the property to evaluate.

getOperation

public int getOperation()
Returns the operation to use when evaluating.

Returns:
The operation to use when evaluating. E.g. EQUALS

getValue

public java.lang.Object getValue()
Returns the value to compare to.

Returns:
The value to compare to.

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.