1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
7 * @requires OpenLayers/Filter.js
11 * Class: OpenLayers.Filter.Logical
12 * This class represents ogc:And, ogc:Or and ogc:Not rules.
15 * - <OpenLayers.Filter>
17 OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {
20 * APIProperty: filters
21 * {Array(<OpenLayers.Filter>)} Child filters for this filter.
27 * {String} type of logical operator. Available types are:
28 * - OpenLayers.Filter.Logical.AND = "&&";
29 * - OpenLayers.Filter.Logical.OR = "||";
30 * - OpenLayers.Filter.Logical.NOT = "!";
35 * Constructor: OpenLayers.Filter.Logical
36 * Creates a logical filter (And, Or, Not).
39 * options - {Object} An optional object with properties to set on the
43 * {<OpenLayers.Filter.Logical>}
45 initialize: function(options) {
47 OpenLayers.Filter.prototype.initialize.apply(this, [options]);
52 * Remove reference to child filters.
56 OpenLayers.Filter.prototype.destroy.apply(this);
61 * Evaluates this filter in a specific context. Should be implemented by
65 * context - {Object} Context to use in evaluating the filter.
68 * {Boolean} The filter applies.
70 evaluate: function(context) {
72 case OpenLayers.Filter.Logical.AND:
73 for (var i=0, len=this.filters.length; i<len; i++) {
74 if (this.filters[i].evaluate(context) == false) {
80 case OpenLayers.Filter.Logical.OR:
81 for (var i=0, len=this.filters.length; i<len; i++) {
82 if (this.filters[i].evaluate(context) == true) {
88 case OpenLayers.Filter.Logical.NOT:
89 return (!this.filters[0].evaluate(context));
98 * {<OpenLayers.Filter.Logical>} Clone of this filter.
102 for(var i=0, len=this.filters.length; i<len; ++i) {
103 filters.push(this.filters[i].clone());
105 return new OpenLayers.Filter.Logical({
111 CLASS_NAME: "OpenLayers.Filter.Logical"
115 OpenLayers.Filter.Logical.AND = "&&";
116 OpenLayers.Filter.Logical.OR = "||";
117 OpenLayers.Filter.Logical.NOT = "!";