Revision 46078 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/expressionevaluator/DefaultFeatureExpressionEvaluator.java
DefaultFeatureExpressionEvaluator.java | ||
---|---|---|
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
import java.util.HashSet; |
5 | 5 |
import java.util.List; |
6 |
import java.util.Objects; |
|
6 | 7 |
import java.util.Set; |
8 |
import org.apache.commons.lang3.StringUtils; |
|
7 | 9 |
import org.gvsig.expressionevaluator.Code; |
10 |
import org.gvsig.expressionevaluator.Code.Callable; |
|
8 | 11 |
import org.gvsig.expressionevaluator.SymbolTable; |
9 | 12 |
import org.gvsig.expressionevaluator.Expression; |
13 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
10 | 14 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
11 | 15 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
12 | 16 |
import org.gvsig.expressionevaluator.Function; |
... | ... | |
37 | 41 |
{ |
38 | 42 |
|
39 | 43 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultFeatureExpressionEvaluator.class); |
44 |
private String storeName; |
|
40 | 45 |
|
41 | 46 |
private static class DescriptionAdapter implements Description { |
42 | 47 |
|
... | ... | |
97 | 102 |
} |
98 | 103 |
|
99 | 104 |
public DefaultFeatureExpressionEvaluator(String source) { |
105 |
this(null, source); |
|
106 |
} |
|
107 |
|
|
108 |
public DefaultFeatureExpressionEvaluator(String storeName, String source) { |
|
100 | 109 |
this(); |
101 | 110 |
ExpressionEvaluatorManager manager = ExpressionEvaluatorLocator.getManager(); |
102 | 111 |
this.expression = manager.createExpression(); |
103 | 112 |
this.expression.setPhrase(source); |
113 |
this.storeName = storeName; |
|
104 | 114 |
} |
105 | 115 |
|
106 | 116 |
public DefaultFeatureExpressionEvaluator(Expression expression) { |
117 |
this(null, expression); |
|
118 |
} |
|
119 |
|
|
120 |
public DefaultFeatureExpressionEvaluator(String storeName, Expression expression) { |
|
107 | 121 |
this(); |
108 | 122 |
this.expression = expression; |
109 |
} |
|
123 |
this.storeName = storeName; |
|
124 |
|
|
125 |
} |
|
110 | 126 |
|
111 | 127 |
@Override |
112 | 128 |
public String getName() { |
... | ... | |
147 | 163 |
this.expression.getCode().accept((Object code) -> { |
148 | 164 |
if (code instanceof Code.Identifier) { |
149 | 165 |
Code.Identifier identifier = (Code.Identifier) code; |
150 |
names.add(identifier.name()); |
|
151 |
} |
|
166 |
if(!StringUtils.equalsIgnoreCase(storeName, identifier.name())) { |
|
167 |
names.add(identifier.name()); |
|
168 |
} |
|
169 |
} else if (code instanceof Code.Callable) { |
|
170 |
Callable callable = (Callable) code; |
|
171 |
if (callable.name().equals(ExpressionBuilder.FUNCTION_GETATTR)) { |
|
172 |
Code p0 = callable.parameters().get(0); |
|
173 |
if (!(p0 instanceof Code.Identifier)) { |
|
174 |
return; |
|
175 |
} |
|
176 |
if (!StringUtils.equalsIgnoreCase(storeName, ((Code.Identifier) p0).name())) { |
|
177 |
return; |
|
178 |
} |
|
179 |
Code p1 = callable.parameters().get(1); |
|
180 |
if (!(p1 instanceof Code.Constant)) { |
|
181 |
return; |
|
182 |
} |
|
183 |
String s = Objects.toString(((Code.Constant)p1).value(), null); |
|
184 |
if (s != null) { |
|
185 |
names.add(s); |
|
186 |
} |
|
187 |
} |
|
188 |
} |
|
152 | 189 |
}); |
153 | 190 |
EvaluatorFieldsInfo info = new EvaluatorFieldsInfo(); |
154 | 191 |
for (String name : names) { |
Also available in: Unified diff