org.pf.text
Class StringCollectionFilter

java.lang.Object
  extended by org.pf.text.AStringFilter
      extended by org.pf.text.StringCollectionFilter
All Implemented Interfaces:
IObjectFilter, StringFilter

public class StringCollectionFilter
extends AStringFilter

This filter is based on a collection of strings. It matches all strings that are in the underlying collection. By default it compares case-insensitive. Case sensitivity must be switched on explicitly.

Version:
1.1
Author:
Manfred Duchrow

Constructor Summary
StringCollectionFilter(java.util.Collection strings)
          Initialize the new instance with a collection of strings.
StringCollectionFilter(java.lang.String strings)
          Initialize the new instance with a List of strings provided as one string where the values are separated by comma (",").
StringCollectionFilter(java.lang.String[] strings)
          Initialize the new instance with an array of strings.
StringCollectionFilter(java.lang.String strings, java.lang.String separators)
          Initialize the new instance with a List of strings provided as one string where the values are separated by the specified separators.
 
Method Summary
 void add(java.lang.String string)
          Add the given string to the internal string collection.
 boolean getIgnoreCase()
          Returns true if the string comparison is done case-insensitive
 boolean matches(java.lang.String string)
          Returns true if the given string is in the internal collection of strings.
 boolean matchesIfInCollection()
          Returns true if this filter matches a string if it is found in the internal collection.
 void negate()
          Inverts the (match) logic of this filter
 void setIgnoreCase(boolean newValue)
          Sets whether or not the string comparison is done case-insensitive
 
Methods inherited from class org.pf.text.AStringFilter
matches
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringCollectionFilter

public StringCollectionFilter(java.lang.String[] strings)
Initialize the new instance with an array of strings.

Parameters:
strings - The strings that define the set that matches this filter

StringCollectionFilter

public StringCollectionFilter(java.util.Collection strings)
Initialize the new instance with a collection of strings.

Parameters:
strings - A list that must only contain String objects

StringCollectionFilter

public StringCollectionFilter(java.lang.String strings,
                              java.lang.String separators)
Initialize the new instance with a List of strings provided as one string where the values are separated by the specified separators.

Parameters:
strings - The strings to add (separated values)
separators - Each charater is treated as a separator between two string values

StringCollectionFilter

public StringCollectionFilter(java.lang.String strings)
Initialize the new instance with a List of strings provided as one string where the values are separated by comma (",").

Parameters:
strings - The strings to add (comma separated values)
Method Detail

getIgnoreCase

public boolean getIgnoreCase()
Returns true if the string comparison is done case-insensitive


setIgnoreCase

public void setIgnoreCase(boolean newValue)
Sets whether or not the string comparison is done case-insensitive


matches

public boolean matches(java.lang.String string)
Returns true if the given string is in the internal collection of strings. If the given string is null, false will be returned.

Parameters:
string - The string to look up in the collection

negate

public void negate()
Inverts the (match) logic of this filter


matchesIfInCollection

public boolean matchesIfInCollection()
Returns true if this filter matches a string if it is found in the internal collection. Returns false if this filter matches a string if it is NOT found in the internal collection.


add

public void add(java.lang.String string)
Add the given string to the internal string collection. If the argument is null it will be ignored.