com.vaadin.data.util.filter
Class SimpleStringFilter

java.lang.Object
  extended by com.vaadin.data.util.filter.SimpleStringFilter
All Implemented Interfaces:
Container.Filter, Serializable

public final class SimpleStringFilter
extends Object
implements Container.Filter

Simple string filter for matching items that start with or contain a specified string. The matching can be case-sensitive or case-insensitive. This filter also directly supports in-memory filtering. When performing in-memory filtering, values of other types are converted using toString(), but other (lazy container) implementations do not need to perform such conversions and might not support values of different types. Note that this filter is modeled after the pre-6.6 filtering mechanisms, and might not be very efficient e.g. for database filtering. TODO this might still change

Since:
6.6
See Also:
Serialized Form

Constructor Summary
SimpleStringFilter(Object propertyId, String filterString, boolean ignoreCase, boolean onlyMatchPrefix)
           
 
Method Summary
 boolean appliesToProperty(Object propertyId)
          Check if a change in the value of a property can affect the filtering result.
 boolean equals(Object obj)
           
 String getFilterString()
          Returns the filter string.
 Object getPropertyId()
          Returns the property identifier to which this filter applies.
 int hashCode()
           
 boolean isIgnoreCase()
          Returns whether the filter is case-insensitive or case-sensitive.
 boolean isOnlyMatchPrefix()
          Returns true if the filter only applies to the beginning of the value string, false for any location in the value.
 boolean passesFilter(Object itemId, Item item)
          Check if an item passes the filter (in-memory filtering).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleStringFilter

public SimpleStringFilter(Object propertyId,
                          String filterString,
                          boolean ignoreCase,
                          boolean onlyMatchPrefix)
Method Detail

passesFilter

public boolean passesFilter(Object itemId,
                            Item item)
Description copied from interface: Container.Filter
Check if an item passes the filter (in-memory filtering).

Specified by:
passesFilter in interface Container.Filter
Parameters:
itemId - identifier of the item being filtered; may be null when the item is being added to the container
item - the item being filtered
Returns:
true if the item is accepted by this filter

appliesToProperty

public boolean appliesToProperty(Object propertyId)
Description copied from interface: Container.Filter
Check if a change in the value of a property can affect the filtering result. May always return true, at the cost of performance. If the filter cannot determine whether it may depend on the property or not, should return true.

Specified by:
appliesToProperty in interface Container.Filter
Returns:
true if the filtering result may/does change based on changes to the property identified by propertyId

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getPropertyId

public Object getPropertyId()
Returns the property identifier to which this filter applies.

Returns:
property id

getFilterString

public String getFilterString()
Returns the filter string. Note: this method is intended only for implementations of lazy string filters and may change in the future.

Returns:
filter string given to the constructor

isIgnoreCase

public boolean isIgnoreCase()
Returns whether the filter is case-insensitive or case-sensitive. Note: this method is intended only for implementations of lazy string filters and may change in the future.

Returns:
true if performing case-insensitive filtering, false for case-sensitive

isOnlyMatchPrefix

public boolean isOnlyMatchPrefix()
Returns true if the filter only applies to the beginning of the value string, false for any location in the value. Note: this method is intended only for implementations of lazy string filters and may change in the future.

Returns:
true if checking for matches at the beginning of the value only, false if matching any part of value


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.