|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.Reader
it.unimi.dsi.mg4j.io.FastBufferedReader
dsiutils
.
@Deprecated public class FastBufferedReader
A lightweight, unsynchronised buffered reader based on mutable strings.
This class provides buffering for readers, but it does so with
purposes and an internal logic that are radically different from the ones
adopted in BufferedReader
.
There is no support for marking. All methods are unsychronised. All
methods returning strings do so by writing in a given MutableString
.
Note that instances of this class can wrap an array
or a mutable string. In this case,
instances of this class may be used as a lightweight, unsynchronised
alternative to CharArrayReader
providing additional services such as word and line breaking.
As any WordReader
, this class is serialisable.
The only field kept is the current buffer size, which will be used to rebuild
a fast buffered reader with the same buffer size. All other fields will be reset.
Field Summary | |
---|---|
protected int |
avail
Deprecated. The number of buffer bytes available starting from pos . |
protected char[] |
buffer
Deprecated. The internal buffer. |
protected int |
bufferSize
Deprecated. The buffer size (must be equal to buffer.length ). |
static int |
DEFAULT_BUFFER_SIZE
Deprecated. The default size of the internal buffer in bytes (16Ki). |
protected int |
pos
Deprecated. The current position in the buffer. |
protected Reader |
reader
Deprecated. The underlying reader. |
static long |
serialVersionUID
Deprecated. |
Fields inherited from class java.io.Reader |
---|
lock |
Constructor Summary | |
---|---|
FastBufferedReader()
Deprecated. Creates a new fast buffered reader with a buffer of DEFAULT_BUFFER_SIZE characters. |
|
FastBufferedReader(char[] array)
Deprecated. Creates a new fast buffered reader by wrapping a given character array. |
|
FastBufferedReader(char[] array,
int offset,
int length)
Deprecated. Creates a new fast buffered reader by wrapping a given fragment of a character array. |
|
FastBufferedReader(int bufferSize)
Deprecated. Creates a new fast buffered reader with a given buffer size. |
|
FastBufferedReader(MutableString s)
Deprecated. Creates a new fast buffered reader by wrapping a given mutable string. |
|
FastBufferedReader(Reader r)
Deprecated. Creates a new fast buffered reader by wrapping a given reader with a buffer of DEFAULT_BUFFER_SIZE characters. |
|
FastBufferedReader(Reader r,
int bufferSize)
Deprecated. Creates a new fast buffered reder by wrapping a given reder with a given buffer size. |
Method Summary | |
---|---|
void |
close()
Deprecated. |
FastBufferedReader |
copy()
Deprecated. Returns a copy of this word reader. |
boolean |
next(MutableString word,
MutableString nonWord)
Deprecated. Extracts the next word and non-word. |
protected boolean |
noMoreCharacters()
Deprecated. Checks whether no more characters will be returned. |
int |
read()
Deprecated. |
int |
read(char[] b,
int offset,
int length)
Deprecated. |
MutableString |
readLine(MutableString s)
Deprecated. Reads a line into the given mutable string. |
FastBufferedReader |
setReader(Reader reader)
Deprecated. Resets the internal state of this word reader, which will start again reading from the given reader. |
long |
skip(long n)
Deprecated. |
Methods inherited from class java.io.Reader |
---|
mark, markSupported, read, read, ready, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long serialVersionUID
public static final int DEFAULT_BUFFER_SIZE
protected final int bufferSize
buffer.length
).
protected transient char[] buffer
protected transient int pos
protected transient int avail
pos
.
protected transient Reader reader
Constructor Detail |
---|
public FastBufferedReader(int bufferSize)
setReader(Reader)
.
bufferSize
- the size in bytes of the internal buffer.public FastBufferedReader()
DEFAULT_BUFFER_SIZE
characters.
The wrapped reader will have to be set later using setReader(Reader)
.
public FastBufferedReader(Reader r, int bufferSize)
r
- a reader to wrap.bufferSize
- the size in bytes of the internal buffer.public FastBufferedReader(Reader r)
DEFAULT_BUFFER_SIZE
characters.
r
- a reader to wrap.public FastBufferedReader(char[] array, int offset, int length)
The effect of setReader(Reader)
on a buffer created with
this constructor is undefined.
array
- the array that will be wrapped by the reader.offset
- the first character to be used.length
- the number of character to be used.public FastBufferedReader(char[] array)
The effect of setReader(Reader)
on a buffer created with
this constructor is undefined.
array
- the array that will be wrapped by the reader.public FastBufferedReader(MutableString s)
The effect of setReader(Reader)
on a buffer created with
this constructor is undefined.
s
- the mutable string that will be wrapped by the reader.Method Detail |
---|
public FastBufferedReader copy()
WordReader
This method must return a word reader with a behaviour that matches exactly that of this word reader.
copy
in interface WordReader
protected boolean noMoreCharacters() throws IOException
IOException
public int read() throws IOException
read
in class Reader
IOException
public int read(char[] b, int offset, int length) throws IOException
read
in class Reader
IOException
public MutableString readLine(MutableString s) throws IOException
The next line of input (defined as in BufferedReader.readLine()
)
will be stored into s
. Note that if s
is
not loose
this method will be quite inefficient.
s
- a mutable string that will be used to store the next line (which could be empty).
s
, or null
if the end of file was found, in which
case s
is unchanged.
IOException
public boolean next(MutableString word, MutableString nonWord) throws IOException
WordReader
If this method returns true, a new non-empty word, and possibly
a new non-word, have been extracted. It is acceptable
that the first call to this method after creation
or after a call to WordReader.setReader(Reader)
returns an empty
word. In other words both word
and nonWord
are maximal.
next
in interface WordReader
word
- the next word returned by the underlying reader.nonWord
- the nonword following the next word returned by the underlying reader.
word
and nonWord
are unchanged).
IOException
public FastBufferedReader setReader(Reader reader)
WordReader
setReader
in interface WordReader
reader
- the new reader providing characters.
public long skip(long n) throws IOException
skip
in class Reader
IOException
public void close() throws IOException
close
in interface Closeable
close
in class Reader
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |