# 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.
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.
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 = “~”;
- OpenLayers.Filter.Comparison.IS_NULL = “NULL”;

### 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}”

### 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

### 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.

> clone: function()

Clones this filter.
This class represents an OGC Filter.
Creates a comparison rule.
Close