public class ContextFilter extends Object implements Filter
filter.filter(someField)
for all fields and setting the
value of that field to the return value of the method call.
The Filter itself is responsible for returning a compatible object and
(optionally) stepping into objects and keeping up with context.
Note: This class is not thread-safe.
template method to filter domain objects. The standard idiom is:
if (m != null && hasntSeen(m)){
enter(m); // Provides context
addSeen(m); // Prevents looping
m.acceptFilter(this); // Visits all fields
exit(m); // Remove from context
}
Implementation notes: - nulls are already "seen"Modifier and Type | Field and Description |
---|---|
protected Map |
_cache |
protected LinkedList |
_context |
Constructor and Description |
---|
ContextFilter() |
Modifier and Type | Method and Description |
---|---|
protected void |
addSeen(Object o) |
protected void |
afterFilter(String fieldId,
Object o) |
protected void |
beforeFilter(String fieldId,
Object o) |
Object |
currentContext() |
protected void |
doFilter(String fieldId,
Collection c) |
protected void |
doFilter(String fieldId,
Filterable f) |
protected void |
doFilter(String fieldId,
Object o) |
boolean |
enter(Object o) |
boolean |
exit(Object o) |
Collection |
filter(String fieldId,
Collection c)
iterates over the contents of the collection and filters each.
|
protected ome.util.ContextFilter.Entry |
filter(String fieldId,
ome.util.ContextFilter.Entry entry)
doesn't return a new entry. only changes key and value
|
Filterable |
filter(String fieldId,
Filterable f) |
Map |
filter(String fieldId,
Map m)
filters both the key and value sets of the map.
|
Object |
filter(String fieldId,
Object o)
used when type is unknown. this is possibly omittable with generics
|
protected boolean |
hasntSeen(Object o) |
protected void |
pop(Object o) |
Object |
previousContext(int index) |
protected void |
push(Object o) |
protected Map _cache
protected LinkedList _context
protected void doFilter(String fieldId, Filterable f)
protected void doFilter(String fieldId, Collection c)
public Filterable filter(String fieldId, Filterable f)
public Collection filter(String fieldId, Collection c)
public Map filter(String fieldId, Map m)
public Object filter(String fieldId, Object o)
protected ome.util.ContextFilter.Entry filter(String fieldId, ome.util.ContextFilter.Entry entry)
public boolean enter(Object o)
public boolean exit(Object o)
public Object currentContext()
public Object previousContext(int index)
protected void push(Object o)
protected void pop(Object o)
protected void addSeen(Object o)
protected boolean hasntSeen(Object o)
Version: 5.2.8-ice35-b57
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.