Interface CharInputReader

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long charCount()
      Returns the number of characters returned by nextChar() at any given time.
      java.lang.String currentParsedContent()
      Returns a String with the input character sequence parsed to produce the current record.
      void enableNormalizeLineEndings​(boolean escaping)
      Indicates to the input reader that the parser is running in "escape" mode and new lines should be returned as-is to prevent modifying the content of the parsed value.
      char getChar()
      Returns the last character returned by the nextChar() method.
      char[] getLineSeparator()
      Returns the line separator by this character input reader.
      java.lang.String getString​(char ch, char stop, boolean trim, java.lang.String nullValue, int maxLength)
      Attempts to collect a String from the current position until a stop character is found on the input, or a line ending is reached.
      long lineCount()
      Returns the number of newlines read so far.
      void markRecordStart()
      Marks the start of a new record in the input, used internally to calculate the result of currentParsedContent()
      char nextChar()
      Returns the next character in the input provided by the active Reader.
      java.lang.String readComment()
      Collects the comment line found on the input.
      void skipLines​(long lineCount)
      Skips characters in the input until the given number of lines is discarded.
      char skipWhitespace​(char current, char stopChar1, char stopChar2)
      Skips characters from the current input position, until a non-whitespace character, or a stop character is found
      void start​(java.io.Reader reader)
      Initializes the CharInputReader implementation with a Reader which provides access to the input.
      void stop()
      Stops the CharInputReader from reading characters from the Reader provided in start(Reader) and closes it.
    • Method Detail

      • start

        void start​(java.io.Reader reader)
        Initializes the CharInputReader implementation with a Reader which provides access to the input.
        Parameters:
        reader - A Reader that provides access to the input.
      • stop

        void stop()
        Stops the CharInputReader from reading characters from the Reader provided in start(Reader) and closes it.
      • nextChar

        char nextChar()
        Returns the next character in the input provided by the active Reader.

        If the input contains a sequence of newline characters (defined by Format.getLineSeparator()), this method will automatically converted them to the newline character specified in Format.getNormalizedNewline().

        A subsequent call to this method will return the character after the newline sequence.

        Specified by:
        nextChar in interface CharInput
        Returns:
        the next character in the input. '\0' if there are no more characters in the input or if the CharInputReader was stopped.
      • getChar

        char getChar()
        Returns the last character returned by the nextChar() method.
        Specified by:
        getChar in interface CharInput
        Returns:
        the last character returned by the nextChar() method.'\0' if there are no more characters in the input or if the CharInputReader was stopped.
      • charCount

        long charCount()
        Returns the number of characters returned by nextChar() at any given time.
        Returns:
        the number of characters returned by nextChar()
      • lineCount

        long lineCount()
        Returns the number of newlines read so far.
        Returns:
        the number of newlines read so far.
      • skipLines

        void skipLines​(long lineCount)
        Skips characters in the input until the given number of lines is discarded.
        Parameters:
        lineCount - the number of lines to skip from the current location in the input
      • readComment

        java.lang.String readComment()
        Collects the comment line found on the input.
        Returns:
        the text found in the comment from the current position.
      • enableNormalizeLineEndings

        void enableNormalizeLineEndings​(boolean escaping)
        Indicates to the input reader that the parser is running in "escape" mode and new lines should be returned as-is to prevent modifying the content of the parsed value.
        Parameters:
        escaping - flag indicating that the parser is escaping values and line separators are to be returned as-is.
      • skipWhitespace

        char skipWhitespace​(char current,
                            char stopChar1,
                            char stopChar2)
        Skips characters from the current input position, until a non-whitespace character, or a stop character is found
        Parameters:
        current - the current character of the input
        stopChar1 - the first stop character (which can be a whitespace)
        stopChar2 - the second character (which can be a whitespace)
        Returns:
        the first non-whitespace character (or delimiter) found in the input.
      • currentParsedContent

        java.lang.String currentParsedContent()
        Returns a String with the input character sequence parsed to produce the current record.
        Returns:
        the text content parsed for the current input record.
      • markRecordStart

        void markRecordStart()
        Marks the start of a new record in the input, used internally to calculate the result of currentParsedContent()
      • getString

        java.lang.String getString​(char ch,
                                   char stop,
                                   boolean trim,
                                   java.lang.String nullValue,
                                   int maxLength)
        Attempts to collect a String from the current position until a stop character is found on the input, or a line ending is reached. If the String can be obtained, the current position of the parser will be updated to the last consumed character. If the internal buffer needs to be reloaded, this method will return null and the current position of the buffer will remain unchanged.
        Parameters:
        ch - the current character to be considered. If equal to the stop character the nullValue will be returned
        stop - the stop character that identifies the end of the content to be collected
        trim - flag indicating whether or not trailing whitespaces should be discarded
        nullValue - value to return when the length of the content to be returned is 0.
        maxLength - the maximum length of the String to be returned. If the length exceeds this limit, null will be returned
        Returns:
        the String found on the input, or null if the buffer needs to reloaded or the maximum length has been exceeded.