Class StringScanner

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int EOF  
    • Constructor Summary

      Constructors 
      Constructor Description
      StringScanner​(String content)
      Creates an instance of this class.
    • Method Summary

      Modifier and Type Method Description
      int column()
      Gets the column in the current line
      int line()
      Gets the current line number
      int peek()
      Returns the character from the top of the stream without moving the stream pointer.
      int peekColumn()
      Gets the next character column number
      int peekLine()
      Gets the next character line number
      int read()
      Reads character from the top of the stream.
      void reset()
      Resets scanner to the initial position
      void unread()
      Puts the one character back into the stream stream.
      void unreadMany​(int count)
      Pushes the specified number of characters to the top of the stream.
    • Constructor Detail

      • StringScanner

        public StringScanner​(String content)
        Creates an instance of this class.
        Parameters:
        content - A text content to be read.
    • Method Detail

      • line

        public int line()
        Gets the current line number
        Specified by:
        line in interface IScanner
        Returns:
        The current line number in the stream
      • column

        public int column()
        Gets the column in the current line
        Specified by:
        column in interface IScanner
        Returns:
        The column in the current line in the stream
      • read

        public int read()
        Reads character from the top of the stream. A read character or -1 if stream processed to the end.
        Specified by:
        read in interface IScanner
        Returns:
        A read character or -1 if stream processed to the end.
      • peek

        public int peek()
        Returns the character from the top of the stream without moving the stream pointer.
        Specified by:
        peek in interface IScanner
        Returns:
        A character from the top of the stream or -1 if stream is empty.
      • peekLine

        public int peekLine()
        Gets the next character line number
        Specified by:
        peekLine in interface IScanner
        Returns:
        The next character line number in the stream
      • peekColumn

        public int peekColumn()
        Gets the next character column number
        Specified by:
        peekColumn in interface IScanner
        Returns:
        The next character column number in the stream
      • unread

        public void unread()
        Puts the one character back into the stream stream.
        Specified by:
        unread in interface IScanner
      • unreadMany

        public void unreadMany​(int count)
        Pushes the specified number of characters to the top of the stream.
        Specified by:
        unreadMany in interface IScanner
        Parameters:
        count - A number of characcted to be pushed back.
      • reset

        public void reset()
        Resets scanner to the initial position
        Specified by:
        reset in interface IScanner