Class DelimitedWordReader
- All Implemented Interfaces:
WordReader, Closeable, Serializable, AutoCloseable, Readable
This class is a simple subclass of FastBufferedReader. It
overwrites isWordConstituent(char) so that word constituents
are defined negatively by a set of delimiters defined at construction time.
There is a constructor
accepting the delimiter set as a string. Note that LF and CR are always considered to be delimiters.
- See Also:
-
Field Summary
Fields inherited from class FastBufferedReader
avail, buffer, bufferSize, DEFAULT_BUFFER_SIZE, pos, reader, wordConstituents -
Constructor Summary
ConstructorsConstructorDescriptionDelimitedWordReader(char[] array, int offset, int length, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given fragment of a character array and using a set delimiters.DelimitedWordReader(char[] array, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given character array and using a set delimiters.DelimitedWordReader(int bufferSize, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader with a given buffer size and set of delimiters.DelimitedWordReader(it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader with a buffer ofFastBufferedReader.DEFAULT_BUFFER_SIZEcharacters.DelimitedWordReader(MutableString s, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given mutable string and using a set of delimiters.DelimitedWordReader(Reader r, int bufferSize, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given reader with a given buffer size and using a set of delimiters.DelimitedWordReader(Reader r, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given reader with a buffer ofFastBufferedReader.DEFAULT_BUFFER_SIZEcharacters using a given set of delimiters.DelimitedWordReader(String delimiters) Creates a new delimited word reader with a buffer ofFastBufferedReader.DEFAULT_BUFFER_SIZEcharacters.DelimitedWordReader(String bufferSize, String delimiters) Creates a new delimited word reader with a given buffer size and set of delimiters. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a copy of this word reader.protected booleanisWordConstituent(char c) Returns whether the given character is a word constituent.toSpec()toString()Methods inherited from class FastBufferedReader
close, next, noMoreCharacters, read, read, readLine, setReader, skipMethods inherited from class Reader
mark, markSupported, nullReader, of, read, read, readAllAsString, readAllLines, ready, reset, transferTo
-
Constructor Details
-
DelimitedWordReader
public DelimitedWordReader(int bufferSize, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader with a given buffer size and set of delimiters. The wrapped reader will have to be set later usingFastBufferedReader.setReader(Reader).- Parameters:
bufferSize- the size in bytes of the internal buffer.delimiters- a set of characters that will be considered word delimiters.
-
DelimitedWordReader
public DelimitedWordReader(it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader with a buffer ofFastBufferedReader.DEFAULT_BUFFER_SIZEcharacters. The wrapped reader will have to be set later usingFastBufferedReader.setReader(Reader).- Parameters:
delimiters- a set of characters that will be considered word delimiters.
-
DelimitedWordReader
Creates a new delimited word reader with a buffer ofFastBufferedReader.DEFAULT_BUFFER_SIZEcharacters. The wrapped reader will have to be set later usingFastBufferedReader.setReader(Reader).Warning: it is easy to mistake this method for one whose semantics is the same as
FastBufferedReader(MutableString), that is, wrapping the argument string in a reader.- Parameters:
delimiters- a set of characters that will be considered word delimiters, specified as a string.
-
DelimitedWordReader
Creates a new delimited word reader with a given buffer size and set of delimiters. The wrapped reader will have to be set later usingFastBufferedReader.setReader(Reader).- Parameters:
bufferSize- the size in bytes of the internal buffer, specified as a string.delimiters- a set of characters that will be considered word delimiters, specified as a string.
-
DelimitedWordReader
public DelimitedWordReader(Reader r, int bufferSize, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given reader with a given buffer size and using a set of delimiters.- Parameters:
r- a reader to wrap.bufferSize- the size in bytes of the internal buffer.delimiters- a set of characters that will be considered word delimiters.
-
DelimitedWordReader
Creates a new delimited word reader by wrapping a given reader with a buffer ofFastBufferedReader.DEFAULT_BUFFER_SIZEcharacters using a given set of delimiters.- Parameters:
r- a reader to wrap.delimiters- a set of characters that will be considered word delimiters.
-
DelimitedWordReader
public DelimitedWordReader(char[] array, int offset, int length, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given fragment of a character array and using a set delimiters.The effect of
FastBufferedReader.setReader(Reader)on a buffer created with this constructor is undefined.- Parameters:
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.delimiters- a set of characters that will be considered word delimiters.
-
DelimitedWordReader
public DelimitedWordReader(char[] array, it.unimi.dsi.fastutil.chars.CharSet delimiters) Creates a new delimited word reader by wrapping a given character array and using a set delimiters.The effect of
FastBufferedReader.setReader(Reader)on a buffer created with this constructor is undefined.- Parameters:
array- the array that will be wrapped by the reader.delimiters- a set of characters that will be considered word delimiters.
-
DelimitedWordReader
Creates a new delimited word reader by wrapping a given mutable string and using a set of delimiters.The effect of
FastBufferedReader.setReader(Reader)on a buffer created with this constructor is undefined.- Parameters:
s- the mutable string that will be wrapped by the reader.delimiters- a set of characters that will be considered word delimiters.
-
-
Method Details
-
isWordConstituent
protected boolean isWordConstituent(char c) Description copied from class:FastBufferedReaderReturns whether the given character is a word constituent.The behaviour of this
FastBufferedReaderas aWordReadercan be radically changed by overwriting this method.- Overrides:
isWordConstituentin classFastBufferedReader- Parameters:
c- a character.- Returns:
- whether
cshould be considered a word constituent.
-
copy
Description copied from interface:WordReaderReturns a copy of this word reader.This method must return a word reader with a behaviour that matches exactly that of this word reader.
- Specified by:
copyin interfaceWordReader- Overrides:
copyin classFastBufferedReader- Returns:
- a copy of this word reader.
-
toSpec
- Overrides:
toSpecin classFastBufferedReader
-
toString
- Overrides:
toStringin classFastBufferedReader
-