Class Operators.SimpleLogicalOperator
- java.lang.Object
-
- com.im.df.api.dml.DFOperator
-
- com.im.df.api.dml.Operators.SimpleLogicalOperator
-
- Enclosing class:
- Operators
public static class Operators.SimpleLogicalOperator extends DFOperator
Class for AND/OR operators.
-
-
Constructor Summary
Constructors Constructor Description SimpleLogicalOperator(java.lang.String persistName, java.lang.String displayName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getToStringPart(java.util.List<DFTerm> operands, int index)
Get the part of the completeDFOperator.toString(java.util.List)
method result.boolean
isFieldAcceptableAsOperand(DFField field)
This is just an utility method which must be implemented by subclasses.java.lang.Object[]
parseOperands(DFField field, java.lang.String operands)
void
validate(DFDataTree dataTree, java.util.List<DFTerm> operands, java.util.Map<java.lang.String,java.lang.Object> options, TermErrors errors)
Validate the operands in context of this operator.-
Methods inherited from class com.im.df.api.dml.DFOperator
correctNumberOfOperands, getDisplayName, getDisplayNameInExpression, getMaxOperands, getMinOperands, getPersistName, getStartingWith, getStartingWithOperator, toString, toString
-
-
-
-
Method Detail
-
validate
public void validate(DFDataTree dataTree, java.util.List<DFTerm> operands, java.util.Map<java.lang.String,java.lang.Object> options, TermErrors errors)
Description copied from class:DFOperator
Validate the operands in context of this operator. It's up to operator to decide if it accepts the given operands or not. This method is called fromDFTerm.validate(com.im.df.api.ddl.DFDataTree)
.- Overrides:
validate
in classDFOperator
- Parameters:
dataTree
- The datatree where this operator will be usedoperands
- The list of operandsoptions
- Options of this query term (DFTermExpression.getOptions()
errors
- The errors object which contains the result of the validation
-
isFieldAcceptableAsOperand
public boolean isFieldAcceptableAsOperand(DFField field)
Description copied from class:DFOperator
This is just an utility method which must be implemented by subclasses. It tests if the given field is acceptable as operand for thisDFOperator
. It can return true even for fields which are recognized as invalid later. This is just rough test in the beginning of validation to filter inappropriate fields.For example some operator takes two operands of different types (text, integer,...), but both must be of the same type. In this case this method returns true for all text, integer etc. fields, but if you use combination of [text, integer] as operands, it will be invalid.
- Specified by:
isFieldAcceptableAsOperand
in classDFOperator
- Parameters:
field
- The field to be tested- Returns:
- True if field seems to be acceptable, false otherwise.
-
getToStringPart
public java.lang.String getToStringPart(java.util.List<DFTerm> operands, int index)
Description copied from class:DFOperator
Get the part of the completeDFOperator.toString(java.util.List)
method result. This method can be overriden by subclasses so each operator can provide specific form of String representation.For example for binary operator is this method called 3 times: for indexes 0, 1 and 2. The index=0 means it's string before the first operand, index=1 is string between operands and index=2 is after the second operand. For operator LESS_THAN it should return: index=0 => "", index=1 => " less than ", and for index=2 => "".
This method allow subclass to reuse the generic code from
DFOperator.toString(java.util.List)
and change the own notation (e.g. "[molW < 15]" => "[< moW, 15]" etc.).- Overrides:
getToStringPart
in classDFOperator
- Parameters:
operands
- The list of all operandsindex
- The index of String [0..operands.size()]- Returns:
- if there is only a single operand, then return no operator, otherwise operands are connected with logical operator name.
-
parseOperands
public java.lang.Object[] parseOperands(DFField field, java.lang.String operands) throws java.lang.IllegalArgumentException
- Specified by:
parseOperands
in classDFOperator
- Throws:
java.lang.IllegalArgumentException
-
-