ca.odell.glazedlists.matchers
Class Matchers
java.lang.Object
ca.odell.glazedlists.matchers.Matchers
public final class Matchers
extends java.lang.Object
A factory for creating Matchers.
static | Matcher beanPropertyMatcher(Class beanClass, String propertyName, Object expectedValue) - Creates a
Matcher that uses Reflection to compare the expectedValue
of the specified property of an object to the expectedValue .
|
static | Matcher falseMatcher() - Get a
Matcher that always returns false, therefore matching nothing..
|
static | Matcher invert(Matcher original) - Get a
Matcher that returns the opposite of the specified Matcher .
|
static | Matcher trueMatcher() - Get a
Matcher that always returns true, therefore matching everything.
|
static | MatcherEditor weakReferenceProxy(MatcherEditor matcherEditor) - Provides a proxy to another MatcherEditor that may go out of scope
without explicitly removing itself from the source MatcherEditor's set
of listeners.
|
static | boolean filter(Collection collection, E> matcher) - Iterate through the specified collection and remove all elements
that don't match the specified matcher.
|
static | extends Comparable,E> Matcher rangeMatcher(D start, D end) - Creates a
Matcher that matches Comparable objects for
containment within the range between the given start
and end .
|
static | extends Comparable,E> Matcher rangeMatcher(D start, D end, Filterator filterator) - Creates a
Matcher that uses the given filterator
to extract Comparable objects from filtered objects and compares
those Comparables against the range between the given start
and end .
|
Matcher beanPropertyMatcher
public static Matcher beanPropertyMatcher(Class beanClass,
String propertyName,
Object expectedValue)
Creates a
Matcher
that uses Reflection to compare the expectedValue
of the specified property of an object to the
expectedValue
.
Matcher falseMatcher
public static Matcher falseMatcher()
Get a
Matcher
that always returns false, therefore matching nothing..
Matcher invert
public static Matcher invert(Matcher original)
Matcher trueMatcher
public static Matcher trueMatcher()
Get a
Matcher
that always returns true, therefore matching everything.
MatcherEditor weakReferenceProxy
public static MatcherEditor weakReferenceProxy(MatcherEditor matcherEditor)
Provides a proxy to another MatcherEditor that may go out of scope
without explicitly removing itself from the source MatcherEditor's set
of listeners.
This exists to solve a garbage collection problem. Suppose I have a
MatcherEditor
M which is long lived and many
MatcherEditor.Listener
s,
t which must listen to
M
while they exist. Instead of adding each of the
t directly as
listeners of
M, add a proxy instead. The proxy will retain a
WeakReference
to the
t, and will remove itself from
the list of listeners for
M.
The
MatcherEditor
returned by this method makes implementing the
above scheme trivial. It does two things for you automatically:
- It wraps each
MatcherEditor.Listener
passed to
MatcherEditor.addMatcherEditorListener(Listener)
in a
java.lang.ref.WeakReference
so that the listeners are
garbage collected when they become unreachable.
- It registers itself as a weak listener of the
given
matcherEditor
so the MatcherEditor returned by
this method will be garbage collected when it becomes unreachable.
java.lang.ref.WeakReference
boolean filter
public static boolean filter(Collection collection,
E> matcher)
Iterate through the specified collection and remove all elements
that don't match the specified matcher.
true
if any elements were removed from the specified
Collection
.
extends Comparable,E> Matcher rangeMatcher
public static Matcher rangeMatcher(D start,
D end)
Creates a
Matcher
that matches
Comparable
objects for
containment within the range between the given
start
and
end
.
extends Comparable,E> Matcher rangeMatcher
public static Matcher rangeMatcher(D start,
D end,
Filterator filterator)
Creates a
Matcher
that uses the given
filterator
to extract
Comparable
objects from filtered objects and compares
those Comparables against the range between the given
start
and
end
. If at least one Comparable returned by the
filterator
is within the range, the object is considered
a match.
null
start
or
end
values are
allowed and are interpreted as
"no start"
or
"no end"
to the range respectively.
start
- the Comparable
which starts the rangeend
- the Comparable
which ends the rangefilterator
- the logic for extracting filter Comparable
s
from filtered objects
Glazed Lists, Copyright © 2003-2006 publicobject.com, O'Dell Engineering.
Documentation build by buildd at 2008-01-04 14:38