Package org.apache.lucene.analysis.util
Class RollingCharBuffer
java.lang.Object
org.apache.lucene.analysis.util.RollingCharBuffer
Acts like a forever growing char[] as you read characters into it from the provided reader, but
internally it uses a circular buffer to only hold the characters that haven't been freed yet.
This is like a PushbackReader, except you don't have to specify up-front the max size of the
buffer, but you do have to periodically call
freeBefore(int)
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
freeBefore
(int pos) Call this to notify us that no chars before this absolute position are needed anymore.int
get
(int pos) char[]
get
(int posStart, int length) private int
getIndex
(int pos) private boolean
inBounds
(int pos) void
Clear array and switch to new reader.
-
Field Details
-
reader
-
buffer
private char[] buffer -
nextWrite
private int nextWrite -
nextPos
private int nextPos -
count
private int count -
end
private boolean end
-
-
Constructor Details
-
RollingCharBuffer
public RollingCharBuffer()
-
-
Method Details
-
reset
Clear array and switch to new reader. -
get
- Throws:
IOException
-
inBounds
private boolean inBounds(int pos) -
getIndex
private int getIndex(int pos) -
get
public char[] get(int posStart, int length) -
freeBefore
public void freeBefore(int pos) Call this to notify us that no chars before this absolute position are needed anymore.
-