com.levigo.util.base.glazedlists.matchers
Class TextMatcherEditor<E>

java.lang.Object
  extended by com.levigo.util.base.glazedlists.matchers.AbstractMatcherEditor<E>
      extended by com.levigo.util.base.glazedlists.matchers.TextMatcherEditor<E>
All Implemented Interfaces:
MatcherEditor<E>
Direct Known Subclasses:
SearchEngineTextMatcherEditor, TextComponentMatcherEditor

public class TextMatcherEditor<E>
extends AbstractMatcherEditor<E>

A matcher editor that matches Objects that contain a filter text string. This TextMatcherEditor is not coupled with any UI component that allows the user to edit the filter text. That job is left to subclasses. This matcher editor is fully concrete, and may be used directly by headless applications.

The TextMatcherEditor requires that either a TextFilterator be specified in its constructor, or that every Object to be matched implements the TextFilterable interface. These are used to extract the searchable Strings for each Object.

TextMatcherEditor is able to operate in one of three modes.

TextMatcherEditor is able to operate with one of two strategies.

Author:
James Lemieux, Jesse Wilson

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.levigo.util.base.glazedlists.matchers.MatcherEditor
MatcherEditor.Event<E>, MatcherEditor.Listener<E>
 
Field Summary
static int CONTAINS
          Matching mode where items are considered a match if at least one of the filter strings extracted from an object contains one of the given search strings.
static int EXACT
          Matching mode where items are considered a match if they are an exact character for character match with at least one of the filter strings.
static Object IDENTICAL_STRATEGY
          Character comparison strategy that assumes all characters can be compared directly as though they are ASCII.
static Object NORMALIZED_STRATEGY
          Character comparison strategy that assumes all Latin characters should have their diacritical marks stripped in an effort to normalize words to their most basic form.
static int REGULAR_EXPRESSION
          Matching mode where items are considered a match using a Matcher produced by compiling a regular expression into Pattern.
static int STARTS_WITH
          Matching mode where items are considered a match if at least one of the filter strings extracted from an object starts with one of the given search strings.
 
Fields inherited from class com.levigo.util.base.glazedlists.matchers.AbstractMatcherEditor
currentMatcher
 
Constructor Summary
TextMatcherEditor()
          Creates a TextMatcherEditor whose Matchers can test only elements which implement the TextFilterable interface.
TextMatcherEditor(TextFilterator<? super E> filterator)
          Creates a TextMatcherEditor that matches Objects using the specified TextFilterator to get the Strings to search.
 
Method Summary
protected  com.levigo.util.base.internal.glazedlists.filter.TextMatcher<E> getCurrentTextMatcher()
          Return the current Matcher if it is a TextMatcher or null if no current Matcher exists or is something other than a TextMatcher.
 TextFilterator<? super E> getFilterator()
          Get the filterator used to extract Strings from the matched elements.
 int getMode()
          Returns the behaviour mode for this TextMatcherEditor.
 Object getStrategy()
          Returns the character comparison strategy for this TextMatcherEditor.
 void setFilterator(TextFilterator<? super E> filterator)
          Set the filterator used to extract Strings from the matched elements.
 void setFilterText(String[] newFilters)
          Adjusts the filters of this TextMatcherEditor and fires a change to the Matcher.
 void setMode(int mode)
          Modify the behaviour of this TextMatcherEditor to one of the predefined modes.
 void setStrategy(Object strategy)
          Modify the character matching strategy of this TextMatcherEditor to one of the predefined strategies.
protected  void setTextMatcher(com.levigo.util.base.internal.glazedlists.filter.TextMatcher<E> newMatcher)
          This method replaces the current Matcher in this TextMatcherEditor with the newMatcher if it is different.
 
Methods inherited from class com.levigo.util.base.glazedlists.matchers.AbstractMatcherEditor
addMatcherEditorListener, fireChanged, fireChangedMatcher, fireConstrained, fireMatchAll, fireMatchNone, fireRelaxed, getMatcher, isCurrentlyMatchingAll, isCurrentlyMatchingNone, removeMatcherEditorListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTAINS

public static final int CONTAINS
Matching mode where items are considered a match if at least one of the filter strings extracted from an object contains one of the given search strings.

See Also:
Constant Field Values

STARTS_WITH

public static final int STARTS_WITH
Matching mode where items are considered a match if at least one of the filter strings extracted from an object starts with one of the given search strings.

See Also:
Constant Field Values

REGULAR_EXPRESSION

public static final int REGULAR_EXPRESSION
Matching mode where items are considered a match using a Matcher produced by compiling a regular expression into Pattern.

See Also:
Constant Field Values

EXACT

public static final int EXACT
Matching mode where items are considered a match if they are an exact character for character match with at least one of the filter strings.

See Also:
Constant Field Values

IDENTICAL_STRATEGY

public static final Object IDENTICAL_STRATEGY
Character comparison strategy that assumes all characters can be compared directly as though they are ASCII. This implies there is no fuzzy matching with this strategy - each character must be precisely matched.


NORMALIZED_STRATEGY

public static final Object NORMALIZED_STRATEGY
Character comparison strategy that assumes all Latin characters should have their diacritical marks stripped in an effort to normalize words to their most basic form. This allows a degree of fuzziness within the matching algorithm, since words like "resume" will match similar words with diacritics like "r�sum�". This strategy is particularly useful when the text to be searched contains text like names in foreign languages, and your application would like search terms such as "Muller" to match the actual native spelling: "M�ller".

Constructor Detail

TextMatcherEditor

public TextMatcherEditor()
Creates a TextMatcherEditor whose Matchers can test only elements which implement the TextFilterable interface.

The Matchers from this MatcherEditor will throw a ClassCastException when called with an Object that does not implement TextFilterable.


TextMatcherEditor

public TextMatcherEditor(TextFilterator<? super E> filterator)
Creates a TextMatcherEditor that matches Objects using the specified TextFilterator to get the Strings to search.

Parameters:
filterator - the object that will extract filter Strings from each object in the source; null indicates the list elements implement TextFilterable
Method Detail

getFilterator

public TextFilterator<? super E> getFilterator()
Get the filterator used to extract Strings from the matched elements.


setFilterator

public void setFilterator(TextFilterator<? super E> filterator)
Set the filterator used to extract Strings from the matched elements.


setMode

public void setMode(int mode)
Modify the behaviour of this TextMatcherEditor to one of the predefined modes.

Parameters:
mode - either CONTAINS, STARTS_WITH, REGULAR_EXPRESSION, or EXACT

getMode

public int getMode()
Returns the behaviour mode for this TextMatcherEditor.

Returns:
one of CONTAINS (default), STARTS_WITH, REGULAR_EXPRESSION, or EXACT

setStrategy

public void setStrategy(Object strategy)
Modify the character matching strategy of this TextMatcherEditor to one of the predefined strategies. See the documentation for each constant in order contrast the strategies.

Parameters:
strategy - either IDENTICAL_STRATEGY or NORMALIZED_STRATEGY

getStrategy

public Object getStrategy()
Returns the character comparison strategy for this TextMatcherEditor. See the documentation for each constant in order contrast the strategies.

Returns:
one of IDENTICAL_STRATEGY or NORMALIZED_STRATEGY

getCurrentTextMatcher

protected com.levigo.util.base.internal.glazedlists.filter.TextMatcher<E> getCurrentTextMatcher()
Return the current Matcher if it is a TextMatcher or null if no current Matcher exists or is something other than a TextMatcher.


setFilterText

public void setFilterText(String[] newFilters)
Adjusts the filters of this TextMatcherEditor and fires a change to the Matcher.

Parameters:
newFilters - the Strings representing all of the filter values

setTextMatcher

protected void setTextMatcher(com.levigo.util.base.internal.glazedlists.filter.TextMatcher<E> newMatcher)
This method replaces the current Matcher in this TextMatcherEditor with the newMatcher if it is different. If the current Matcher is also a TextMatcher then many comparisons between the two in order to determine if the new Matcher is a strict constrainment or relaxation of the current TextMatcher.

Parameters:
newMatcher - new TextMatcher which defines the text filtering logic


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.