org.pfsw.text
Class StringCollectionFilter

java.lang.Object
  extended by org.pfsw.text.AStringFilter
      extended by org.pfsw.text.StringCollectionFilter
All Implemented Interfaces:
org.pfsw.bif.filter.IObjectFilter<java.lang.String>, org.pfsw.bif.text.IStringFilter

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.


Field Summary
 
Fields inherited from interface org.pfsw.bif.text.IStringFilter
ALL, NONE
 
Constructor Summary
StringCollectionFilter(java.util.Collection<java.lang.String> 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... strings)
          Add the given strings to the internal string collection.
protected  void addSingleString(java.lang.String string)
          Add the given string to the internal string collection.
static StringCollectionFilter create(java.lang.String... strings)
          A factory method that supports a variable number of strings.
 boolean getIgnoreCase()
          Returns true if the string comparison is done case-insensitive
protected  java.lang.String[] getInternalStrings()
           
 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
protected  void setInternalStrings(java.lang.String[] newValue)
           
protected  StringUtil str()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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<java.lang.String> 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 character 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

create

public static StringCollectionFilter create(java.lang.String... strings)
A factory method that supports a variable number of strings.


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... strings)
Add the given strings to the internal string collection. If the argument is null it will be ignored.


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


addSingleString

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


getInternalStrings

protected java.lang.String[] getInternalStrings()

setInternalStrings

protected void setInternalStrings(java.lang.String[] newValue)

str

protected StringUtil str()