com.steadystate.css.parser

Class SACParser

Implemented Interfaces:
Parser, SACParserConstants

public class SACParser
extends java.lang.Object
implements Parser, SACParserConstants

Version:
$Release$
Author:
David Schweinsberg

Field Summary

Token
jj_nt
boolean
lookingAhead
Token
token
SACParserTokenManager
token_source

Fields inherited from interface com.steadystate.css.parser.SACParserConstants

AND, ANGLE_DEG, ANGLE_GRAD, ANGLE_RAD, ASTERISK, ATKEYWORD, CDC, CDO, CHARSET_SYM, COLON, COMMA, COMMENT, DASHMATCH, DEFAULT, DIMEN, DOT, EMS, EOF, EQUALS, ESCAPE, EXS, FONT_FACE_SYM, FREQ_HZ, FREQ_KHZ, FUNCTION, GT, H, HASH, HNUM, IDENT, IMPORTANT_SYM, IMPORT_SYM, INCLUDES, INHERIT, LBRACE, LENGTH_CM, LENGTH_IN, LENGTH_MM, LENGTH_PC, LENGTH_PT, LENGTH_PX, LPAREN, LSQUARE, MEDIA_SYM, MEDIUM, MINUS, NAME, NL, NMCHAR, NMSTART, NONASCII, NOT, NUM, NUMBER, ONLY, PAGE_SYM, PERCENTAGE, PLUS, Q11, Q12, Q13, Q14, Q15, Q16, RANGE, RBRACE, RGB, RROUND, RSQUARE, S, SEMICOLON, SLASH, STRING, STRING1, STRING2, TIME_MS, TIME_S, UNICODE, UNICODERANGE, UNKNOWN, URI, URL, tokenImage

Constructor Summary

SACParser()
SACParser(CharStream stream)
SACParser(SACParserTokenManager tm)

Method Summary

void
ReInit(CharStream stream)
void
ReInit(SACParserTokenManager tm)
Condition
_class(Condition pred)
Condition
attrib(Condition pred)
void
charsetRule()
char
combinator()
void
declaration()
void
disable_tracing()
SimpleSelector
elementName()
void
enable_tracing()
LexicalUnit
expr()
void
fontFaceRule()
LexicalUnit
function(LexicalUnit prev)
ParseException
generateParseException()
Token
getNextToken()
String
getParserVersion()
Returns a string about which CSS language is supported by this parser.
Token
getToken(int index)
Condition
hash(Condition pred)
LexicalUnit
hexcolor(LexicalUnit prev)
void
importRule()
void
mediaExpression(SACMediaListImpl ml)
void
mediaFeature(SACMediaListImpl ml)
void
mediaList(SACMediaListImpl ml)
void
mediaListOrExpression(SACMediaListImpl ml)
void
mediaQuery(SACMediaListImpl ml)
void
mediaRule()
void
mediaRuleList()
void
mediaRuleSingle()
String
medium()
LexicalUnit
operator(LexicalUnit prev)
void
pageRule()
boolean
parsePriority(InputSource source)
Parse a CSS priority value (e.g.
LexicalUnit
parsePropertyValue(InputSource source)
Parse a CSS property value.
void
parseRule(InputSource source)
Parse a CSS rule.
SelectorList
parseSelectors(InputSource source)
Parse a comma separated list of selectors.
void
parseStyleDeclaration(InputSource source)
Parse a CSS style declaration (without '{' and '}').
void
parseStyleSheet(String uri)
Parse a CSS document from a URI.
void
parseStyleSheet(InputSource source)
Parse a CSS document.
boolean
prio()
String
property()
Condition
pseudo(Condition pred)
String
pseudoPage()
LexicalUnit
rgb(LexicalUnit prev)
Selector
selector()
SelectorList
selectorList()
void
setConditionFactory(ConditionFactory conditionFactory)
void
setDocumentHandler(DocumentHandler handler)
Allow an application to register a document event handler.
void
setErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler.
void
setLocale(Locale locale)
Allow an application to request a locale for errors and warnings.
void
setSelectorFactory(SelectorFactory selectorFactory)
Selector
simpleSelector(Selector sel, char comb)
void
styleDeclaration()
void
styleRule()
void
styleSheet()
void
styleSheetRuleList()
void
styleSheetRuleSingle()
LexicalUnit
term(LexicalUnit prev)
char
unaryOperator()
void
unknownRule()

Field Details

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead

token

public Token token

token_source

public SACParserTokenManager token_source

Constructor Details

SACParser

public SACParser()

SACParser

public SACParser(CharStream stream)

SACParser

public SACParser(SACParserTokenManager tm)

Method Details

ReInit

public void ReInit(CharStream stream)

ReInit

public void ReInit(SACParserTokenManager tm)

_class

public final Condition _class(Condition pred)
            throws ParseException

attrib

public final Condition attrib(Condition pred)
            throws ParseException

charsetRule

public final void charsetRule()
            throws ParseException

combinator

public final char combinator()
            throws ParseException

declaration

public final void declaration()
            throws ParseException

disable_tracing

public final void disable_tracing()

elementName

public final SimpleSelector elementName()
            throws ParseException

enable_tracing

public final void enable_tracing()

expr

public final LexicalUnit expr()
            throws ParseException

fontFaceRule

public final void fontFaceRule()
            throws ParseException

function

public final LexicalUnit function(LexicalUnit prev)
            throws ParseException

generateParseException

public ParseException generateParseException()

getNextToken

public final Token getNextToken()

getParserVersion

public String getParserVersion()
Returns a string about which CSS language is supported by this parser. For CSS Level 1, it returns "http://www.w3.org/TR/REC-CSS1", for CSS Level 2, it returns "http://www.w3.org/TR/REC-CSS2". Note that a "CSSx" parser can return lexical unit other than those allowed by CSS Level x but this usage is not recommended.
Specified by:
getParserVersion in interface Parser

getToken

public final Token getToken(int index)

hash

public final Condition hash(Condition pred)
            throws ParseException

hexcolor

public final LexicalUnit hexcolor(LexicalUnit prev)
            throws ParseException

importRule

public final void importRule()
            throws ParseException

mediaExpression

public final void mediaExpression(SACMediaListImpl ml)
            throws ParseException

mediaFeature

public final void mediaFeature(SACMediaListImpl ml)
            throws ParseException

mediaList

public final void mediaList(SACMediaListImpl ml)
            throws ParseException

mediaListOrExpression

public final void mediaListOrExpression(SACMediaListImpl ml)
            throws ParseException

mediaQuery

public final void mediaQuery(SACMediaListImpl ml)
            throws ParseException

mediaRule

public final void mediaRule()
            throws ParseException

mediaRuleList

public final void mediaRuleList()
            throws ParseException

mediaRuleSingle

public final void mediaRuleSingle()
            throws ParseException

medium

public final String medium()
            throws ParseException

operator

public final LexicalUnit operator(LexicalUnit prev)
            throws ParseException

pageRule

public final void pageRule()
            throws ParseException

parsePriority

public boolean parsePriority(InputSource source)
            throws CSSException,
                   IOException
Parse a CSS priority value (e.g. "!important").
Specified by:
parsePriority in interface Parser
Throws:
CSSException - Any CSS exception, possibly wrapping another exception.

parsePropertyValue

public LexicalUnit parsePropertyValue(InputSource source)
            throws CSSException,
                   IOException
Parse a CSS property value.
Specified by:
parsePropertyValue in interface Parser
Throws:
CSSException - Any CSS exception, possibly wrapping another exception.

parseRule

public void parseRule(InputSource source)
            throws CSSException,
                   IOException
Parse a CSS rule.
Specified by:
parseRule in interface Parser
Throws:
CSSException - Any CSS exception, possibly wrapping another exception.

parseSelectors

public SelectorList parseSelectors(InputSource source)
            throws CSSException,
                   IOException
Parse a comma separated list of selectors.
Specified by:
parseSelectors in interface Parser
Throws:
CSSException - Any CSS exception, possibly wrapping another exception.

parseStyleDeclaration

public void parseStyleDeclaration(InputSource source)
            throws CSSException,
                   IOException
Parse a CSS style declaration (without '{' and '}').
Specified by:
parseStyleDeclaration in interface Parser
Parameters:
Throws:
CSSException - Any CSS exception, possibly wrapping another exception.

parseStyleSheet

public void parseStyleSheet(String uri)
            throws CSSException,
                   IOException
Parse a CSS document from a URI.

This method is a shortcut for the common case of reading a document from a URI. It is the exact equivalent of the following:

 parse(new InputSource(uri));
 

The URI must be fully resolved by the application before it is passed to the parser.

Specified by:
parseStyleSheet in interface Parser
Parameters:
uri - The URI.
Throws:
CSSException - Any CSS exception, possibly wrapping another exception.

parseStyleSheet

public void parseStyleSheet(InputSource source)
            throws CSSException,
                   IOException
Parse a CSS document.

The application can use this method to instruct the CSS parser to begin parsing an CSS document from any valid input source (a character stream, a byte stream, or a URI).

Applications may not invoke this method while a parse is in progress (they should create a new Parser instead for each additional CSS document). Once a parse is complete, an application may reuse the same Parser object, possibly with a different input source.

Specified by:
parseStyleSheet in interface Parser
Parameters:
source - The input source for the top-level of the CSS document.
Throws:
CSSException - Any CSS exception, possibly wrapping another exception.

prio

public final boolean prio()
            throws ParseException

property

public final String property()
            throws ParseException

pseudo

public final Condition pseudo(Condition pred)
            throws ParseException

pseudoPage

public final String pseudoPage()
            throws ParseException

rgb

public final LexicalUnit rgb(LexicalUnit prev)
            throws ParseException

selector

public final Selector selector()
            throws ParseException

selectorList

public final SelectorList selectorList()
            throws ParseException

setConditionFactory

public void setConditionFactory(ConditionFactory conditionFactory)
Specified by:
setConditionFactory in interface Parser

setDocumentHandler

public void setDocumentHandler(DocumentHandler handler)
Allow an application to register a document event handler.

If the application does not register a document handler, all document events reported by the CSS parser will be silently ignored (this is the default behaviour implemented by HandlerBase).

Applications may register a new or different handler in the middle of a parse, and the CSS parser must begin using the new handler immediately.

Specified by:
setDocumentHandler in interface Parser
Parameters:
handler - The document handler.

setErrorHandler

public void setErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler.

If the application does not register an error event handler, all error events reported by the CSS parser will be silently ignored, except for fatalError, which will throw a CSSException (this is the default behaviour implemented by HandlerBase).

Applications may register a new or different handler in the middle of a parse, and the CSS parser must begin using the new handler immediately.

Specified by:
setErrorHandler in interface Parser
Parameters:
handler - The error handler.

setLocale

public void setLocale(Locale locale)
            throws CSSException
Allow an application to request a locale for errors and warnings.

CSS parsers are not required to provide localisation for errors and warnings; if they cannot support the requested locale, however, they must throw a CSS exception. Applications may not request a locale change in the middle of a parse.

Specified by:
setLocale in interface Parser
Parameters:
locale - A Java Locale object.
Throws:
CSSException - Throws an exception (using the previous or default locale) if the requested locale is not supported.

setSelectorFactory

public void setSelectorFactory(SelectorFactory selectorFactory)
Specified by:
setSelectorFactory in interface Parser

simpleSelector

public final Selector simpleSelector(Selector sel,
                                     char comb)
            throws ParseException

styleDeclaration

public final void styleDeclaration()
            throws ParseException

styleRule

public final void styleRule()
            throws ParseException

styleSheet

public final void styleSheet()
            throws ParseException

styleSheetRuleList

public final void styleSheetRuleList()
            throws ParseException

styleSheetRuleSingle

public final void styleSheetRuleSingle()
            throws ParseException

term

public final LexicalUnit term(LexicalUnit prev)
            throws ParseException

unaryOperator

public final char unaryOperator()
            throws ParseException

unknownRule

public final void unknownRule()
            throws ParseException