Package 

Class HCReader

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public final class HCReader
     implements Closeable
                        

    Provides convenience methods to parse the input data, with clear error handling and line numbering.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Integer lineNumber
    • Constructor Summary

      Constructors 
      Constructor Description
      HCReader(Reader reader, Regex tokenDelimiter)
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer getLineNumber()
      final Unit skip(Integer n) Skips the next n tokens of input.
      final String readString() Reads the next token of the input as a string.
      final Integer readInt() Reads the next token of the input as an int.
      final Double readDouble() Reads the next token of the input as a double.
      final Boolean readBoolean() Reads the next token of the input as a boolean value ("true" or "false" ignoring case).
      final String nextLineText() Reads and returns the whole next line of input.
      final List<String> nextLineTokens() Reads and returns the next line of input as a list of strings.
      Unit close() Releases potential resources used by the reader.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HCReader

        HCReader(Reader reader, Regex tokenDelimiter)
        Parameters:
        reader - the reader to use to read the input
        tokenDelimiter - the delimiter to use to separate tokens
    • Method Detail

      • readString

         final String readString()

        Reads the next token of the input as a string.

      • readInt

         final Integer readInt()

        Reads the next token of the input as an int.

      • readDouble

         final Double readDouble()

        Reads the next token of the input as a double.

      • readBoolean

         final Boolean readBoolean()

        Reads the next token of the input as a boolean value ("true" or "false" ignoring case).

      • nextLineText

         final String nextLineText()

        Reads and returns the whole next line of input.

      • close

         Unit close()

        Releases potential resources used by the reader. Should be called when parsing is over.