public class ContextFilter extends java.lang.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 java.util.Map |
_cache |
protected java.util.LinkedList |
_context |
Constructor and Description |
---|
ContextFilter() |
Modifier and Type | Method and Description |
---|---|
protected void |
addSeen(java.lang.Object o) |
protected void |
afterFilter(java.lang.String fieldId,
java.lang.Object o) |
protected void |
beforeFilter(java.lang.String fieldId,
java.lang.Object o) |
java.lang.Object |
currentContext() |
protected void |
doFilter(java.lang.String fieldId,
java.util.Collection c) |
protected void |
doFilter(java.lang.String fieldId,
Filterable f) |
protected void |
doFilter(java.lang.String fieldId,
java.lang.Object o) |
boolean |
enter(java.lang.Object o) |
boolean |
exit(java.lang.Object o) |
java.util.Collection |
filter(java.lang.String fieldId,
java.util.Collection c)
iterates over the contents of the collection and filters each.
|
protected ome.util.ContextFilter.Entry |
filter(java.lang.String fieldId,
ome.util.ContextFilter.Entry entry)
doesn't return a new entry.
|
Filterable |
filter(java.lang.String fieldId,
Filterable f) |
java.util.Map |
filter(java.lang.String fieldId,
java.util.Map m)
filters both the key and value sets of the map.
|
java.lang.Object |
filter(java.lang.String fieldId,
java.lang.Object o)
used when type is unknown.
|
protected boolean |
hasntSeen(java.lang.Object o) |
protected void |
pop(java.lang.Object o) |
java.lang.Object |
previousContext(int index) |
protected void |
push(java.lang.Object o) |
protected void beforeFilter(java.lang.String fieldId, java.lang.Object o)
protected void doFilter(java.lang.String fieldId, java.lang.Object o)
protected void doFilter(java.lang.String fieldId, Filterable f)
protected void doFilter(java.lang.String fieldId, java.util.Collection c)
protected void afterFilter(java.lang.String fieldId, java.lang.Object o)
public Filterable filter(java.lang.String fieldId, Filterable f)
public java.util.Collection filter(java.lang.String fieldId, java.util.Collection c)
public java.util.Map filter(java.lang.String fieldId, java.util.Map m)
public java.lang.Object filter(java.lang.String fieldId, java.lang.Object o)
protected ome.util.ContextFilter.Entry filter(java.lang.String fieldId, ome.util.ContextFilter.Entry entry)
public boolean enter(java.lang.Object o)
public boolean exit(java.lang.Object o)
public java.lang.Object currentContext()
public java.lang.Object previousContext(int index)
protected void push(java.lang.Object o)
protected void pop(java.lang.Object o)
protected void addSeen(java.lang.Object o)
protected boolean hasntSeen(java.lang.Object o)