blob: c4a0065ac6f68f1d2d1d42aad29ce2383e8c26e4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.select.convert;
import com.yahoo.document.select.rule.ArithmeticNode;
import com.yahoo.document.select.rule.AttributeNode;
import com.yahoo.document.select.rule.ComparisonNode;
/**
* Represents a query containing a valid now() expression. The now expression
* is very strict right now, but can be expanded later.
*
* @author Ulf Lilleengen
*/
public class NowQueryExpression {
private final AttributeNode attribute;
private final ComparisonNode comparison;
private final NowQueryNode now;
NowQueryExpression(AttributeNode attribute, ComparisonNode comparison, ArithmeticNode arithmetic) {
this.attribute = attribute;
this.comparison = comparison;
this.now = (arithmetic != null ? new NowQueryNode(arithmetic) : new NowQueryNode(0));
}
public String getDocumentType() {
return attribute.getValue().toString();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
for(AttributeNode.Item item : attribute.getItems()) {
sb.append(item.getName()).append(".");
}
sb.deleteCharAt(sb.length() - 1);
return sb + ":" + comparison.getOperator() + now;
}
}
|