|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectde.unidu.is.text.AbstractFilter
This is an abstract filter implementation which allows for chaining filters.
Chaining filters means that the output of one filter is used as the input
of another filter. This makes it easy to combine simple filters for
advanced applications.
Filter filter = new StemmerFilter(new WordSplitterFilter(null));
Iterator iterator = filter.apply("The quick brown fox jumps");
This code block chains a StemmerFilter with a
WordSplitterFilter. This means that the string
"The quick brown fox jumps" is first applied on the
WordSplitterFilter, which leads to an iterator over
"the", "quick", "brown", "fox" and "jumps". These objects are then applied
on the StemmerFilter, resulting in "the", "quick", "brown",
"fox" and "jump" (instead of "jump").
Subclasses have to implement the actual filtering method.
| Field Summary | |
protected Filter |
nextFilter
The next filter in the filter chain. |
| Constructor Summary | |
AbstractFilter(Filter nextFilter)
Creates a new instance and sets the next filter in the chain. |
|
| Method Summary | |
java.util.Iterator |
apply(java.util.Iterator iterator)
Applies this filter on each object returned by the specified iterator. |
java.util.Iterator |
apply(java.lang.Object seed)
Applies this filter on the specified single object. |
protected abstract java.util.Iterator |
filter(java.lang.Object value)
Applies only this filter on the specified object, without considering the other filters from the filter chain. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Filter nextFilter
| Constructor Detail |
public AbstractFilter(Filter nextFilter)
nextFilter - next filter in the filter chain| Method Detail |
public java.util.Iterator apply(java.lang.Object seed)
apply in interface Filterseed - object on which the filter is applied
Filter.apply(java.lang.Object)public java.util.Iterator apply(java.util.Iterator iterator)
This method first calls the next filter in the filter chain (if existing), and then applies this filter on the specified iterator.
apply in interface Filteriterator - iterator over objects on which the filter is applied
Filter.apply(java.util.Iterator)protected abstract java.util.Iterator filter(java.lang.Object value)
This method is the working horse of filters extending this class, and
the only method which has to be implemented in concrete filters. The
chaining of filters in done on apply(Iterator).
value - value to be modified by this filter
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||