Package org.camunda.spin.impl.util
Class RewindableReader
- java.lang.Object
-
- java.io.Reader
-
- org.camunda.spin.impl.util.RewindableReader
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class RewindableReader extends java.io.ReaderCaches the initial characters that are read from the suppliedReaderand allows to rewind these. As soon as more thansizecharacters have been read, rewinding fails.- Author:
- Thorben Lindhauer
-
-
Field Summary
Fields Modifier and Type Field Description protected char[]bufferprotected intposprotected booleanrewindableprotected java.io.PushbackReaderwrappedReader
-
Constructor Summary
Constructors Constructor Description RewindableReader(java.io.Reader input, int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intgetCurrentRewindableCapacity()intgetRewindBufferSize()voidmark(int readlimit)booleanmarkSupported()intread()intread(char[] cbuf, int off, int len)voidreset()voidrewind()Rewinds the reader such that the initial characters are returned when invoking read().longskip(long n)
-
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException- Specified by:
readin classjava.io.Reader- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.Reader- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein classjava.io.Reader- Throws:
java.io.IOException
-
mark
public void mark(int readlimit) throws java.io.IOException- Overrides:
markin classjava.io.Reader- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.Reader
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.Reader- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.Reader- Throws:
java.io.IOException
-
rewind
public void rewind() throws java.io.IOExceptionRewinds the reader such that the initial characters are returned when invoking read(). Throws an exception if more than the buffering limit has already been read.- Throws:
java.io.IOException
-
getRewindBufferSize
public int getRewindBufferSize()
-
getCurrentRewindableCapacity
public int getCurrentRewindableCapacity()
- Returns:
- the number of characters that can still be read and rewound.
-
-