public class ComparisonNode extends Object implements ExpressionNode
Modifier and Type | Field and Description |
---|---|
private ExpressionNode |
lhs |
private String |
operator |
private ExpressionNode |
rhs |
Constructor and Description |
---|
ComparisonNode(ExpressionNode lhs,
String operator,
ExpressionNode rhs)
Constructs a new comparison node.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(Visitor visitor)
Perform visitation of this node.
|
private BucketSet |
compare(BucketIdFactory factory,
IdNode id,
LiteralNode literal,
String operator) |
private BucketSet |
compare(BucketIdFactory factory,
SearchColumnNode node,
LiteralNode literal)
Compares a search column node with a literal node.
|
Object |
evaluate(Context context)
Evaluate the content of this node based on document object, and return that value.
|
private Result |
evaluateBool(Object lhs,
Object rhs)
Evaluate this expression on two operands, given that they are not invalid.
|
private Result |
evaluateEquals(Object lhs,
Object rhs)
Compare two operands for equality.
|
ResultList |
evaluateListAndSingle(AttributeNode.VariableValueList lhs,
Object rhs) |
ResultList |
evaluateListsFalse(AttributeNode.VariableValueList lhs,
AttributeNode.VariableValueList rhs) |
ResultList |
evaluateListsTrue(AttributeNode.VariableValueList lhs,
AttributeNode.VariableValueList rhs) |
private Result |
evaluateNumber(Object lhs,
Object rhs)
Evalutes the value of this term over a document, given that both operands must be numbers.
|
private Result |
evaluateString(Object lhs,
Object rhs)
Evalutes the value of this term over a document, given that both operands must be strings.
|
private ResultList |
evaluateWithAtLeastOneNullSide(Object lhs,
Object rhs)
Evaluates a binary comparison where one or both operands are null.
|
private double |
getAsNumber(Object value) |
BucketSet |
getBucketSet(BucketIdFactory factory)
Returns the set of bucket ids covered by this node.
|
ExpressionNode |
getLHS()
Returns the left hand side of this comparison.
|
String |
getOperator()
Returns the comparison operator of this.
|
OrderingSpecification |
getOrdering(IdNode lhs,
LiteralNode rhs,
String operator,
int order) |
OrderingSpecification |
getOrdering(int order)
If this document selection implies a specific ordering (using the orderdoc scheme),
return that specification.
|
ExpressionNode |
getRHS()
Returns the right hand side of this comparison.
|
private String |
globToRegex(char glob)
Converts a single character in a glob expression to the corresponding regular expression string.
|
private String |
globToRegex(String glob)
Converts a glob pattern to a corresponding regular expression string.
|
ComparisonNode |
setLHS(ExpressionNode lhs)
Sets the left hand side of this comparison.
|
ComparisonNode |
setOperator(String operator)
Sets the comparison operator of this.
|
ComparisonNode |
setRHS(ExpressionNode rhs)
Sets the right hand side of this comparison.
|
String |
toString() |
private ExpressionNode lhs
private ExpressionNode rhs
private String operator
public ComparisonNode(ExpressionNode lhs, String operator, ExpressionNode rhs)
lhs
- The left-hand-side of the comparison.operator
- The comparison operator.rhs
- The right-hand-side of the comparison.public ExpressionNode getLHS()
public ComparisonNode setLHS(ExpressionNode lhs)
lhs
- The new left hand side.public String getOperator()
public ComparisonNode setOperator(String operator)
operator
- The operator string.public ExpressionNode getRHS()
public ComparisonNode setRHS(ExpressionNode rhs)
rhs
- The new right hand side.public OrderingSpecification getOrdering(IdNode lhs, LiteralNode rhs, String operator, int order)
public OrderingSpecification getOrdering(int order)
ExpressionNode
getOrdering
in interface ExpressionNode
order
- The order in which we are looking to traverse the ordering (ASCENDING or DESCENDING)public BucketSet getBucketSet(BucketIdFactory factory)
ExpressionNode
getBucketSet
in interface ExpressionNode
factory
- The factory used by the current application.private BucketSet compare(BucketIdFactory factory, SearchColumnNode node, LiteralNode literal)
factory
- The bucket id factory used.node
- The search column node.literal
- The literal node to compare to.private BucketSet compare(BucketIdFactory factory, IdNode id, LiteralNode literal, String operator)
public Object evaluate(Context context)
ExpressionNode
evaluate
in interface ExpressionNode
context
- The document to evaluate over.private ResultList evaluateWithAtLeastOneNullSide(Object lhs, Object rhs)
public ResultList evaluateListsTrue(AttributeNode.VariableValueList lhs, AttributeNode.VariableValueList rhs)
public ResultList evaluateListsFalse(AttributeNode.VariableValueList lhs, AttributeNode.VariableValueList rhs)
public ResultList evaluateListAndSingle(AttributeNode.VariableValueList lhs, Object rhs)
private Result evaluateBool(Object lhs, Object rhs)
lhs
- Left hand side of operation.rhs
- Right hand side of operation.private Result evaluateEquals(Object lhs, Object rhs)
lhs
- Left hand side of operation.rhs
- Right hand side of operation.private double getAsNumber(Object value)
private Result evaluateNumber(Object lhs, Object rhs)
lhs
- Left hand side of operation.rhs
- Right hand side of operation.private Result evaluateString(Object lhs, Object rhs)
lhs
- Left hand side of operation.rhs
- Right hand side of operation.private String globToRegex(String glob)
glob
- The glob pattern.private String globToRegex(char glob)
glob
- The glob character.public void accept(Visitor visitor)
ExpressionNode
accept
in interface ExpressionNode
visitor
- The visitor that wishes to visit the node.Copyright © 2018. All rights reserved.