Class Filter

  extended by corny.addressbook.searching.Filter.Filter
Direct Known Subclasses:
ContactFilter, MetaFilter

public abstract class Filter
extends java.lang.Object

Abstract filter class to use for searching the Address Book Contacts.

Filters can be created either by using the subclasses ContactFilter and MetaFilter or by using regular expressions.

ContactFilter implements the functionality for comparing the properties of Address Book contacts to a specified value. With a ContactFilter, you can only compare one property of the Address Book contacts. For example, you can filter all contacts whose address's street ends with "avenue"

MetaFilter lets you combine multiple ContactFilters by either the AND or the OR conjunction.

By using both the ContactFilter and the MetaFilter, you can create quite complex search queries.

The Usage of regular expressions makes creating Filters more comfortable. It lets you create complex search queries which compare contact properties against String, Integer, or double values or against null. Comparing against complex types (e.g. an Address or Date instance) isn't possible. To create a filter using regular expressions, call createFilter(String).


Constructor Summary
          Default constructor.
Method Summary
abstract  boolean appliesToFilter(Contact c)
          Used by NativeAddressBook to determine whether the Contact matches the search query
static Filter createFilter(java.lang.String expr)
          Creates a Filter instance by using a regular expression.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public Filter()
Default constructor.

Method Detail


public abstract boolean appliesToFilter(Contact c)
Used by NativeAddressBook to determine whether the Contact matches the search query

c - Contact to compare
True, if the Contact matches the search query


public static Filter createFilter(java.lang.String expr)
                           throws FilterParseException
Creates a Filter instance by using a regular expression.

A simple regular expression looks like "Contact_Property Comparison Value", e.g. "ADDRESS_STREET ENDS_WITH 'avenue'". To search only a specific type (home / work / mobile) of multivalue properties, you can specify the type after the property, separated by a dot or colon (e.g. "ADDRESS_STREET.home ENDS_WITH 'avenue'").

See ContactFilter for more information about possible contact properties and comparison types

Strings can either be surrounded by single or double quotes. If you want to compare against an integer, simply omit the quotes. A number containing a dot will be considered a double value.

Multiple queries of this type can be combined by AND / OR. You can use brackets to specify the order of executing the queries.

expr - The regular expression
Filter instance
FilterParseException - Will be thrown if the syntax contains errors.
See Also: