Class DelimitedWordReader

All Implemented Interfaces:
WordReader, Closeable, Serializable, AutoCloseable, Readable

public class DelimitedWordReader extends FastBufferedReader
A word reader that breaks words on a given set of characters.

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:
  • Constructor Details

    • DelimitedWordReader

      public DelimitedWordReader(int bufferSize, 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 using FastBufferedReader.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(CharSet delimiters)
      Creates a new delimited word reader with a buffer of FastBufferedReader.DEFAULT_BUFFER_SIZE characters. The wrapped reader will have to be set later using FastBufferedReader.setReader(Reader).
      Parameters:
      delimiters - a set of characters that will be considered word delimiters.
    • DelimitedWordReader

      public DelimitedWordReader(String delimiters)
      Creates a new delimited word reader with a buffer of FastBufferedReader.DEFAULT_BUFFER_SIZE characters. The wrapped reader will have to be set later using FastBufferedReader.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

      public DelimitedWordReader(String bufferSize, String 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 using FastBufferedReader.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, 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

      public DelimitedWordReader(Reader r, CharSet delimiters)
      Creates a new delimited word reader by wrapping a given reader with a buffer of FastBufferedReader.DEFAULT_BUFFER_SIZE characters 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, 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, 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

      public DelimitedWordReader(MutableString s, CharSet delimiters)
      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