# OpenLayers.Filter.Comparison

This class represents a comparison filter.

#### Inherits from

- OpenLayers.Filter

Summary

OpenLayers.Filter.Comparison | This class represents a comparison filter.
Properties |
type | {String} type: type of the comparison.
property | {String} name of the context property to compare
value | {Number} or {String} comparison value for binary comparisons.
matchCase | {Boolean} Force case sensitive searches for EQUAL_TO and NOT_EQUAL_TO comparisons.
lowerBoundary | {Number} or {String} lower boundary for between comparisons.
upperBoundary | {Number} or {String} upper boundary for between comparisons.
Constructor |
OpenLayers.Filter.Comparison | Creates a comparison rule.
Functions |
evaluate | Evaluates this filter in a specific context.
value2regex | Converts the value of this rule into a regular expression string, according to the wildcard characters specified.
regex2value | Convert the value of this rule from a regular expression string into an ogc literal string using a wildCard of *, a singleChar of ., and an escape of !.
clone | Clones this filter.

### Properties

### type

{String} type: type of the comparison. This is one of

- OpenLayers.Filter.Comparison.EQUAL_TO = “==”;
- OpenLayers.Filter.Comparison.NOT_EQUAL_TO = “!=”;
- OpenLayers.Filter.Comparison.LESS_THAN = “<”;
- OpenLayers.Filter.Comparison.GREATER_THAN = “>”;
- OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = “<=”;
- OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = “>=”;
- OpenLayers.Filter.Comparison.BETWEEN = “..”;
- OpenLayers.Filter.Comparison.LIKE = “~”;

### property

{String} name of the context property to compare

### value

{Number} or {String} comparison value for binary comparisons. In the case of a String, this can be a combination of text and propertyNames in the form “literal ${propertyName}”

### matchCase

{Boolean} Force case sensitive searches for EQUAL_TO and NOT_EQUAL_TO comparisons. The Filter Encoding 1.1 specification added a matchCase attribute to ogc:PropertyIsEqualTo and ogc:PropertyIsNotEqualTo elements. This property will be serialized with those elements only if using the v1.1.0 filter format. However, when evaluating filters here, the matchCase property will always be respected (for EQUAL_TO and NOT_EQUAL_TO). Default is true.

### lowerBoundary

{Number} or {String} lower boundary for between comparisons. In the case of a String, this can be a combination of text and propertyNames in the form “literal ${propertyName}”

### upperBoundary

{Number} or {String} upper boundary for between comparisons. In the case of a String, this can be a combination of text and propertyNames in the form “literal ${propertyName}”

### Constructor

### OpenLayers.Filter.Comparison

Creates a comparison rule.

#### Parameters

options | {Object} An optional object with properties to set on the rule

#### Returns

{OpenLayers.Filter.Comparison}

### Functions

### evaluate

> evaluate: function( | context | )

Evaluates this filter in a specific context.

#### Parameters

context | {Object} Context to use in evaluating the filter. If a vector feature is provided, the feature.attributes will be used as context.

#### Returns

{Boolean} The filter applies.

### value2regex

> value2regex: function( | wildCard,
> | singleChar,
> | escapeChar | )

Converts the value of this rule into a regular expression string, according to the wildcard characters specified. This method has to be called after instantiation of this class, if the value is not a regular expression already.

#### Parameters

wildCard | {Char} wildcard character in the above value, default is “*”
singleChar | {Char} single-character wildcard in the above value default is “.”
escapeChar | {Char} escape character in the above value, default is “!”

#### Returns

{String} regular expression string

### regex2value

> regex2value: function()

Convert the value of this rule from a regular expression string into an ogc literal string using a wildCard of *, a singleChar of ., and an escape of !. Leaves the value property unmodified.

#### Returns

{String} A string value.

### clone

> clone: function()

Clones this filter.

#### Returns

{OpenLayers.Filter.Comparison} Clone of this filter.

> evaluate: function( | context | )

Evaluates this filter in a specific context.

> value2regex: function( | wildCard,
> | singleChar,
> | escapeChar | )

Converts the value of this rule into a regular expression string, according to the wildcard characters specified.

> regex2value: function()

Convert the value of this rule from a regular expression string into an ogc literal string using a wildCard of *, a singleChar of ., and an escape of !.

> clone: function()

Clones this filter.
This class represents an OGC Filter.
Creates a comparison rule.
{Number} or {String} comparison value for binary comparisons.
Close