Package org.htmlunit.cssparser.parser
Class CssCharStream
- java.lang.Object
-
- org.htmlunit.cssparser.parser.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 Summary
Fields Modifier and Type Field Description intbufposPosition in buffer.static booleanstaticFlagWhether parser is static.
-
Constructor Summary
Constructors Constructor Description CssCharStream(Reader dstream, int startline, int startcolumn)Constructor.CssCharStream(Reader dstream, int startline, int startcolumn, int buffersize)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadjustBeginLineColumn(int newLine, int newCol)Method to adjust line and column numbers for the start of a token.voidbackup(int amount)Backs up the input stream by amount steps.charbeginToken()Start.voiddone()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.intgetBeginColumn()Get token beginning column number.intgetBeginLine()Get token beginning line number.intgetEndColumn()Get token end column number.intgetEndLine()Get token end line number.StringgetImage()Get token literal value.char[]getSuffix(int len)Get the suffix.intgetTabSize()booleanisTrackLineColumn()charreadChar()Get the next character from the selected input.voidsetTabSize(int i)Set the tab size to use.voidsetTrackLineColumn(boolean tlc)Enable or disable line number and column number tracking.
-
-
-
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 fromstartline- startlinestartcolumn- startcolumnbuffersize- buffersize
-
CssCharStream
public CssCharStream(Reader dstream, int startline, int startcolumn)
Constructor.- Parameters:
dstream- the stream to read fromstartline- startlinestartcolumn- startcolumn
-
-
Method Detail
-
beginToken
public final char beginToken() throws IOExceptionStart.- Specified by:
beginTokenin interfaceorg.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 IOExceptionGet 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:
readCharin interfaceorg.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:
getEndColumnin interfaceorg.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:
getEndLinein interfaceorg.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:
getBeginColumnin interfaceorg.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:
getBeginLinein interfaceorg.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:
backupin interfaceorg.htmlunit.cssparser.parser.javacc.CharStream- Parameters:
amount- Number of chars to back up.
-
getImage
public final String getImage()
Get token literal value.- Specified by:
getImagein interfaceorg.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:
getSuffixin interfaceorg.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:
donein interfaceorg.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 linenewCol- the new column
-
setTabSize
public void setTabSize(int i)
Set the tab size to use.- Specified by:
setTabSizein interfaceorg.htmlunit.cssparser.parser.javacc.CharStream- Parameters:
i- spaces per tab
-
getTabSize
public int getTabSize()
- Specified by:
getTabSizein interfaceorg.htmlunit.cssparser.parser.javacc.CharStream- Returns:
- Current tab size.
-
isTrackLineColumn
public boolean isTrackLineColumn()
- Specified by:
isTrackLineColumnin interfaceorg.htmlunit.cssparser.parser.javacc.CharStream- Returns:
trueif 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:
setTrackLineColumnin interfaceorg.htmlunit.cssparser.parser.javacc.CharStream- Parameters:
tlc-trueto track it,falseto not do it.
-
-