Package org.pentaho.di.core
Class Condition
- java.lang.Object
-
- 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 be1) 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
Fields Modifier and Type Field Description 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_LIKE
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 int
FUNC_TRUE
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
Constructors Constructor Description Condition()
Condition(boolean negate, String valuename, int function, String valuename2, ValueMetaAndData exact)
Condition(int operator, String valuename, int function, String valuename2, ValueMetaAndData exact)
Condition(String xml)
Condition(String valuename, int function, String valuename2, ValueMetaAndData exact)
Condition(Node condnode)
Build a new condition using an XML Document Node
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCondition(int idx, Condition cb)
void
addCondition(Condition cb)
void
clearFieldPositions()
We cache the position of a value in a row.Object
clone()
boolean
evaluate(RowMetaInterface rowMeta, Object[] r)
Evaluate the condition...List<Condition>
getChildren()
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 repositoryString
getRightExactString()
String
getRightValuename()
String[]
getUsedFields()
void
getUsedFields(Map<String,String> fields)
String
getXML()
Describes the Object implementing this interface as XMLString
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 leftValuename)
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 rightExact)
void
setRightExactID(ObjectId idRightExact)
Set the database ID for the RightExact Value in the repository.void
setRightValuename(String rightValuename)
boolean
simplify()
This method moves up atomic conditions if there is only one sub-condition.String
toString()
String
toString(int level, boolean showNegate, boolean showOperator)
-
-
-
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
-
FUNC_LIKE
public static final int FUNC_LIKE
- See Also:
- Constant Field Values
-
FUNC_TRUE
public static final int FUNC_TRUE
- 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(String xml) throws KettleXMLException
- Throws:
KettleXMLException
-
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.
-
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 leftValuename)
-
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 rightValuename)
-
getRightValuename
public String getRightValuename()
-
setRightExact
public void setRightExact(ValueMetaAndData rightExact)
-
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 idRightExact)
Set the database ID for the RightExact Value in the repository.- Parameters:
idRightExact
- 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)
Evaluate the condition...- Parameters:
rowMeta
- the row metadatar
- the row data- Returns:
- true if the condition evaluates to true.
-
addCondition
public void addCondition(Condition cb)
-
addCondition
public void addCondition(int idx, Condition cb)
-
removeCondition
public void removeCondition(int nr)
-
simplify
public boolean simplify()
This method moves up atomic conditions if there is only one sub-condition.- Returns:
- true if there was a simplification.
-
nrConditions
public int nrConditions()
-
getCondition
public Condition getCondition(int i)
-
setCondition
public void setCondition(int i, Condition subCondition)
-
toString
public String toString(int level, boolean showNegate, boolean showOperator)
-
getXML
public String getXML() throws KettleValueException
Description copied from interface:XMLInterface
Describes the Object implementing this interface as XML- Specified by:
getXML
in interfaceXMLInterface
- Returns:
- the XML string for this object
- Throws:
KettleValueException
-
getXML
public String getXML(int level) throws KettleValueException
- Throws:
KettleValueException
-
getUsedFields
public String[] getUsedFields()
-
-