001 /*
002 * GeoAPI - Java interfaces for OGC/ISO standards
003 * http://www.geoapi.org
004 *
005 * Copyright (C) 2006-2012 Open Geospatial Consortium, Inc.
006 * All Rights Reserved. http://www.opengeospatial.org/ogc/legal
007 *
008 * Permission to use, copy, and modify this software and its documentation, with
009 * or without modification, for any purpose and without fee or royalty is hereby
010 * granted, provided that you include the following on ALL copies of the software
011 * and documentation or portions thereof, including modifications, that you make:
012 *
013 * 1. The full text of this NOTICE in a location viewable to users of the
014 * redistributed or derivative work.
015 * 2. Notice of any changes or modifications to the OGC files, including the
016 * date changes were made.
017 *
018 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
019 * NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
020 * TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
021 * THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
022 * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
023 *
024 * COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
025 * CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
026 *
027 * The name and trademarks of copyright holders may NOT be used in advertising or
028 * publicity pertaining to the software without specific, written prior permission.
029 * Title to copyright in this software and any associated documentation will at all
030 * times remain with copyright holders.
031 */
032 package org.opengis.filter;
033
034 import org.opengis.annotation.Extension;
035 import org.opengis.annotation.XmlElement;
036 import org.opengis.feature.Feature;
037 import org.opengis.feature.type.FeatureType; // For javadoc
038
039
040 /**
041 * Defines a constraint that can be checked against an instance of an object (Usually a Feature).
042 * <p?
043 * This is an abstract super type of the Filters defined by the Filter specification; you are not
044 * free to define your own filters. For extensibility please explore the definition of
045 * your own {@link Function}.
046 * <p>
047 * Often a filter is used to to define a set {@linkplain Feature feature} instances
048 * that are to be operated upon. The operating set can be comprised of one or more
049 * enumerated features or a set of features defined by specifying spatial and
050 * non-spatial constraints on the geometric and scalar properties of a feature type.
051 * <p>
052 * Roughly speaking, a filter encodes the information present in the {@code WHERE}
053 * clause of a SQL statement. There are various subclasses of this class that
054 * implement many types of filters, such as simple property comparisons or spatial
055 * queries.
056 * <p>
057 * The second use of Filter focuses on expressing constraints (or Facets). This use
058 * places restrictions on the allowable and is captured as part of schema information
059 * (@linkplain FeatureType). This is similar to the XML concept of "facets".
060 * </p>
061 *
062 * @version <A HREF="http://www.opengis.org/docs/02-059.pdf">Implementation specification 1.0</A>
063 * @author Chris Dillard (SYS Technologies)
064 * @since GeoAPI 2.0
065 */
066 @XmlElement("Filter")
067 public interface Filter {
068 /**
069 * Placeholder Filter that evaulates to {@code true}.
070 * <p>
071 * Filtering a set with {@code Filter.INCLUDE} results in the origional set.
072 */
073 IncludeFilter INCLUDE = new IncludeFilter();
074
075 /**
076 * Placeholder Filter that evaulates to {@code false}.
077 * <p>
078 * Filtering a set with {@code Filter.EXCLUDE} results in the empty Set.
079 */
080 ExcludeFilter EXCLUDE = new ExcludeFilter();
081
082 /**
083 * Give an object, this method determines if the test(s) represented by this filter object
084 * are passed.
085 * <p>
086 * This ability is used to allow Queries against both Features and and non spatial data (such as Record) and
087 * to express constraints on permissable data values.
088 * </p>
089 * @param object
090 * @return <code>true</true> if the test(s) are passed for the provided object
091 */
092 boolean evaluate(Object object);
093
094 /**
095 * Accepts a visitor.
096 * <p>
097 * Implementations of all subinterfaces must have with a
098 * method whose content is the following:
099 * <pre>return visitor.{@linkplain FilterVisitor#visit visit}(this, extraData);</pre>
100 * </p>
101 */
102 @Extension
103 Object accept(FilterVisitor visitor, Object extraData);
104 }