Class CssCharStream

  • All Implemented Interfaces:
    org.htmlunit.cssparser.parser.javacc.CharStream

    public final class CssCharStream
    extends Object
    implements org.htmlunit.cssparser.parser.javacc.CharStream
    An implementation of interface CharStream. There is no processing of escaping in this class because the escaping is part of the parser. CSS has some strange rules about that, so processing unicode escapes in this class is too early.
    • Field Detail

      • staticFlag

        public static final boolean staticFlag
        Whether parser is static.
        See Also:
        Constant Field Values
      • bufpos

        public int bufpos
        Position in buffer.
    • Constructor Detail

      • CssCharStream

        public CssCharStream​(Reader dstream,
                             int startline,
                             int startcolumn,
                             int buffersize)
        Constructor.
        Parameters:
        dstream - the stream to read from
        startline - startline
        startcolumn - startcolumn
        buffersize - buffersize
      • CssCharStream

        public CssCharStream​(Reader dstream,
                             int startline,
                             int startcolumn)
        Constructor.
        Parameters:
        dstream - the stream to read from
        startline - startline
        startcolumn - startcolumn
    • Method Detail

      • beginToken

        public final char beginToken()
                              throws IOException
        Start.
        Specified by:
        beginToken in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        the next character that marks the beginning of the next token. All characters must remain in the buffer between two successive calls to this method to implement backup correctly.
        Throws:
        IOException
      • readChar

        public final char readChar()
                            throws IOException
        Get the next character from the selected input. The method of selecting the input is the responsibility of the class implementing this interface. Read a character.
        Specified by:
        readChar in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        the next character from the selected input
        Throws:
        IOException - on IO error
      • getEndColumn

        public final int getEndColumn()
        Get token end column number.
        Specified by:
        getEndColumn in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        the column number of the last character for current token (being matched after the last call to BeginToken).
      • getEndLine

        public final int getEndLine()
        Get token end line number.
        Specified by:
        getEndLine in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        the line number of the last character for current token (being matched after the last call to BeginToken).
      • getBeginColumn

        public final int getBeginColumn()
        Get token beginning column number.
        Specified by:
        getBeginColumn in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        the column number of the first character for current token (being matched after the last call to beginToken).
      • getBeginLine

        public final int getBeginLine()
        Get token beginning line number.
        Specified by:
        getBeginLine in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        the line number of the first character for current token (being matched after the last call to BeginToken).
      • backup

        public final void backup​(int amount)
        Backs up the input stream by amount steps. Lexer calls this method if it had already read some characters, but could not use them to match a (longer) token. So, they will be used again as the prefix of the next token and it is the implemetation's responsibility to do this right. Backup a number of characters.
        Specified by:
        backup in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Parameters:
        amount - Number of chars to back up.
      • getImage

        public final String getImage()
        Get token literal value.
        Specified by:
        getImage in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        a string made up of characters from the marked token beginning to the current buffer position. Implementations have the choice of returning anything that they want to. For example, for efficiency, one might decide to just return null, which is a valid implementation.
      • getSuffix

        public final char[] getSuffix​(int len)
        Get the suffix.
        Specified by:
        getSuffix in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        an array of characters that make up the suffix of length 'len' for the currently matched token. This is used to build up the matched string for use in actions in the case of MORE. A simple and inefficient implementation of this is as follows:
           {
              String t = getImage();
              return t.substring(t.length() - len, t.length()).toCharArray();
           }
         
      • done

        public void done()
        The lexer calls this function to indicate that it is done with the stream and hence implementations can free any resources held by this class. Again, the body of this function can be just empty and it will not affect the lexer's operation. Reset buffer when finished.
        Specified by:
        done in interface org.htmlunit.cssparser.parser.javacc.CharStream
      • adjustBeginLineColumn

        public void adjustBeginLineColumn​(int newLine,
                                          int newCol)
        Method to adjust line and column numbers for the start of a token.
        Parameters:
        newLine - the new line
        newCol - the new column
      • setTabSize

        public void setTabSize​(int i)
        Set the tab size to use.
        Specified by:
        setTabSize in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Parameters:
        i - spaces per tab
      • getTabSize

        public int getTabSize()
        Specified by:
        getTabSize in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        Current tab size.
      • isTrackLineColumn

        public boolean isTrackLineColumn()
        Specified by:
        isTrackLineColumn in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Returns:
        true if line number and column numbers should be tracked.
      • setTrackLineColumn

        public void setTrackLineColumn​(boolean tlc)
        Enable or disable line number and column number tracking.
        Specified by:
        setTrackLineColumn in interface org.htmlunit.cssparser.parser.javacc.CharStream
        Parameters:
        tlc - true to track it, false to not do it.