/** 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"); } }
/** * 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()); } }
/** * 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); } }
/** * 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."); } }
/** * 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"); } }
/** * Gets the left or first expression. * * @throws IllegalFilterException */ public void setExpression1(org.opengis.filter.expression.Expression expression) { if (isGeometryExpression(Filters.getExpressionType(expression))) { throw new IllegalFilterException( "Attempted to add Geometry expression to math expression."); } this.leftValue = expression; }
/** * Gets the second expression. * * @throws IllegalFilterException */ public void setExpression2(org.opengis.filter.expression.Expression expression) { // Check to see if this is a valid math expression before adding. if (isGeometryExpression(Filters.getExpressionType(expression))) { throw new IllegalFilterException( "Attempted to add Geometry expression to math expression."); } this.rightValue = expression; }
/** * To be called when the sax parser reaches the end of a logic filter. Tells this class to * complete. * * @param logicType the Filter type. * @throws IllegalFilterException If the end message can't be processed in this state. */ // logic types are AND=2, OR=1, NOT=3 public void end(short logicType) throws IllegalFilterException { LOGGER.finer("got an end element: " + logicType); if (logicFactory != null) { LOGGER.finer("sending end element to nested logic filter: " + logicType); logicFactory.end(logicType); if (logicFactory.isComplete()) { subFilters.add(logicFactory.create()); logicFactory = null; } } else if (this.logicType == logicType) { LOGGER.finer("end element matched internal type: " + this.logicType); isComplete = true; } else { throw new IllegalFilterException( "Logic Factory got an end message that it can't process."); } }
public void setPropertyName(String attPath) { LOGGER.entering("ExpressionAttribute", "setAttributePath", attPath); if (LOGGER.isLoggable(Level.FINEST)) LOGGER.finest("schema: " + schema + "\n\nattribute: " + attPath); if (schema != null) { if (schema.getDescriptor(attPath) != null) { this.attPath = attPath; } else { throw new IllegalFilterException( "Attribute: " + attPath + " is not in stated schema " + schema.getTypeName() + "."); } } else { this.attPath = attPath; } }
/** * Sets the state that shall be expected next based on the filterType. So if a between, null or * like is the currentFilter then attribute should be next, if an fid filter then fid should be * next. If it's a comparison, geometry or not, then leftValue should be next. * * @param filterType An AbstractFilter short of the filter type. * @return the string of what state should come next. * @throws IllegalFilterException if the filter type is not recognized. */ private static String setInitialState(short filterType) throws IllegalFilterException { if ((filterType == AbstractFilter.BETWEEN) || (filterType == AbstractFilter.NULL) || (filterType == AbstractFilter.LIKE)) { return "attribute"; } else if ((filterType == AbstractFilter.FID)) { return "fid"; } else if ((AbstractFilter.isCompareFilter(filterType)) || (AbstractFilter.isGeometryFilter(filterType))) { return "leftValue"; } else { throw new IllegalFilterException("Filter type: " + filterType + " is not recognized"); } }
/** * Creates the the logic filter if in a complete state. * * @return The created logic filter. * @throws IllegalFilterException if the filter is not complete. */ @SuppressWarnings("deprecation") public Filter create() throws IllegalFilterException { Filter filter = null; LOGGER.finer("creating a logic filter"); if (isComplete()) { LOGGER.finer("filter is complete, with type: " + this.logicType); if (logicType == AbstractFilter.LOGIC_NOT) { filter = ff.not(subFilters.get(0)); } else if (logicType == AbstractFilter.LOGIC_AND) { filter = ff.and(subFilters); } else if (logicType == AbstractFilter.LOGIC_OR) { filter = ff.or(subFilters); } // reset the variables so it works right if called again. subFilters = new ArrayList<Filter>(); this.logicType = -1; isComplete = false; return filter; } else { throw new IllegalFilterException("Attempted to generate incomplete logic filter."); } }
/** * To be called by a parser to start the creation of a logic filter. Can start a nested or a * base logic filter. * * @param logicType OR, or AND abstract filter type. * @throws IllegalFilterException if filter type does not match declared type. */ // logic types are AND=2, OR=1, NOT=3 public void start(short logicType) throws IllegalFilterException { LOGGER.finest("got a start element: " + logicType); if (this.logicType != -1) { // DJB: for GEOS-328 we need to keep the old parser around to handle multiple nestings // of logic operators. if (logicFactory == null) { logicFactory = new LogicSAXParser(); } logicFactory.start(logicType); } else if (!AbstractFilter.isLogicFilter(logicType)) { throw new IllegalFilterException("Add logic filter type does not match declared type."); } else { this.logicType = logicType; } }
curState = "complete"; } else { throw new IllegalFilterException( "Got expression for Between Filter in illegal state: " + curState); curState = "complete"; } else { throw new IllegalFilterException( "Got expression for Compare Filter in illegal state: " + curState); curState = "complete"; } else { throw new IllegalFilterException( "Got expression for Null Filter in illegal state: " + curState); throw new IllegalFilterException( "Got expression for Geometry Filter in illegal state: " + curState); } else if (curState.equals("pattern")) { if (attributes.size() < NUM_LIKE_ATTS) { throw new IllegalFilterException( "Got wrong number of attributes (expecting minimum 3): " + attributes.size() throw new IllegalFilterException( "like filter -- required attribute 'wildCard' missing or not exactly 1 char long. Capitalization?"); throw new IllegalFilterException( "like filter -- required attribute 'singleChar' missing or not exactly 1 char long. Capitalization?");
throw new IllegalFilterException( "Attempted to add sub expression in a bad state: " + currentState); readyFlag = true; } else { // otherwise, throw exception throw new IllegalFilterException( "Reached end of unready, non-nested expression: " + currentState);
allNames.add(pd.getName()); throw new IllegalFilterException( "Could not find '" + attribute + allNames); } else { throw new IllegalFilterException( "Could not find '" + attribute
curExprssn = (FunctionExpression) function; } else { throw new IllegalFilterException( name + " not availabel as FunctionExpressio:" + function); break; default: throw new IllegalFilterException("Unsupported math expression");
break; default: throw new IllegalFilterException( "Not one of the accepted spatial filter types."); break; default: throw new IllegalFilterException( "Not one of the accepted spatial filter types."); break; default: throw new IllegalFilterException("Must be one of <,<=,==,>,>=,<>"); throw new IllegalFilterException("Filter start with invalid type: " + filterType);
public Expression getExpression2() { Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate(envelope.getMinX(), envelope.getMinY()); coords[1] = new Coordinate(envelope.getMinX(), envelope.getMaxY()); coords[2] = new Coordinate(envelope.getMaxX(), envelope.getMaxY()); coords[3] = new Coordinate(envelope.getMaxX(), envelope.getMinY()); coords[4] = new Coordinate(envelope.getMinX(), envelope.getMinY()); LinearRing ring = null; GeometryFactory gfac = new GeometryFactory(); try { ring = gfac.createLinearRing(coords); } catch (TopologyException tex) { throw new IllegalFilterException(tex.toString()); } Polygon polygon = gfac.createPolygon(ring, null); if (envelope instanceof ReferencedEnvelope) { ReferencedEnvelope refEnv = (ReferencedEnvelope) envelope; polygon.setUserData(refEnv.getCoordinateReferenceSystem()); } return factory.literal(polygon); }
/** * Generate bounding polygon for provided envelope. * * <p>For a ReferenedEnvelope the CoordinateReferenceSystem wil be preserved. * * @param env The envelope to set as the bounds. * @throws IllegalFilterException If the box can not be created. * @task Currently sets the SRID to null, which can cause problems with JTS when it comes to * doing spatial tests */ public static Polygon boundingPolygon(Envelope env) { Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate(env.getMinX(), env.getMinY()); coords[1] = new Coordinate(env.getMinX(), env.getMaxY()); coords[2] = new Coordinate(env.getMaxX(), env.getMaxY()); coords[3] = new Coordinate(env.getMaxX(), env.getMinY()); coords[4] = new Coordinate(env.getMinX(), env.getMinY()); LinearRing ring = null; try { ring = GEOMETRY_FACTORY.createLinearRing(coords); } catch (TopologyException tex) { throw new IllegalFilterException(tex.toString()); } Polygon polygon = GEOMETRY_FACTORY.createPolygon(ring, null); if (env instanceof ReferencedEnvelope) { ReferencedEnvelope refEnv = (ReferencedEnvelope) env; polygon.setUserData(refEnv.getCoordinateReferenceSystem()); } return polygon; }
public Expression getExpression2() { // in this case, the 3D BBOX falls back to regular 2D bbox behaviour (until there is more // support for 3D geometries) // 3DBBOX must be run as a post-filter in order to support the third coordinate. Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate(envelope.getMinX(), envelope.getMinY()); coords[1] = new Coordinate(envelope.getMinX(), envelope.getMaxY()); coords[2] = new Coordinate(envelope.getMaxX(), envelope.getMaxY()); coords[3] = new Coordinate(envelope.getMaxX(), envelope.getMinY()); coords[4] = new Coordinate(envelope.getMinX(), envelope.getMinY()); LinearRing ring = null; GeometryFactory gfac = new GeometryFactory(); try { ring = gfac.createLinearRing(coords); } catch (TopologyException tex) { throw new IllegalFilterException(tex.toString()); } Polygon polygon = gfac.createPolygon(ring, null); if (envelope instanceof ReferencedEnvelope3D) { ReferencedEnvelope3D refEnv = (ReferencedEnvelope3D) envelope; polygon.setUserData(refEnv.getCoordinateReferenceSystem()); } return factory.literal(polygon); }