EvaluationContextImpl.java
2.83 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.RepositoryException
* javax.jcr.Session
* javax.jcr.query.Row
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.search.impl.builder;
import com.day.cq.search.PredicateGroup;
import com.day.cq.search.eval.EvaluationContext;
import com.day.cq.search.eval.PredicateEvaluator;
import com.day.cq.search.impl.builder.QueryImpl;
import com.day.cq.search.impl.builder.RootEvaluator;
import java.util.HashMap;
import java.util.Map;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.query.Row;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EvaluationContextImpl
implements EvaluationContext {
private static final Logger log = LoggerFactory.getLogger(EvaluationContextImpl.class);
private QueryImpl query;
private Map<String, Object> map = new HashMap<String, Object>();
private RootEvaluator rootEvaluator;
public EvaluationContextImpl(QueryImpl query, RootEvaluator rootEvaluator) {
this.query = query;
this.rootEvaluator = rootEvaluator;
}
@Override
public PredicateEvaluator getPredicateEvaluator(String type) {
return this.query.getPredicateEvaluator(type);
}
@Override
public Session getSession() {
return this.query.getSession();
}
@Override
public Node getNode(Row row) {
try {
return row.getNode();
}
catch (RepositoryException e) {
log.warn("Could not retrive jcr:path value from row", (Throwable)e);
return null;
}
}
@Override
public ResourceResolver getResourceResolver() {
return this.query.getResourceResolver();
}
@Override
public String getPath(Row row) {
try {
return row.getPath();
}
catch (RepositoryException e) {
log.warn("Could not retrive jcr:path value from row", (Throwable)e);
return null;
}
}
@Override
public Resource getResource(Row row) {
return this.getResourceResolver().getResource(this.getPath(row));
}
@Override
public void put(String key, Object value) {
if (value == null) {
this.map.remove(key);
} else {
this.map.put(key, value);
}
}
@Override
public Object get(String key) {
return this.map.get(key);
}
public RootEvaluator getRootEvaluator() {
return this.rootEvaluator;
}
public PredicateGroup getRootPredicate() {
return this.query.getPredicates();
}
}