Package org.apache.batik.css.parser
Class Scanner
- java.lang.Object
-
- org.apache.batik.css.parser.Scanner
-
public class Scanner extends java.lang.ObjectThis class represents a CSS scanner - an object which decodes CSS lexical units.- Version:
- $Id: Scanner.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description protected intblankCharactersThe characters to skip to create the string which represents the current token.protected char[]bufferThe recording buffer.protected intcurrentThe current char.protected intendThe end offset of the last lexical unit.protected intpositionThe current position in the buffer.protected NormalizingReaderreaderThe reader.protected intstartThe start offset of the last lexical unit.protected inttypeThe type of the current lexical unit.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearBuffer()Clears the buffer.voidclose()Closes the underlying stream used by the scanner.protected intdotNumber()Scans the decimal part of a number.protected intendGap()Returns the end gap of the current lexical unit.protected voidescape()Scans an escape sequence, if one.char[]getBuffer()Returns the buffer used to store the chars.intgetColumn()Returns the current column.intgetEnd()Returns the end offset of the last lexical unit.intgetLine()Returns the current line.intgetStart()Returns the start offset of the last lexical unit.java.lang.StringgetStringValue()Returns the string representation of the current lexical unit.intgetType()The current lexical unit type like defined in LexicalUnits.protected static booleanisEqualIgnoreCase(int i, char c)Compares the given int with the given character, ignoring case.intnext()Returns the next token.protected intnextChar()Sets the value of the current char to the next character or -1 if the end of stream has been reached.protected voidnextToken()Returns the next token.protected intnumber()Scans a number.protected intnumberUnit(boolean integer)Scans the unit of a number.voidscanAtRule()Scans a @rule value.protected intstring1()Scans a single quoted string.protected intstring2()Scans a double quoted string.
-
-
-
Field Detail
-
reader
protected NormalizingReader reader
The reader.
-
current
protected int current
The current char.
-
buffer
protected char[] buffer
The recording buffer.
-
position
protected int position
The current position in the buffer.
-
type
protected int type
The type of the current lexical unit.
-
start
protected int start
The start offset of the last lexical unit.
-
end
protected int end
The end offset of the last lexical unit.
-
blankCharacters
protected int blankCharacters
The characters to skip to create the string which represents the current token.
-
-
Constructor Detail
-
Scanner
public Scanner(java.io.Reader r) throws ParseExceptionCreates a new Scanner object.- Parameters:
r- The reader to scan.- Throws:
ParseException
-
Scanner
public Scanner(java.io.InputStream is, java.lang.String enc) throws ParseExceptionCreates a new Scanner object.- Parameters:
is- The input stream to scan.enc- The encoding to use to decode the input stream, or null.- Throws:
ParseException
-
Scanner
public Scanner(java.lang.String s) throws ParseExceptionCreates a new Scanner object.- Parameters:
s- The string to scan.- Throws:
ParseException
-
-
Method Detail
-
getLine
public int getLine()
Returns the current line.
-
getColumn
public int getColumn()
Returns the current column.
-
getBuffer
public char[] getBuffer()
Returns the buffer used to store the chars.
-
getStart
public int getStart()
Returns the start offset of the last lexical unit.
-
getEnd
public int getEnd()
Returns the end offset of the last lexical unit.
-
clearBuffer
public void clearBuffer()
Clears the buffer.
-
getType
public int getType()
The current lexical unit type like defined in LexicalUnits.
-
getStringValue
public java.lang.String getStringValue()
Returns the string representation of the current lexical unit.
-
scanAtRule
public void scanAtRule() throws ParseExceptionScans a @rule value. This method assumes that the current lexical unit is a at keyword.- Throws:
ParseException
-
next
public int next() throws ParseExceptionReturns the next token.- Throws:
ParseException
-
close
public void close()
Closes the underlying stream used by the scanner.
-
endGap
protected int endGap()
Returns the end gap of the current lexical unit.
-
nextToken
protected void nextToken() throws ParseExceptionReturns the next token.- Throws:
ParseException
-
string1
protected int string1() throws java.io.IOExceptionScans a single quoted string.- Throws:
java.io.IOException
-
string2
protected int string2() throws java.io.IOExceptionScans a double quoted string.- Throws:
java.io.IOException
-
number
protected int number() throws java.io.IOExceptionScans a number.- Throws:
java.io.IOException
-
dotNumber
protected int dotNumber() throws java.io.IOExceptionScans the decimal part of a number.- Throws:
java.io.IOException
-
numberUnit
protected int numberUnit(boolean integer) throws java.io.IOExceptionScans the unit of a number.- Throws:
java.io.IOException
-
escape
protected void escape() throws java.io.IOExceptionScans an escape sequence, if one.- Throws:
java.io.IOException
-
isEqualIgnoreCase
protected static boolean isEqualIgnoreCase(int i, char c)Compares the given int with the given character, ignoring case.
-
nextChar
protected int nextChar() throws java.io.IOExceptionSets the value of the current char to the next character or -1 if the end of stream has been reached.- Throws:
java.io.IOException
-
-