Class CharIterator

    • Constructor Detail

      • CharIterator

        public CharIterator​(String value)
    • Method Detail

      • skip

        public void skip​(int n)
        Skip next n characters
        Parameters:
        n - number of characters to skip
      • skip

        public void skip()
        Skip next character
      • peek

        public char peek()
        Return next character, without advancing cursor
        Returns:
        next character
      • peek

        public char peek​(int offset)
        Return character by offset from the next, without advancing cursor
        Parameters:
        offset - offset value.
        Returns:
        character by offset from next
      • next

        public String next​(int length)
        Return next length characters as a substring and advance cursor
        Parameters:
        length - number of characters to return
        Returns:
        substring start from next of length characters
      • context

        public String context()
        Returns context of cursor (text around the cursor)
        Returns:
        substring [-5,+5) chars from current position
      • context

        public String context​(int index)
        Returns context around passed index
        Parameters:
        index - center point of context
        Returns:
        substring [-5,+5) chars from index
      • remaining

        public int remaining()
        Calculate number of characters remaining to iterate over
        Returns:
        num of characters
      • nextUntil

        public String nextUntil​(char c)
        Returns substring from 'next' character UP TO first not escaped character c Cursor is advanced to a position after character c

        Example: For text '0123456789', nextUntil('8') will return '01234567' and put cursor before '9'

        Parameters:
        c - character to search for
        Returns:
        substring from next character up to next not escaped character c
        Throws:
        NoSuchElementException - if no such character present after next character
      • nextUntil

        public String nextUntil​(String s)
        Returns substring from next character up to next occurrence of s Cursor is advanced to a position after last character in s

        Example: For text '0123456789', nextUntil("456") will return '0123' and put cursor before '7'

        Parameters:
        s - string to search for
        Returns:
        substring from next character up to next not escaped occurrence of s. if string not found - returns all remaining characters
      • takeWhile

        public String takeWhile​(Predicate<Character> condition)
        Create substring starting from next character while condition is true Cursor is advanced to the first character which does not match condition
        Parameters:
        condition - condition to test each character with
        Returns:
        substring of characters that matches condition
      • lastChar

        public char lastChar()
        Returns last character that would be iterated over
        Returns:
        last character that would be iterated over
      • modifyBound

        public void modifyBound​(int offset)
        Move the bound until which iterator will iterate
        Parameters:
        offset - offset in respect to current bound
      • prevPos

        public int prevPos()
        Return position of last symbol returned by next()
        Returns:
        index
      • substringToCurrPos

        public String substringToCurrPos​(int pos)