Class MarkableSequenceReader
- java.lang.Object
-
- java.io.Reader
-
- org.postgresql.pljava.internal.MarkableSequenceReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Readable
public class MarkableSequenceReader extends Reader
Like aMarkableSequenceInputStream
but for characters.This class implements
mark
andreset
by calling the corresponding methods on the underlying readers; it does not add buffering or have any means of providingmark
andreset
support if the underlying readers do not.As with
SequenceInputStream
, each underlying reader, when completely read and no longer needed, is closed to free resources. This instance itself will remain in "open at EOF" condition until explicitly closed, but does not prevent reclamation of the underlying readers.Unlike
SequenceInputStream
, this class can keep underlying readers open, after fully reading them, if amark
has been set, so thatreset
will be possible. When a mark is no longer needed, it can be canceled (by callingmark
with areadlimit
of 0) to again allow the underlying readers to be reclaimed as soon as possible.
-
-
Constructor Summary
Constructors Constructor Description MarkableSequenceReader(Reader... streams)
Create aMarkableSequenceReader
from one or more existing readers.
-
-
-
Constructor Detail
-
MarkableSequenceReader
public MarkableSequenceReader(Reader... streams)
Create aMarkableSequenceReader
from one or more existing readers.- Parameters:
streams
- Sequence ofReader
s that will be read from in order.- Throws:
NullPointerException
- ifstreams
isnull
, or containsnull
for any stream.
-
-
Method Detail
-
read
public int read() throws IOException
- Overrides:
read
in classReader
- Throws:
IOException
-
read
public int read(char[] b, int off, int len) throws IOException
- Specified by:
read
in classReader
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classReader
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classReader
- Throws:
IOException
-
mark
public void mark(int readlimit) throws IOException
Marks the current position in this reader. In this implementation, it is possible to 'cancel' a mark, by passing this method areadlimit
of zero, returning the reader immediately to the state of having no mark.- Overrides:
mark
in classReader
- Throws:
IOException
-
reset
public void reset() throws IOException
- Overrides:
reset
in classReader
- Throws:
IOException
-
markSupported
public boolean markSupported()
Tests if this reader supports the mark and reset methods.For any instance of this class, the result is determined by the first call to this method, and does not change thereafter. At the first call, the result is determined only by the underlying readers remaining to be read (or, if a mark has been set, which is possible before checking this method, then by the underlying readers including and following the one that was current when the mark was set). The result will be
true
unless any of those underlying readers reports it asfalse
.- Overrides:
markSupported
in classReader
-
-