de.unidu.is.text
Class AbstractFilter

java.lang.Object
  extended byde.unidu.is.text.AbstractFilter
All Implemented Interfaces:
Filter
Direct Known Subclasses:
AbstractSingleItemFilter, ParserFilter, TokenSplitterFilter, WordSplitterFilter

public abstract class AbstractFilter
extends java.lang.Object
implements Filter

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.

Since:
2003-07-03
Version:
$Revision: 1.9 $, $Date: 2005/02/21 17:29:28 $
Author:
Henrik Nottelmann

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

nextFilter

protected Filter nextFilter
The next filter in the filter chain.

Constructor Detail

AbstractFilter

public AbstractFilter(Filter nextFilter)
Creates a new instance and sets the next filter in the chain.

Parameters:
nextFilter - next filter in the filter chain
Method Detail

apply

public java.util.Iterator apply(java.lang.Object seed)
Applies this filter on the specified single object.

Specified by:
apply in interface Filter
Parameters:
seed - object on which the filter is applied
Returns:
iterator over the resulting objects
See Also:
Filter.apply(java.lang.Object)

apply

public java.util.Iterator apply(java.util.Iterator iterator)
Applies this filter on each object returned by the specified iterator.

This method first calls the next filter in the filter chain (if existing), and then applies this filter on the specified iterator.

Specified by:
apply in interface Filter
Parameters:
iterator - iterator over objects on which the filter is applied
Returns:
iterator over the resulting objects
See Also:
Filter.apply(java.util.Iterator)

filter

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.

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).

Parameters:
value - value to be modified by this filter
Returns:
iterator over the resulting objects