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; } } } }
extractor.clear(); expression.accept(extractor, null); if (!extractor.isConstantExpression()) { staticTable = false; thresholds = null;
public Object visit(org.opengis.filter.expression.Function expression, Object data) { if (expression instanceof VolatileFunction) { usingVolatileFunctions = true; } if (expression instanceof FilterFunction_property) { boolean foundLiteral = false; // dynamic property usage if (expression.getParameters() != null && expression.getParameters().size() > 0) { org.opengis.filter.expression.Expression firstParam = expression.getParameters().get(0); FilterAttributeExtractor secondary = new FilterAttributeExtractor(); firstParam.accept(secondary, null); if (secondary.isConstantExpression()) { String name = firstParam.evaluate(null, String.class); if (name != null) { attributeNames.add(name); propertyNames.add(FF.property(name)); foundLiteral = true; } } } if (!foundLiteral) { usingDynamicProperties = true; } } return super.visit(expression, data); };
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; } }
extractor.clear(); expression.accept(extractor, null); if(!extractor.isConstantExpression()) { staticTable = false; thresholds = null;
public Object visit(org.opengis.filter.expression.Function expression, Object data) { if (expression instanceof VolatileFunction) { usingVolatileFunctions = true; } if(expression instanceof FilterFunction_property) { boolean foundLiteral = false; // dynamic property usage if(expression.getParameters() != null && expression.getParameters().size() > 0) { org.opengis.filter.expression.Expression firstParam = expression.getParameters().get(0); FilterAttributeExtractor secondary = new FilterAttributeExtractor(); firstParam.accept(secondary, null); if (secondary.isConstantExpression()) { String name = firstParam.evaluate(null, String.class); if(name != null) { attributeNames.add(name); propertyNames.add(ff.property(name)); foundLiteral = true; } } } if(!foundLiteral) { usingDynamicProperties = true; } } return super.visit(expression, data); };
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); } }