001 /*
002 * GeoAPI - Java interfaces for OGC/ISO standards
003 * http://www.geoapi.org
004 *
005 * Copyright (C) 2006-2013 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.XmlElement;
035 import org.opengis.feature.Feature;
036 import org.opengis.feature.type.FeatureType; // For javadoc
037
038
039 /**
040 * Defines a constraint that can be checked against an instance of an object (Usually a Feature).
041 * <p?
042 * This is an abstract super type of the Filters defined by the Filter specification; you are not
043 * free to define your own filters. For extensibility please explore the definition of
044 * your own {@link Function}.
045 * <p>
046 * Often a filter is used to to define a set {@linkplain Feature feature} instances
047 * that are to be operated upon. The operating set can be comprised of one or more
048 * enumerated features or a set of features defined by specifying spatial and
049 * non-spatial constraints on the geometric and scalar properties of a feature type.
050 * <p>
051 * Roughly speaking, a filter encodes the information present in the {@code WHERE}
052 * clause of a SQL statement. There are various subclasses of this class that
053 * implement many types of filters, such as simple property comparisons or spatial
054 * queries.
055 * <p>
056 * The second use of Filter focuses on expressing constraints (or Facets). This use
057 * places restrictions on the allowable and is captured as part of schema information
058 * (@linkplain FeatureType). This is similar to the XML concept of "facets".
059 * </p>
060 *
061 * @version <A HREF="http://www.opengis.org/docs/02-059.pdf">Implementation specification 1.0</A>
062 * @author Chris Dillard (SYS Technologies)
063 * @since GeoAPI 2.0
064 */
065 @XmlElement("Filter")
066 public interface Filter {
067 /**
068 * Placeholder Filter that evaulates to {@code true}.
069 * <p>
070 * Filtering a set with {@code Filter.INCLUDE} results in the origional set.
071 */
072 IncludeFilter INCLUDE = new IncludeFilter();
073
074 /**
075 * Placeholder Filter that evaulates to {@code false}.
076 * <p>
077 * Filtering a set with {@code Filter.EXCLUDE} results in the empty Set.
078 */
079 ExcludeFilter EXCLUDE = new ExcludeFilter();
080
081 /**
082 * Give an object, this method determines if the test(s) represented by this filter object
083 * are passed.
084 * <p>
085 * This ability is used to allow Queries against both Features and and non spatial data (such as Record) and
086 * to express constraints on permissable data values.
087 * </p>
088 * @param object
089 * @return <code>true</true> if the test(s) are passed for the provided object
090 */
091 boolean evaluate(Object object);
092
093 /**
094 * Accepts a visitor.
095 * <p>
096 * Implementations of all subinterfaces must have with a
097 * method whose content is the following:
098 * <pre>return visitor.{@linkplain FilterVisitor#visit visit}(this, extraData);</pre>
099 * </p>
100 */
101 Object accept(FilterVisitor visitor, Object extraData);
102 }