net.sf.mpxj
Enum TestOperator

java.lang.Object
  extended by java.lang.Enum<TestOperator>
      extended by net.sf.mpxj.TestOperator
All Implemented Interfaces:
Serializable, Comparable<TestOperator>, MpxjEnum

public enum TestOperator
extends Enum<TestOperator>
implements MpxjEnum

This class represents the set of operators used to perform a test between two or more operands.


Enum Constant Summary
AND
           
CONTAINS
           
CONTAINS_EXACTLY
           
DOES_NOT_CONTAIN
           
DOES_NOT_EQUAL
           
EQUALS
           
IS_ANY_VALUE
           
IS_GREATER_THAN
           
IS_GREATER_THAN_OR_EQUAL_TO
           
IS_LESS_THAN
           
IS_LESS_THAN_OR_EQUAL_TO
           
IS_NOT_WITHIN
           
IS_WITHIN
           
OR
           
 
Method Summary
abstract  boolean evaluate(Object lhs, Object rhs)
          This method applies the operator represented by this class to the supplied operands.
protected  int evaluateCompareTo(Object lhs, Object rhs)
          Implements a simple compare-to operation.
protected  boolean evaluateContains(Object lhs, Object rhs)
          Assuming the supplied arguments are both Strings, this method determines if rhs is contained within lhs.
protected  boolean evaluateContainsExactly(Object lhs, Object rhs)
          Assuming the supplied arguments are both Strings, this method determines if rhs is contained within lhs.
protected  boolean evaluateWithin(Object lhs, Object rhs)
          Determine if the supplied value falls within the specified range.
static TestOperator getInstance(int type)
          Retrieve an instance of the enum based on its int value.
static TestOperator getInstance(Number type)
          Retrieve an instance of the enum based on its int value.
protected  Object getSingleOperand(Object operand)
          This method is used to ensure that if a list of operand values has been supplied, that a single operand is extracted.
 int getValue()
          Accessor method used to retrieve the numeric representation of the enum.
static TestOperator valueOf(String name)
          Returns the enum constant of this type with the specified name.
static TestOperator[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

IS_ANY_VALUE

public static final TestOperator IS_ANY_VALUE

IS_WITHIN

public static final TestOperator IS_WITHIN

IS_GREATER_THAN

public static final TestOperator IS_GREATER_THAN

IS_LESS_THAN

public static final TestOperator IS_LESS_THAN

IS_GREATER_THAN_OR_EQUAL_TO

public static final TestOperator IS_GREATER_THAN_OR_EQUAL_TO

IS_LESS_THAN_OR_EQUAL_TO

public static final TestOperator IS_LESS_THAN_OR_EQUAL_TO

EQUALS

public static final TestOperator EQUALS

DOES_NOT_EQUAL

public static final TestOperator DOES_NOT_EQUAL

CONTAINS

public static final TestOperator CONTAINS

IS_NOT_WITHIN

public static final TestOperator IS_NOT_WITHIN

DOES_NOT_CONTAIN

public static final TestOperator DOES_NOT_CONTAIN

CONTAINS_EXACTLY

public static final TestOperator CONTAINS_EXACTLY

AND

public static final TestOperator AND

OR

public static final TestOperator OR
Method Detail

values

public static TestOperator[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (TestOperator c : TestOperator.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static TestOperator valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

getInstance

public static TestOperator getInstance(int type)
Retrieve an instance of the enum based on its int value.

Parameters:
type - int type
Returns:
enum instance

getInstance

public static TestOperator getInstance(Number type)
Retrieve an instance of the enum based on its int value.

Parameters:
type - int type
Returns:
enum instance

getValue

public int getValue()
Accessor method used to retrieve the numeric representation of the enum.

Specified by:
getValue in interface MpxjEnum
Returns:
int representation of the enum

evaluate

public abstract boolean evaluate(Object lhs,
                                 Object rhs)
This method applies the operator represented by this class to the supplied operands. Note that the RHS operand can be a list, allowing range operators like "within" to operate.

Parameters:
lhs - operand
rhs - operand
Returns:
boolean result

getSingleOperand

protected Object getSingleOperand(Object operand)
This method is used to ensure that if a list of operand values has been supplied, that a single operand is extracted.

Parameters:
operand - operand value
Returns:
single operand value

evaluateWithin

protected boolean evaluateWithin(Object lhs,
                                 Object rhs)
Determine if the supplied value falls within the specified range.

Parameters:
lhs - single value operand
rhs - range operand
Returns:
boolean result

evaluateCompareTo

protected int evaluateCompareTo(Object lhs,
                                Object rhs)
Implements a simple compare-to operation. Assumes that the LHS operand implements the Comparable interface.

Parameters:
lhs - operand
rhs - operand
Returns:
boolean result

evaluateContains

protected boolean evaluateContains(Object lhs,
                                   Object rhs)
Assuming the supplied arguments are both Strings, this method determines if rhs is contained within lhs. This test is case insensitive.

Parameters:
lhs - operand
rhs - operand
Returns:
boolean result

evaluateContainsExactly

protected boolean evaluateContainsExactly(Object lhs,
                                          Object rhs)
Assuming the supplied arguments are both Strings, this method determines if rhs is contained within lhs. This test is case sensitive.

Parameters:
lhs - operand
rhs - operand
Returns:
boolean result


Copyright © 2012. All Rights Reserved.