Package org.pentaho.di.core
Class Condition
java.lang.Object
org.pentaho.di.core.Condition
- All Implemented Interfaces:
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
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final String[]
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final String[]
static final String
-
Constructor Summary
ConstructorDescriptionCondition
(boolean negate, String valuename, int function, String valuename2, ValueMetaAndData exact) Condition
(int operator, String valuename, int function, String valuename2, ValueMetaAndData exact) Condition
(String valuename, int function, String valuename2, ValueMetaAndData exact) Build a new condition using an XML Document Node -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCondition
(int idx, Condition cb) void
void
We cache the position of a value in a row.clone()
boolean
evaluate
(RowMetaInterface rowMeta, Object[] r) Evaluate the condition...getCondition
(int i) int
static final int
getFunction
(String description) Returns the database ID of this Condition if a repository was used before.int
static final int
getOperator
(String description) static final String[]
static final String[]
Get the id of the RightExact Value in the repositoryString[]
void
getUsedFields
(Map<String, String> fields) getXML()
Describes the Object implementing this interface as XMLgetXML
(int level) boolean
isAtomic()
boolean
boolean
isEmpty()
A condition is empty when the condition is atomic and no left field is specified.boolean
void
negate()
int
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.toString()
toString
(int level, boolean showNegate, boolean showOperator)
-
Field Details
-
XML_TAG
- See Also:
-
operators
-
OPERATOR_NONE
public static final int OPERATOR_NONE- See Also:
-
OPERATOR_OR
public static final int OPERATOR_OR- See Also:
-
OPERATOR_AND
public static final int OPERATOR_AND- See Also:
-
OPERATOR_NOT
public static final int OPERATOR_NOT- See Also:
-
OPERATOR_OR_NOT
public static final int OPERATOR_OR_NOT- See Also:
-
OPERATOR_AND_NOT
public static final int OPERATOR_AND_NOT- See Also:
-
OPERATOR_XOR
public static final int OPERATOR_XOR- See Also:
-
functions
-
FUNC_EQUAL
public static final int FUNC_EQUAL- See Also:
-
FUNC_NOT_EQUAL
public static final int FUNC_NOT_EQUAL- See Also:
-
FUNC_SMALLER
public static final int FUNC_SMALLER- See Also:
-
FUNC_SMALLER_EQUAL
public static final int FUNC_SMALLER_EQUAL- See Also:
-
FUNC_LARGER
public static final int FUNC_LARGER- See Also:
-
FUNC_LARGER_EQUAL
public static final int FUNC_LARGER_EQUAL- See Also:
-
FUNC_REGEXP
public static final int FUNC_REGEXP- See Also:
-
FUNC_NULL
public static final int FUNC_NULL- See Also:
-
FUNC_NOT_NULL
public static final int FUNC_NOT_NULL- See Also:
-
FUNC_IN_LIST
public static final int FUNC_IN_LIST- See Also:
-
FUNC_CONTAINS
public static final int FUNC_CONTAINS- See Also:
-
FUNC_STARTS_WITH
public static final int FUNC_STARTS_WITH- See Also:
-
FUNC_ENDS_WITH
public static final int FUNC_ENDS_WITH- See Also:
-
FUNC_LIKE
public static final int FUNC_LIKE- See Also:
-
FUNC_TRUE
public static final int FUNC_TRUE- See Also:
-
-
Constructor Details
-
Condition
public Condition() -
Condition
-
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
- Throws:
KettleXMLException
-
Condition
Build a new condition using an XML Document Node- Parameters:
condnode
-- Throws:
KettleXMLException
-
-
Method Details
-
getObjectId
Returns the database ID of this Condition if a repository was used before.- Returns:
- the ID of the db connection.
-
setObjectId
Set the database ID for this Condition in the repository.- Parameters:
id
- The ID to set on this condition.
-
clone
-
setOperator
public void setOperator(int operator) -
getOperator
public int getOperator() -
getOperatorDesc
-
getOperator
-
getOperators
-
getRealOperators
-
setLeftValuename
-
getLeftValuename
-
getFunction
public int getFunction() -
setFunction
public void setFunction(int function) -
getFunctionDesc
-
getFunction
-
setRightValuename
-
getRightValuename
-
setRightExact
-
getRightExact
-
getRightExactString
-
getRightExactID
Get the id of the RightExact Value in the repository- Returns:
- The id of the RightExact Value in the repository
-
setRightExactID
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
Evaluate the condition...- Parameters:
rowMeta
- the row metadatar
- the row data- Returns:
- true if the condition evaluates to true.
-
addCondition
-
addCondition
-
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
-
setCondition
-
toString
-
toString
-
getXML
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
- Throws:
KettleValueException
-
getUsedFields
-
getUsedFields
-
getChildren
-