Package org.apache.batik.css.parser
Class Scanner
- java.lang.Object
-
- org.apache.batik.css.parser.Scanner
-
public class Scanner extends java.lang.Object
This class represents a CSS scanner - an object which decodes CSS lexical units.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
blankCharacters
The characters to skip to create the string which represents the current token.protected char[]
buffer
The recording buffer.protected int
current
The current char.protected int
end
The end offset of the last lexical unit.protected int
position
The current position in the buffer.protected NormalizingReader
reader
The reader.protected int
start
The start offset of the last lexical unit.protected int
type
The type of the current lexical unit.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearBuffer()
Clears the buffer.void
close()
Closes the underlying stream used by the scanner.protected int
dotNumber()
Scans the decimal part of a number.protected int
endGap()
Returns the end gap of the current lexical unit.protected void
escape()
Scans an escape sequence, if one.char[]
getBuffer()
Returns the buffer used to store the chars.int
getColumn()
Returns the current column.int
getEnd()
Returns the end offset of the last lexical unit.int
getLine()
Returns the current line.int
getStart()
Returns the start offset of the last lexical unit.java.lang.String
getStringValue()
Returns the string representation of the current lexical unit.int
getType()
The current lexical unit type like defined in LexicalUnits.protected static boolean
isEqualIgnoreCase(int i, char c)
Compares the given int with the given character, ignoring case.int
next()
Returns the next token.protected int
nextChar()
Sets the value of the current char to the next character or -1 if the end of stream has been reached.protected void
nextToken()
Returns the next token.protected int
number()
Scans a number.protected int
numberUnit(boolean integer)
Scans the unit of a number.void
scanAtRule()
Scans a @rule value.protected int
string1()
Scans a single quoted string.protected int
string2()
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 ParseException
Creates a new Scanner object.- Parameters:
r
- The reader to scan.- Throws:
ParseException
-
Scanner
public Scanner(java.io.InputStream is, java.lang.String enc) throws ParseException
Creates 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 ParseException
Creates 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 ParseException
Scans a @rule value. This method assumes that the current lexical unit is a at keyword.- Throws:
ParseException
-
next
public int next() throws ParseException
Returns 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 ParseException
Returns the next token.- Throws:
ParseException
-
string1
protected int string1() throws java.io.IOException
Scans a single quoted string.- Throws:
java.io.IOException
-
string2
protected int string2() throws java.io.IOException
Scans a double quoted string.- Throws:
java.io.IOException
-
number
protected int number() throws java.io.IOException
Scans a number.- Throws:
java.io.IOException
-
dotNumber
protected int dotNumber() throws java.io.IOException
Scans the decimal part of a number.- Throws:
java.io.IOException
-
numberUnit
protected int numberUnit(boolean integer) throws java.io.IOException
Scans the unit of a number.- Throws:
java.io.IOException
-
escape
protected void escape() throws java.io.IOException
Scans 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.IOException
Sets the value of the current char to the next character or -1 if the end of stream has been reached.- Throws:
java.io.IOException
-
-