/** * Builds a like filter * * @matchCase * @return a PropertyIsLike * @throws CQLException */ public PropertyIsLike buildLikeFilter(boolean matchCase) throws CQLException { final String WC_MULTI = "%"; final String WC_SINGLE = "_"; final String ESCAPE = "\\"; try { org.opengis.filter.expression.Expression pattern = this.resultStack.popExpression(); org.opengis.filter.expression.Expression expr = this.resultStack.popExpression(); PropertyIsLike f = filterFactory.like( expr, pattern.toString(), WC_MULTI, WC_SINGLE, ESCAPE, matchCase); return f; } catch (IllegalFilterException ife) { throw new CQLException( "Exception building LikeFilter: " + ife.getMessage(), this.cqlSource); } }
/** Sets the expression which represents the null check. */ public void setExpression(Expression nullCheck) { if (nullCheck != null && nullCheck instanceof PropertyName) { this.nullCheck = nullCheck; } else { throw new IllegalFilterException("PropertyName expression required"); } }
public Object evaluate(Object feature) { if (feature == null) { return Integer.valueOf(0); // no features were visited in the making of this answer } SimpleFeatureCollection featureCollection = (SimpleFeatureCollection) feature; synchronized (featureCollection) { if (featureCollection != previousFeatureCollection) { previousFeatureCollection = featureCollection; count = null; try { CalcResult result = calculateCount(featureCollection); if (result != null) { count = result.getValue(); } } catch (IllegalFilterException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } catch (IOException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } } } return count; } }
getFInfoFilter = ff.intersects(ff.property(localName), ff.literal(queryPolygon)); } catch (IllegalFilterException e) { e.printStackTrace(); throw new ServiceException("Internal error : " + e.getMessage(), e);
le.setLiteral((new GeometryFactory()).toGeometry(tmp)); } catch (IllegalFilterException e) { logger.warning(e.toString());
} catch (IllegalFilterException ex) { ex.printStackTrace();
le.setLiteral((new GeometryFactory()).toGeometry(tmp)); } catch (IllegalFilterException e) { logger.warning(e.toString());
/** * Sets the appropriate state. * * @param expression the expression being evaluated. * @return <tt>leftValue</tt> if curExprssn is a mathExpression, an empty string if a literal or * attribute, illegal expression thrown otherwise. * @throws IllegalFilterException if the current expression is not math, attribute, or literal. */ private static String setInitialState(org.opengis.filter.expression.Expression expression) throws IllegalFilterException { if (expression instanceof BinaryExpression) { return "leftValue"; } else if ((expression instanceof PropertyName) || (expression instanceof Literal)) { return ""; } else if (expression instanceof FunctionExpression) { return "accumulate"; // start storing values! } else { throw new IllegalFilterException( "Created illegal expression: " + expression.getClass().toString()); } }
"Attempted to construct illegal " + "filter: " + ife.getMessage(), ife);
@SuppressWarnings("unchecked") public Object evaluate(Object feature) { if (feature == null) { return Integer.valueOf(0); // no features were visited in the making of this answer } FeatureCollection<FeatureType, Feature> featureCollection = (FeatureCollection<FeatureType, Feature>) feature; synchronized (featureCollection) { if (featureCollection != previousFeatureCollection) { previousFeatureCollection = featureCollection; bounds = null; try { CalcResult result = calculateBounds(featureCollection); if (result != null) { bounds = result.getValue(); } } catch (IllegalFilterException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } catch (IOException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } } } return bounds; } }
/** * Creates the filter held in the parser. * * @return The current filter to be created by this parser. * @throws IllegalFilterException If called before the filter is in a complete state. */ public Filter create() throws IllegalFilterException { if (isComplete()) { LOGGER.finer("complete called, state = " + curState); curState = "complete"; // added by cholmes fid bug. return curFilter; } else { throw new IllegalFilterException( "Got to the end state of an incomplete filter, current" + " state is " + curState); } }
/** * builds PropertyIsBetween filter * * @return PropertyIsBetween * @throws CQLException */ public PropertyIsBetween buildBetween() throws CQLException { try { org.opengis.filter.expression.Expression sup = this.resultStack.popExpression(); org.opengis.filter.expression.Expression inf = this.resultStack.popExpression(); org.opengis.filter.expression.Expression expr = this.resultStack.popExpression(); PropertyIsBetween filter = filterFactory.between(expr, inf, sup); return filter; } catch (IllegalFilterException ife) { throw new CQLException( "Exception building CompareFilter: " + ife.getMessage(), this.cqlSource); } }
@SuppressWarnings("unchecked") public Object evaluate(Object feature) { if (feature == null) { return Integer.valueOf(0); // no features were visited in the making of this answer } FeatureCollection<FeatureType, Feature> featureCollection = (FeatureCollection<FeatureType, Feature>) feature; synchronized (featureCollection) { if (featureCollection != previousFeatureCollection) { previousFeatureCollection = featureCollection; average = null; try { CalcResult result = calculateAverage(featureCollection, expr); if (result != null) { average = result.getValue(); } } catch (IllegalFilterException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } catch (IOException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } } } return average; }
/** * Adds a sub filter to this filter. * * @param filter Specified filter to add to the sub filter list. * @throws IllegalFilterException Does not conform to logic filter structure * @task REVISIT: make all filters immutable. This should return a new filter. */ public final void addFilter(org.opengis.filter.Filter filter) throws IllegalFilterException { // reset cachedHash = 0; int filterType = Filters.getFilterType(this); if ((filterType != LOGIC_NOT) || (children.size() == 0)) { children.add(filter); } else { throw new IllegalFilterException( "Attempted to add an more than one filter to a NOT filter."); } }
"Attempted to construct illegal filter: " + e.getMessage()); "Attempted to construct illegal filter: " + e.getMessage(), e);
public Object evaluate(Object feature) { if (feature == null) { return Integer.valueOf(0); // no features were visited in the making of this answer } Expression expr = (Expression) getExpression(0); SimpleFeatureCollection featureCollection = (SimpleFeatureCollection) feature; synchronized (featureCollection) { if (featureCollection != previousFeatureCollection) { previousFeatureCollection = featureCollection; min = null; try { CalcResult result = calculateMin(featureCollection, expr); if (result != null) { min = result.getValue(); } } catch (IllegalFilterException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } catch (IOException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } } } return min; }
/** * This sets the distance for a GeometryDistanceFilter. It currently ignores the units, and * attempts to convert the distance to a double. * * @param distance the distance - should be a string of a double. * @param units a reference to a units dictionary. * @throws IllegalFilterException if the distance string can not be converted to a double. * @task TODO: Implement units, probably with org.geotools.units package and a special distance * class in the filter package. It would be nice if the distance class could get any type of * units, like it would handle the conversion. */ public void setDistance(String distance, String units) throws IllegalFilterException { LOGGER.finer("set distance called, current state is " + curState); if (curState.equals("distance")) { try { double distDouble = Double.parseDouble(distance); ((CartesianDistanceFilter) curFilter).setDistance(distDouble); curState = "complete"; } catch (NumberFormatException nfe) { throw new IllegalFilterException( "could not parse distance: " + distance + " to a double"); } } else { throw new IllegalFilterException( "Got distance for Geometry Distance Filter in illegal state: " + curState + ", geometry and property should be set first"); } }
public void testLiteralExpressionImplEquals() { try { Literal testString1 = new LiteralExpressionImpl("test literal"); Literal testString2 = new LiteralExpressionImpl("test literal"); assertTrue(testString1.equals(testString2)); Literal testOtherString = new LiteralExpressionImpl("not test literal"); assertFalse(testString1.equals(testOtherString)); Literal testNumber34 = new LiteralExpressionImpl(Integer.valueOf(34)); assertFalse(testString1.equals(testNumber34)); Literal testOtherNumber34 = new LiteralExpressionImpl(Integer.valueOf(34)); assertTrue(testNumber34.equals(testOtherNumber34)); } catch (IllegalFilterException e) { LOGGER.warning("bad filter " + e.getMessage()); } }
public Object evaluate(Object feature) { if (feature == null) { return Integer.valueOf(0); // no features were visited in the making of this answer } SimpleFeatureCollection featureCollection = (SimpleFeatureCollection) feature; Expression expr = (Expression) getExpression(0); synchronized (featureCollection) { if (featureCollection != previousFeatureCollection) { previousFeatureCollection = featureCollection; sum = null; try { CalcResult result = calculateSum(featureCollection, expr); if (result != null) { sum = result.getValue(); } } catch (IllegalFilterException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } catch (IOException e) { LOGGER.log(Level.FINER, e.getLocalizedMessage(), e); } } } return sum; }