protected boolean isConstant(Expression ex) { // quick common cases first if (ex instanceof Literal) { return true; } else if (ex instanceof PropertyName) { return false; } // ok, check for attribute dependencies and volatile functions then attributeExtractor.clear(); ex.accept(attributeExtractor, null); return attributeExtractor.isConstantExpression(); }
protected boolean isConstant(Expression ex) { // quick common cases first if (ex instanceof Literal) { return true; } else if (ex instanceof NilExpression) { return true; } else if (ex instanceof PropertyName) { return false; } // ok, check for attribute dependencies and volatile functions then attributeExtractor.clear(); ex.accept(attributeExtractor, null); return attributeExtractor.isConstantExpression(); }
public RecodeFunction(List<Expression> parameters, Literal fallback) { this.parameters = parameters; this.fallback = fallback; // check inputs if (parameters.size() % 2 != 1 && parameters.size() != 0) { throw new IllegalArgumentException( "There must be an equal number of lookup data and return values"); } // see if the table is full of attribute independent expressions FilterAttributeExtractor extractor = new FilterAttributeExtractor(); for (int i = 1; i < parameters.size(); i++) { Expression expression = parameters.get(i); if (expression != null) { extractor.clear(); expression.accept(extractor, null); if (!extractor.isConstantExpression()) { staticTable = false; break; } } } }
Expression expression = parameters.get(i); if (expression != null) { extractor.clear(); expression.accept(extractor, null); if (!extractor.isConstantExpression()) {
private void assertAttributeName(org.opengis.filter.Filter filter, String[] names) { fae.clear(); filter.accept(fae, null); Set<String> attNames = fae.getAttributeNameSet(); assertNotNull(attNames); assertEquals(attNames.size(), names.length); for (int i = 0; i < names.length; i++) { assertTrue(attNames.contains(names[i])); } // make sure the property name set is aligned Set<PropertyName> propNames = fae.getPropertyNameSet(); assertNotNull(propNames); assertEquals(attNames.size(), propNames.size()); for (PropertyName pn : propNames) { assertTrue(attNames.contains(pn.getPropertyName())); } }
public Object visit(org.opengis.filter.expression.Function function, Object extraData) { // can't optimize out volatile functions if (isVolatileFunction(function)) { return super.visit(function, extraData); } // stable function, is it using attributes? if (attributeExtractor == null) { attributeExtractor = new FilterAttributeExtractor(); } else { attributeExtractor.clear(); } function.accept(attributeExtractor, null); // if so we can replace it with a literal if (attributeExtractor.isConstantExpression()) { Object result = function.evaluate(null); return ff.literal(result); } else { return super.visit(function, extraData); } }
public RecodeFunction(List<Expression> parameters, Literal fallback) { this.parameters = parameters; this.fallback = fallback; // check inputs if (parameters.size() % 2 != 1 && parameters.size() != 0) { throw new IllegalArgumentException( "There must be an equal number of lookup data and return values"); } // see if the table is full of attribute independent expressions FilterAttributeExtractor extractor = new FilterAttributeExtractor(); for (int i = 1; i < parameters.size(); i++) { Expression expression = parameters.get(i); if(expression != null) { extractor.clear(); expression.accept(extractor, null); if(!extractor.isConstantExpression()) { staticTable = false; break; } } } }
private void evaluateWidth(Expression width) { attributeExtractor.clear(); width.accept(attributeExtractor, null); if (attributeExtractor.isConstantExpression()) { Double result = width.evaluate(null, Double.class); if(result != null) { int size = (int) Math.ceil(result); if (size > buffer) { buffer = size; } } else { estimateAccurate = false; } } else { estimateAccurate = false; } }
Expression expression = parameters.get(i); if(expression != null) { extractor.clear(); expression.accept(extractor, null); if(!extractor.isConstantExpression()) {
public Object visit(org.opengis.filter.expression.Function function, Object extraData) { // can't optimize out volatile functions if (function instanceof VolatileFunction) { return super.visit(function, extraData); } // stable function, is it using attributes? if (attributeExtractor == null) { attributeExtractor = new FilterAttributeExtractor(); } else { attributeExtractor.clear(); } function.accept(attributeExtractor, null); // if so we can replace it with a literal if (attributeExtractor.isConstantExpression()) { Object result = function.evaluate(null); return ff.literal(result); } else { return super.visit(function, extraData); } }