corny.addressbook.searching.Filter
Class ContactFilter

java.lang.Object
  extended by corny.addressbook.searching.Filter.Filter
      extended by corny.addressbook.searching.Filter.ContactFilter

public class ContactFilter
extends Filter

Filter class for filtering Contacts.

The enumeration ContactProperty declares all the Contact properties which can be searched in. A possible property can for example be the first name or the phone number.

There are multiple constants which declare the way in which the properties are compared. For example, you could check if a property contains a specified String (CONTAINS_SUBSTRING) or if a property is greater than a given Number (GREATER).

The value which the property is compared against can be either a String value or another class, like a Date or a Group. The ContactProperty documentation declares the possible classes which the property can be compared against.

Author:
Corny

Field Summary
static int CONTAINS_SUBSTRING
          The property should contain a given substring.
static int CONTAINS_SUBSTRING_CASE_SENSITIVE
           
static int ENDS_WITH
          The property should end with a given String.
static int ENDS_WITH_CASE_SENSITIVE
           
static int EQUAL
          The property should equal to a given value.
static int EQUAL_CASE_SENSITIVE
           
static int GREATER
          The property should be greater than a given value.
static int GREATER_OR_EQUAL
          The property should be greater or equal than a given value.
static int IN_GROUP
          The Contact should be contained in a given Group.
static int IN_GROUP_CASE_SENSITIVE
           
static int LESS
          The property should be less than a given value.
static int LESS_OR_EQUAL
          The property should be less or equal than a given value.
static int LIKE
          The property should match a given regular expression.
static int NOT_CONTAINS_SUBSTRING
           
static int NOT_CONTAINS_SUBSTRING_CASE_SENSITIVE
           
static int NOT_ENDS_WITH
           
static int NOT_ENDS_WITH_CASE_SENSITIVE
           
static int NOT_EQUAL
           
static int NOT_EQUAL_CASE_SENSITIVE
           
static int NOT_IN_GROUP
           
static int NOT_IN_GROUP_CASE_SENSITIVE
           
static int NOT_LIKE
           
static int NOT_PART_OF_STRING
           
static int NOT_PART_OF_STRING_CASE_SENSITIVE
           
static int NOT_STARTS_WITH
           
static int NOT_STARTS_WITH_CASE_SENSITIVE
           
static int PART_OF_STRING
          The property should be part of a given String.
static int PART_OF_STRING_CASE_SENSITIVE
           
static int STARTS_WITH
          The property should start with a given String.
static int STARTS_WITH_CASE_SENSITIVE
           
 
Constructor Summary
ContactFilter(ContactProperty property, int comparison, java.lang.Object value)
          Creates new ContactFilter which compares the selected property by the selected comparison to the given value.
ContactFilter(ContactProperty property, java.lang.String propertyLabel, int comparison, java.lang.Object value)
          Creates new ContactFilter which compares the selected property by the selected comparison to the given value.
 
Method Summary
 boolean appliesToFilter(Contact c)
          Used by NativeAddressBook to determine whether the Contact matches the search query
static java.lang.String getDefaultRegex(int comparison)
          Returns the default regular expression for a given comparison.
 java.lang.String toString()
           
 
Methods inherited from class corny.addressbook.searching.Filter.Filter
createFilter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EQUAL

public static final int EQUAL
The property should equal to a given value. Works with every property or value. If the class of the property is equal to the class of the value, they will be compared by the equals() method. Otherwise, the String representations will be compared.

See Also:
Constant Field Values

EQUAL_CASE_SENSITIVE

public static final int EQUAL_CASE_SENSITIVE
See Also:
EQUAL, Constant Field Values

NOT_EQUAL

public static final int NOT_EQUAL
See Also:
EQUAL, Constant Field Values

NOT_EQUAL_CASE_SENSITIVE

public static final int NOT_EQUAL_CASE_SENSITIVE
See Also:
EQUAL, Constant Field Values

GREATER

public static final int GREATER
The property should be greater than a given value. Works if the property's and the value's class are the same and Comparable against each other.

See Also:
Constant Field Values

GREATER_OR_EQUAL

public static final int GREATER_OR_EQUAL
The property should be greater or equal than a given value. Works if the property's and the value's class are the same and Comparable against each other.

See Also:
Constant Field Values

LESS

public static final int LESS
The property should be less than a given value. Works if the property's and the value's class are the same and Comparable against each other.

See Also:
Constant Field Values

LESS_OR_EQUAL

public static final int LESS_OR_EQUAL
The property should be less or equal than a given value. Works if the property's and the value's class are the same and Comparable against each other.

See Also:
Constant Field Values

CONTAINS_SUBSTRING

public static final int CONTAINS_SUBSTRING
The property should contain a given substring. Works with every kind of property and value. If the property or the value isn't a String, the String representation will be used.

See Also:
Constant Field Values

CONTAINS_SUBSTRING_CASE_SENSITIVE

public static final int CONTAINS_SUBSTRING_CASE_SENSITIVE
See Also:
CONTAINS_SUBSTRING, Constant Field Values

NOT_CONTAINS_SUBSTRING

public static final int NOT_CONTAINS_SUBSTRING
See Also:
CONTAINS_SUBSTRING, Constant Field Values

NOT_CONTAINS_SUBSTRING_CASE_SENSITIVE

public static final int NOT_CONTAINS_SUBSTRING_CASE_SENSITIVE
See Also:
CONTAINS_SUBSTRING, Constant Field Values

ENDS_WITH

public static final int ENDS_WITH
The property should end with a given String. Works with every kind of property and value. If the property or the value isn't a String, the String representation will be used.

See Also:
Constant Field Values

ENDS_WITH_CASE_SENSITIVE

public static final int ENDS_WITH_CASE_SENSITIVE
See Also:
ENDS_WITH, Constant Field Values

NOT_ENDS_WITH

public static final int NOT_ENDS_WITH
See Also:
ENDS_WITH, Constant Field Values

NOT_ENDS_WITH_CASE_SENSITIVE

public static final int NOT_ENDS_WITH_CASE_SENSITIVE
See Also:
ENDS_WITH, Constant Field Values

STARTS_WITH

public static final int STARTS_WITH
The property should start with a given String. Works with every kind of property and value. If the property or the value isn't a String, the String representation will be used.

See Also:
Constant Field Values

STARTS_WITH_CASE_SENSITIVE

public static final int STARTS_WITH_CASE_SENSITIVE
See Also:
STARTS_WITH, Constant Field Values

NOT_STARTS_WITH

public static final int NOT_STARTS_WITH
See Also:
STARTS_WITH, Constant Field Values

NOT_STARTS_WITH_CASE_SENSITIVE

public static final int NOT_STARTS_WITH_CASE_SENSITIVE
See Also:
STARTS_WITH, Constant Field Values

PART_OF_STRING

public static final int PART_OF_STRING
The property should be part of a given String. Works with every kind of property and value. If the property or the value isn't a String, the String representation will be used.

See Also:
Constant Field Values

PART_OF_STRING_CASE_SENSITIVE

public static final int PART_OF_STRING_CASE_SENSITIVE
See Also:
PART_OF_STRING, Constant Field Values

NOT_PART_OF_STRING

public static final int NOT_PART_OF_STRING
See Also:
PART_OF_STRING, Constant Field Values

NOT_PART_OF_STRING_CASE_SENSITIVE

public static final int NOT_PART_OF_STRING_CASE_SENSITIVE
See Also:
PART_OF_STRING, Constant Field Values

IN_GROUP

public static final int IN_GROUP
The Contact should be contained in a given Group. Works only with the CONTACT property and with every type of value. If the value is instanceof Group, the UID will be compared to the UID of every parent group of the Contact. Otherwise, the String representation will be compared to the Names of the parent groups.

See Also:
Constant Field Values

NOT_IN_GROUP

public static final int NOT_IN_GROUP
See Also:
IN_GROUP, Constant Field Values

IN_GROUP_CASE_SENSITIVE

public static final int IN_GROUP_CASE_SENSITIVE
See Also:
IN_GROUP, Constant Field Values

NOT_IN_GROUP_CASE_SENSITIVE

public static final int NOT_IN_GROUP_CASE_SENSITIVE
See Also:
IN_GROUP, Constant Field Values

LIKE

public static final int LIKE
The property should match a given regular expression. See Pattern for more details about regular expressions. Works with every kind of property but only with String values. If the property isn't a String, the String representation will be used. Comparison using LIKE is always case sensitive.

See Also:
Constant Field Values

NOT_LIKE

public static final int NOT_LIKE
See Also:
LIKE, Constant Field Values
Constructor Detail

ContactFilter

public ContactFilter(ContactProperty property,
                     java.lang.String propertyLabel,
                     int comparison,
                     java.lang.Object value)
Creates new ContactFilter which compares the selected property by the selected comparison to the given value.

Parameters:
property - Property of the Contacts which should be compared
comparison - Comparison type
propertyLabel - The label (key) of the property, if the property is a multi value type (like the Phone Property)
value - The Contact property will be compared to this value

ContactFilter

public ContactFilter(ContactProperty property,
                     int comparison,
                     java.lang.Object value)
Creates new ContactFilter which compares the selected property by the selected comparison to the given value. If searching in MultiValue properties, the key will be ignored.

Parameters:
property - Property of the Contacts which should be compared
comparison - Comparison type
value - The Contact property will be compared to this value
Method Detail

getDefaultRegex

public static java.lang.String getDefaultRegex(int comparison)
Returns the default regular expression for a given comparison.

Parameters:
comparison - Comparison
Returns:
Default regular expression

appliesToFilter

public boolean appliesToFilter(Contact c)
Description copied from class: Filter
Used by NativeAddressBook to determine whether the Contact matches the search query

Specified by:
appliesToFilter in class Filter
Parameters:
c - Contact to compare
Returns:
True, if the Contact matches the search query

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object