org.pentaho.di.core
Class Condition

java.lang.Object
  extended by org.pentaho.di.core.Condition
All Implemented Interfaces:
Cloneable, XMLInterface

public class Condition
extends Object
implements Cloneable, XMLInterface

This class describes a condition in a general meaning. A condition can either be

1) Atomic (a=10, B='aa')

2) Composite ( NOT Condition1 AND Condition2 OR Condition3 )

If the nr of atomic conditions is 0, the condition is atomic, otherwise it's Composit.

Precedence doesn't exist. Conditions are evaluated in the order in which they are found.

A condition can be negated or not.

Since:
8-06-2004
Author:
Matt

Field Summary
static int FUNC_CONTAINS
           
static int FUNC_ENDS_WITH
           
static int FUNC_EQUAL
           
static int FUNC_IN_LIST
           
static int FUNC_LARGER
           
static int FUNC_LARGER_EQUAL
           
static int FUNC_NOT_EQUAL
           
static int FUNC_NOT_NULL
           
static int FUNC_NULL
           
static int FUNC_REGEXP
           
static int FUNC_SMALLER
           
static int FUNC_SMALLER_EQUAL
           
static int FUNC_STARTS_WITH
           
static String[] functions
           
static int OPERATOR_AND
           
static int OPERATOR_AND_NOT
           
static int OPERATOR_NONE
           
static int OPERATOR_NOT
           
static int OPERATOR_OR
           
static int OPERATOR_OR_NOT
           
static int OPERATOR_XOR
           
static String[] operators
           
static String XML_TAG
           
 
Constructor Summary
Condition()
           
Condition(boolean negate, String valuename, int function, String valuename2, ValueMetaAndData exact)
           
Condition(int operator, String valuename, int function, String valuename2, ValueMetaAndData exact)
           
Condition(Node condnode)
          Build a new condition using an XML Document Node
Condition(String valuename, int function, String valuename2, ValueMetaAndData exact)
           
 
Method Summary
 void addCondition(Condition cb)
           
 void addCondition(int idx, Condition cb)
           
 void clearFieldPositions()
          We cache the position of a value in a row.
 Object clone()
           
 boolean evaluate(RowMetaInterface rowMeta, Object[] r)
           
 Condition getCondition(int i)
           
 int getFunction()
           
static int getFunction(String description)
           
 String getFunctionDesc()
           
 String getLeftValuename()
           
 ObjectId getObjectId()
          Returns the database ID of this Condition if a repository was used before.
 int getOperator()
           
static int getOperator(String description)
           
 String getOperatorDesc()
           
static String[] getOperators()
           
static String[] getRealOperators()
           
 ValueMetaAndData getRightExact()
           
 ObjectId getRightExactID()
          Get the id of the RightExact Value in the repository
 String getRightExactString()
           
 String getRightValuename()
           
 String[] getUsedFields()
           
 void getUsedFields(Hashtable<String,String> fields)
           
 String getXML()
          Describes the Object implementing this interface as XML
 String getXML(int level)
           
 boolean isAtomic()
           
 boolean isComposite()
           
 boolean isEmpty()
          A condition is empty when the condition is atomic and no left field is specified.
 boolean isNegated()
           
 void negate()
           
 int nrConditions()
           
 void removeCondition(int nr)
           
 void setCondition(int i, Condition subCondition)
           
 void setFunction(int function)
           
 void setLeftValuename(String left_valuename)
           
 void setNegated(boolean negate)
           
 void setObjectId(ObjectId id)
          Set the database ID for this Condition in the repository.
 void setOperator(int operator)
           
 void setRightExact(ValueMetaAndData right_exact)
           
 void setRightExactID(ObjectId id_right_exact)
          Set the database ID for the RightExact Value in the repository.
 void setRightValuename(String right_valuename)
           
 String toString()
           
 String toString(int level, boolean show_negate, boolean show_operator)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_TAG

public static final String XML_TAG
See Also:
Constant Field Values

operators

public static final String[] operators

OPERATOR_NONE

public static final int OPERATOR_NONE
See Also:
Constant Field Values

OPERATOR_OR

public static final int OPERATOR_OR
See Also:
Constant Field Values

OPERATOR_AND

public static final int OPERATOR_AND
See Also:
Constant Field Values

OPERATOR_NOT

public static final int OPERATOR_NOT
See Also:
Constant Field Values

OPERATOR_OR_NOT

public static final int OPERATOR_OR_NOT
See Also:
Constant Field Values

OPERATOR_AND_NOT

public static final int OPERATOR_AND_NOT
See Also:
Constant Field Values

OPERATOR_XOR

public static final int OPERATOR_XOR
See Also:
Constant Field Values

functions

public static final String[] functions

FUNC_EQUAL

public static final int FUNC_EQUAL
See Also:
Constant Field Values

FUNC_NOT_EQUAL

public static final int FUNC_NOT_EQUAL
See Also:
Constant Field Values

FUNC_SMALLER

public static final int FUNC_SMALLER
See Also:
Constant Field Values

FUNC_SMALLER_EQUAL

public static final int FUNC_SMALLER_EQUAL
See Also:
Constant Field Values

FUNC_LARGER

public static final int FUNC_LARGER
See Also:
Constant Field Values

FUNC_LARGER_EQUAL

public static final int FUNC_LARGER_EQUAL
See Also:
Constant Field Values

FUNC_REGEXP

public static final int FUNC_REGEXP
See Also:
Constant Field Values

FUNC_NULL

public static final int FUNC_NULL
See Also:
Constant Field Values

FUNC_NOT_NULL

public static final int FUNC_NOT_NULL
See Also:
Constant Field Values

FUNC_IN_LIST

public static final int FUNC_IN_LIST
See Also:
Constant Field Values

FUNC_CONTAINS

public static final int FUNC_CONTAINS
See Also:
Constant Field Values

FUNC_STARTS_WITH

public static final int FUNC_STARTS_WITH
See Also:
Constant Field Values

FUNC_ENDS_WITH

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

Condition

public Condition()

Condition

public Condition(String valuename,
                 int function,
                 String valuename2,
                 ValueMetaAndData exact)

Condition

public Condition(int operator,
                 String valuename,
                 int function,
                 String valuename2,
                 ValueMetaAndData exact)

Condition

public Condition(boolean negate,
                 String valuename,
                 int function,
                 String valuename2,
                 ValueMetaAndData exact)

Condition

public Condition(Node condnode)
          throws KettleXMLException
Build a new condition using an XML Document Node

Parameters:
condnode -
Throws:
KettleXMLException
Method Detail

getObjectId

public ObjectId getObjectId()
Returns the database ID of this Condition if a repository was used before.

Returns:
the ID of the db connection.

setObjectId

public void setObjectId(ObjectId id)
Set the database ID for this Condition in the repository.

Parameters:
id - The ID to set on this condition.

clone

public Object clone()
Overrides:
clone in class Object

setOperator

public void setOperator(int operator)

getOperator

public int getOperator()

getOperatorDesc

public String getOperatorDesc()

getOperator

public static final int getOperator(String description)

getOperators

public static final String[] getOperators()

getRealOperators

public static final String[] getRealOperators()

setLeftValuename

public void setLeftValuename(String left_valuename)

getLeftValuename

public String getLeftValuename()

getFunction

public int getFunction()

setFunction

public void setFunction(int function)

getFunctionDesc

public String getFunctionDesc()

getFunction

public static final int getFunction(String description)

setRightValuename

public void setRightValuename(String right_valuename)

getRightValuename

public String getRightValuename()

setRightExact

public void setRightExact(ValueMetaAndData right_exact)

getRightExact

public ValueMetaAndData getRightExact()

getRightExactString

public String getRightExactString()

getRightExactID

public ObjectId getRightExactID()
Get the id of the RightExact Value in the repository

Returns:
The id of the RightExact Value in the repository

setRightExactID

public void setRightExactID(ObjectId id_right_exact)
Set the database ID for the RightExact Value in the repository.

Parameters:
id_right_exact - The ID to set on this Value.

isAtomic

public boolean isAtomic()

isComposite

public boolean isComposite()

isNegated

public boolean isNegated()

setNegated

public void setNegated(boolean negate)

negate

public void negate()

isEmpty

public boolean isEmpty()
A condition is empty when the condition is atomic and no left field is specified.


clearFieldPositions

public void clearFieldPositions()
We cache the position of a value in a row. If ever we want to change the rowtype, we need to clear these cached field positions...


evaluate

public boolean evaluate(RowMetaInterface rowMeta,
                        Object[] r)

addCondition

public void addCondition(Condition cb)

addCondition

public void addCondition(int idx,
                         Condition cb)

removeCondition

public void removeCondition(int nr)

nrConditions

public int nrConditions()

getCondition

public Condition getCondition(int i)

setCondition

public void setCondition(int i,
                         Condition subCondition)

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(int level,
                       boolean show_negate,
                       boolean show_operator)

getXML

public String getXML()
              throws KettleValueException
Description copied from interface: XMLInterface
Describes the Object implementing this interface as XML

Specified by:
getXML in interface XMLInterface
Returns:
the XML string for this object
Throws:
KettleValueException

getXML

public String getXML(int level)
              throws KettleValueException
Throws:
KettleValueException

getUsedFields

public String[] getUsedFields()

getUsedFields

public void getUsedFields(Hashtable<String,String> fields)