JIDE 3.3.1

com.jidesoft.filter
Class RegexFilter<T>

java.lang.Object
  extended by com.jidesoft.filter.AbstractFilter<T>
      extended by com.jidesoft.filter.RegexFilter<T>
All Implemented Interfaces:
Filter<T>, Serializable, Cloneable
Direct Known Subclasses:
LikeFilter, WildcardFilter

public class RegexFilter<T>
extends AbstractFilter<T>

A filter implements filtering a string based the regular expression as defined in Java Pattern class.

See Also:
Serialized Form

Field Summary
protected  boolean _beginWith
           
protected  Pattern _regex
           
 
Fields inherited from interface com.jidesoft.filter.Filter
ALL, CUSTOM, NULL
 
Constructor Summary
RegexFilter()
           
RegexFilter(String pattern)
           
 
Method Summary
protected  String convertElementToString(T value)
          Converts an element to String.
protected  String convertFromPatternToRegex(String pattern)
          Converts the input pattern to the pattern used in Java Pattern class.
 boolean equals(Object obj)
           
 String getPattern()
          Gets the pattern string.
 boolean isBeginWith()
          Checks if the filter only matches the pattern from the beginning of the string.
 boolean isCaseSensitive()
          Checks if the filter is case sensitive.
 boolean isEndWith()
          Checks if the filter only matches the pattern from the end of the string.
 boolean isValueFiltered(T value)
          Checks to see if the value should be filtered.
 void setBeginWith(boolean beginWith)
          Sets the begingWidth flag.
 void setCaseSensitive(boolean caseSensitive)
          Sets the case sensitive.
 void setEndWith(boolean endWith)
          Sets the endWith flag.
 void setPattern(String pattern)
          Sets the pattern.
 boolean stricterThan(Filter inputFilter)
          Check if this filter is stricter than the input filter while the two filters are with the same class.
 
Methods inherited from class com.jidesoft.filter.AbstractFilter
addFilterListener, clone, fireFilterChanged, fireFilterContentChanged, fireFilterDisabled, fireFilterEnabled, fireFilterNameChanged, getConditionString, getFilterFactory, getFilterFactoryName, getFilterListeners, getName, isEnabled, removeFilterListener, setEnabled, setFilterFactory, setFilterFactoryName, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_regex

protected Pattern _regex

_beginWith

protected boolean _beginWith
Constructor Detail

RegexFilter

public RegexFilter()

RegexFilter

public RegexFilter(String pattern)
Method Detail

isValueFiltered

public boolean isValueFiltered(T value)
Description copied from interface: Filter
Checks to see if the value should be filtered.

Parameters:
value - the value to filter
Returns:
true if the value should be filtered. Otherwise false.

convertElementToString

protected String convertElementToString(T value)
Converts an element to String. By default we will use ObjectConverterManager.toString(value) to convert.

Parameters:
value - the element to be filtered.
Returns:
the String version of the value.

convertFromPatternToRegex

protected String convertFromPatternToRegex(String pattern)
Converts the input pattern to the pattern used in Java Pattern class.

Parameters:
pattern - the input pattern.
Returns:
the pattern string used by Pattern.

setPattern

public void setPattern(String pattern)
Sets the pattern.

Parameters:
pattern - the new pattern.
See Also:
Pattern

getPattern

public String getPattern()
Gets the pattern string.

Returns:
the pattern string.

isCaseSensitive

public boolean isCaseSensitive()
Checks if the filter is case sensitive.

Returns:
true if case sensitive. Otherwise false.

setCaseSensitive

public void setCaseSensitive(boolean caseSensitive)
Sets the case sensitive.

Parameters:
caseSensitive - true or false.

isBeginWith

public boolean isBeginWith()
Checks if the filter only matches the pattern from the beginning of the string.

Returns:
true or false.

setBeginWith

public void setBeginWith(boolean beginWith)
Sets the begingWidth flag. If true, the filter will match the pattern from the beginning of the string. Note that if both begingWith and endWith flag are true, it means "match exactly". If both flags are false, it means "match anywhere".

Parameters:
beginWith - true or false.

isEndWith

public boolean isEndWith()
Checks if the filter only matches the pattern from the end of the string.

Returns:
true or false.

setEndWith

public void setEndWith(boolean endWith)
Sets the endWith flag. If true, the filter will match the pattern from the end of the string.

Parameters:
endWith - true or false.

stricterThan

public boolean stricterThan(Filter inputFilter)
Check if this filter is stricter than the input filter while the two filters are with the same class.

Since we don't have a good algorithm to parse the regular expression, so far we just take it as a normal String.

Specified by:
stricterThan in interface Filter<T>
Overrides:
stricterThan in class AbstractFilter<T>
Parameters:
inputFilter - the input filter
Returns:
true if the pattern string in this filter contains the patter string in the input filter. Otherwise false.

equals

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

JIDE 3.3.1