com.steadystate.css.parser
public class SACParser extends java.lang.Object implements Parser, SACParserConstants
Modifier and Type | Field and Description |
---|---|
Token |
jj_nt |
boolean |
lookingAhead |
Token |
token |
SACParserTokenManager |
token_source |
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, IMPORT_SYM, IMPORTANT_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, tokenImage, UNICODE, UNICODERANGE, UNKNOWN, URI, URL
Constructor and Description |
---|
SACParser() |
SACParser(CharStream stream) |
SACParser(SACParserTokenManager tm) |
public SACParserTokenManager token_source
public Token token
public Token jj_nt
public boolean lookingAhead
public SACParser()
public SACParser(CharStream stream)
public SACParser(SACParserTokenManager tm)
public void setLocale(java.util.Locale locale) throws CSSException
Parser
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.
setLocale
in interface Parser
locale
- A Java Locale object.CSSException
- Throws an exception
(using the previous or default locale) if the
requested locale is not supported.CSSException
,
CSSParseException
public void setDocumentHandler(DocumentHandler handler)
Parser
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.
setDocumentHandler
in interface Parser
handler
- The document handler.DocumentHandler
public void setSelectorFactory(SelectorFactory selectorFactory)
setSelectorFactory
in interface Parser
public void setConditionFactory(ConditionFactory conditionFactory)
setConditionFactory
in interface Parser
public void setErrorHandler(ErrorHandler handler)
Parser
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.
setErrorHandler
in interface Parser
handler
- The error handler.ErrorHandler
,
CSSException
public void parseStyleSheet(InputSource source) throws CSSException, java.io.IOException
Parser
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.
parseStyleSheet
in interface Parser
source
- The input source for the top-level of the
CSS document.CSSException
- Any CSS exception, possibly
wrapping another exception.java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.InputSource
,
Parser.parseStyleSheet(java.lang.String)
,
Parser.setDocumentHandler(org.w3c.css.sac.DocumentHandler)
,
Parser.setErrorHandler(org.w3c.css.sac.ErrorHandler)
public void parseStyleSheet(java.lang.String uri) throws CSSException, java.io.IOException
Parser
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.
parseStyleSheet
in interface Parser
uri
- The URI.CSSException
- Any CSS exception, possibly
wrapping another exception.java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.Parser.parseStyleSheet(InputSource)
public void parseStyleDeclaration(InputSource source) throws CSSException, java.io.IOException
Parser
parseStyleDeclaration
in interface Parser
CSSException
- Any CSS exception, possibly
wrapping another exception.java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public void parseRule(InputSource source) throws CSSException, java.io.IOException
Parser
parseRule
in interface Parser
CSSException
- Any CSS exception, possibly
wrapping another exception.java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public java.lang.String getParserVersion()
Parser
getParserVersion
in interface Parser
public SelectorList parseSelectors(InputSource source) throws CSSException, java.io.IOException
Parser
parseSelectors
in interface Parser
CSSException
- Any CSS exception, possibly
wrapping another exception.java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public LexicalUnit parsePropertyValue(InputSource source) throws CSSException, java.io.IOException
Parser
parsePropertyValue
in interface Parser
CSSException
- Any CSS exception, possibly
wrapping another exception.java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public boolean parsePriority(InputSource source) throws CSSException, java.io.IOException
Parser
parsePriority
in interface Parser
CSSException
- Any CSS exception, possibly
wrapping another exception.java.io.IOException
- An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.public final void styleSheet() throws ParseException
ParseException
public final void styleSheetRuleList() throws ParseException
ParseException
public final void styleSheetRuleSingle() throws ParseException
ParseException
public final void charsetRule() throws ParseException
ParseException
public final void unknownRule() throws ParseException
ParseException
public final void importRule() throws ParseException
ParseException
public final void mediaRule() throws ParseException
ParseException
public final void mediaQuery(SACMediaListImpl ml) throws ParseException
ParseException
public final void mediaListOrExpression(SACMediaListImpl ml) throws ParseException
ParseException
public final void mediaExpression(SACMediaListImpl ml) throws ParseException
ParseException
public final void mediaFeature(SACMediaListImpl ml) throws ParseException
ParseException
public final void mediaList(SACMediaListImpl ml) throws ParseException
ParseException
public final void mediaRuleList() throws ParseException
ParseException
public final void mediaRuleSingle() throws ParseException
ParseException
public final java.lang.String medium() throws ParseException
ParseException
public final void pageRule() throws ParseException
ParseException
public final java.lang.String pseudoPage() throws ParseException
ParseException
public final void fontFaceRule() throws ParseException
ParseException
public final LexicalUnit operator(LexicalUnit prev) throws ParseException
ParseException
public final char combinator() throws ParseException
ParseException
public final char unaryOperator() throws ParseException
ParseException
public final java.lang.String property() throws ParseException
ParseException
public final void styleRule() throws ParseException
ParseException
public final void styleRuleDeclarations() throws ParseException
ParseException
public final SelectorList selectorList() throws ParseException
ParseException
public final Selector selector() throws ParseException
ParseException
public final Selector simpleSelector(Selector sel, char comb) throws ParseException
ParseException
public final Condition _class(Condition pred) throws ParseException
ParseException
public final SimpleSelector elementName() throws ParseException
ParseException
public final Condition attrib(Condition pred) throws ParseException
ParseException
public final Condition pseudo(Condition pred) throws ParseException
ParseException
public final Condition hash(Condition pred) throws ParseException
ParseException
public final void styleDeclaration() throws ParseException
ParseException
public final void declaration() throws ParseException
ParseException
public final boolean prio() throws ParseException
ParseException
public final LexicalUnit expr() throws ParseException
ParseException
public final LexicalUnit term(LexicalUnit prev) throws ParseException
ParseException
public final LexicalUnit function(LexicalUnit prev) throws ParseException
ParseException
public final LexicalUnit rgb(LexicalUnit prev) throws ParseException
ParseException
public final LexicalUnit hexcolor(LexicalUnit prev) throws ParseException
ParseException
public void ReInit(CharStream stream)
public void ReInit(SACParserTokenManager tm)
public final Token getNextToken()
public final Token getToken(int index)
public ParseException generateParseException()
public final void enable_tracing()
public final void disable_tracing()