public static class CollectionUtils.FilterExpression extends Object
CollectionUtils.filter(Collection, FilterExpression, IFilterableValueDecorator)
. The filter expression uses the standard common search keyword rules (*
= wildcard, space = and, quotes = exact phrase).Modifier and Type | Field and Description |
---|---|
protected List<Pattern> |
m_patterns
List< of individual patterns |
protected String |
m_string
Expression string.
|
protected static Pattern |
RE_EMPTY
Pattern for matching whitespace, stars, and quotes |
protected static Pattern |
RE_QUOTED
Pattern for matching anything inside quotes (inclusive) |
protected static Pattern |
RE_WILDCARD
Wildcard
Pattern |
Constructor and Description |
---|
FilterExpression(String s)
Creates a new filter expression object from the specified string.
|
Modifier and Type | Method and Description |
---|---|
void |
filter(Collection<?> collection,
CollectionUtils.IFilterableValueDecorator valueDecorator)
Removes the items from the specified collection whose value does not match the filter.
|
String |
getExpressionString()
Expression string.
|
boolean |
matches(String s)
True if the specified string matches this expression.
|
void |
setExpressionString(String s)
Expression string.
|
protected static Pattern RE_QUOTED
Pattern
for matching anything inside quotes (inclusive)protected String m_string
public FilterExpression(String s)
public String getExpressionString()
public void setExpressionString(String s)
public boolean matches(String s)
public void filter(Collection<?> collection, CollectionUtils.IFilterableValueDecorator valueDecorator)
collection
- Items to filter. The collection will be iterated,
and the iterator's remove()
method will be called
for each item that does not match the filter.valueDecorator
- Decorator to use to calculate the value on which to filter
for each item in the collection.