com.sun.data.provider.impl
Class RegexFilterCriteria

java.lang.Object
  extended by com.sun.data.provider.FilterCriteria
      extended by com.sun.data.provider.impl.RegexFilterCriteria
All Implemented Interfaces:
java.io.Serializable

public class RegexFilterCriteria
extends FilterCriteria

The RegexFilterCriteria is an implementation of FilterCriteria that matches a regular expression with the toString() value of a FieldKey in a TableDataProvider.

See Also:
Serialized Form

Field Summary
protected  java.util.regex.Pattern pattern
          Storage for the Pattern
 
Constructor Summary
RegexFilterCriteria()
           
RegexFilterCriteria(FieldKey fieldKey)
           
RegexFilterCriteria(FieldKey fieldKey, java.lang.String expression)
           
RegexFilterCriteria(java.lang.String expression)
           
 
Method Summary
 java.lang.String getDisplayName()
          Returns the display name for this filter criteria.
 java.lang.String getExpression()
           
 FieldKey getFieldKey()
           
 boolean match(TableDataProvider provider, RowKey row)
          This method tests for a pattern match in the toString() value of the data item stored under the FieldKey at the specified row.
 void setExpression(java.lang.String expression)
           
 void setFieldKey(FieldKey fieldKey)
           
 
Methods inherited from class com.sun.data.provider.FilterCriteria
isInclude, setDisplayName, setInclude
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pattern

protected java.util.regex.Pattern pattern
Storage for the Pattern

Constructor Detail

RegexFilterCriteria

public RegexFilterCriteria()

RegexFilterCriteria

public RegexFilterCriteria(FieldKey fieldKey)
Parameters:
fieldKey - FieldKey

RegexFilterCriteria

public RegexFilterCriteria(java.lang.String expression)
                    throws java.util.regex.PatternSyntaxException
Parameters:
expression - String
Throws:
java.util.regex.PatternSyntaxException

RegexFilterCriteria

public RegexFilterCriteria(FieldKey fieldKey,
                           java.lang.String expression)
                    throws java.util.regex.PatternSyntaxException
Parameters:
fieldKey - FieldKey
expression - String
Throws:
java.util.regex.PatternSyntaxException
Method Detail

getDisplayName

public java.lang.String getDisplayName()
Description copied from class: FilterCriteria

Returns the display name for this filter criteria.

Overrides:
getDisplayName in class FilterCriteria
Returns:
The display name of this filter criteria

setFieldKey

public void setFieldKey(FieldKey fieldKey)
Parameters:
fieldKey - FieldKey

getFieldKey

public FieldKey getFieldKey()
Returns:
FieldKey

setExpression

public void setExpression(java.lang.String expression)
                   throws java.util.regex.PatternSyntaxException
Parameters:
expression - String
Throws:
java.util.regex.PatternSyntaxException

getExpression

public java.lang.String getExpression()
Returns:
String

match

public boolean match(TableDataProvider provider,
                     RowKey row)
              throws DataProviderException

This method tests for a pattern match in the toString() value of the data item stored under the FieldKey at the specified row. A match is determined using the currently set regular expression.

Determines wether or not a particular row matches this filter criteria. Implementations may perform whatever logic is desired to make this determination. The combination of a positive match and the state of the include property determines if a row is included or excluded from the filter.

Specified by:
match in class FilterCriteria
Parameters:
provider - TableDataProvider containing the data on display
row - The RowKey of the data to be checked for a match
Returns:
true if a match was detected, or false if not.
Throws:
DataProviderException - Implementations may wish to surface internal exceptions (nested in DataProviderException) rather than simply returning null. A DPE may also indicate that the passed TableDataProvider or RowKey is not valid. Consult the documentation of the specific FilterCriteria implementation for details on what exceptions might be wrapped by a DPE.