|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.lucene.analysis.TokenStream
org.apache.solr.analysis.BufferedTokenStream
public abstract class BufferedTokenStream
Handles input and output buffering of TokenStream
// Example of a class implementing the rule "A" "B" => "Q" "B"
class MyTokenStream extends BufferedTokenStream {
public MyTokenStream(TokenStream input) {super(input);}
protected Token process(Token t) throws IOException {
if ("A".equals(t.termText())) {
Token t2 = read();
if (t2!=null && "B".equals(t2.termText())) t.setTermText("Q");
if (t2!=null) pushBack(t2);
}
return t;
}
}
// Example of a class implementing "A" "B" => "A" "A" "B"
class MyTokenStream extends BufferedTokenStream {
public MyTokenStream(TokenStream input) {super(input);}
protected Token process(Token t) throws IOException {
if ("A".equals(t.termText()) && "B".equals(peek(1).termText()))
write(t);
return t;
}
}
| Constructor Summary | |
|---|---|
BufferedTokenStream(org.apache.lucene.analysis.TokenStream input)
|
|
| Method Summary | |
|---|---|
org.apache.lucene.analysis.Token |
next()
|
protected java.lang.Iterable<org.apache.lucene.analysis.Token> |
output()
Provides direct Iterator access to the buffered output stream. |
protected org.apache.lucene.analysis.Token |
peek(int n)
Peek n tokens ahead in the buffered input stream, without modifying the stream. |
protected abstract org.apache.lucene.analysis.Token |
process(org.apache.lucene.analysis.Token t)
Process a token. |
protected void |
pushBack(org.apache.lucene.analysis.Token t)
Push a token back into the buffered input stream, such that it will be returned by a future call to read() |
protected org.apache.lucene.analysis.Token |
read()
Read a token from the buffered input stream. |
protected void |
write(org.apache.lucene.analysis.Token t)
Write a token to the buffered output stream |
| Methods inherited from class org.apache.lucene.analysis.TokenStream |
|---|
close, reset |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BufferedTokenStream(org.apache.lucene.analysis.TokenStream input)
| Method Detail |
|---|
protected abstract org.apache.lucene.analysis.Token process(org.apache.lucene.analysis.Token t)
throws java.io.IOException
java.io.IOException
public final org.apache.lucene.analysis.Token next()
throws java.io.IOException
next in class org.apache.lucene.analysis.TokenStreamjava.io.IOException
protected org.apache.lucene.analysis.Token read()
throws java.io.IOException
java.io.IOExceptionprotected void pushBack(org.apache.lucene.analysis.Token t)
read()
protected org.apache.lucene.analysis.Token peek(int n)
throws java.io.IOException
n - Number of tokens into the input stream to peek, 1 based ...
0 is invalid
read() from the stream.
java.io.IOExceptionprotected void write(org.apache.lucene.analysis.Token t)
protected java.lang.Iterable<org.apache.lucene.analysis.Token> output()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||