org.apache.lucene.analysis
public class: CachingTokenFilter [javadoc |
source]
java.lang.Object
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.TokenFilter
org.apache.lucene.analysis.CachingTokenFilter
This class can be used if the Tokens of a TokenStream
are intended to be consumed more than once. It caches
all Tokens locally in a List.
CachingTokenFilter implements the optional method
TokenStream#reset() , which repositions the
stream to the first Token.
| Method from org.apache.lucene.analysis.CachingTokenFilter Summary: |
|---|
|
next, reset |
| Methods from org.apache.lucene.analysis.TokenFilter: |
|---|
|
close |
| Method from org.apache.lucene.analysis.CachingTokenFilter Detail: |
public Token next() throws IOException {
if (cache == null) {
// fill cache lazily
cache = new LinkedList();
fillCache();
iterator = cache.iterator();
}
if (!iterator.hasNext()) {
// the cache is exhausted, return null
return null;
}
return (Token) iterator.next();
}
|
public void reset() throws IOException {
if(cache != null) {
iterator = cache.iterator();
}
}
|