Class SACParser
- java.lang.Object
-
- com.steadystate.css.parser.SACParser
-
- All Implemented Interfaces:
SACParserConstants
,Parser
public class SACParser extends java.lang.Object implements Parser, SACParserConstants
- Version:
- $Release$
- Author:
- David Schweinsberg
-
-
Field Summary
Fields Modifier and Type Field Description 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, 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 Summary
Constructors Constructor Description SACParser()
SACParser(CharStream stream)
SACParser(SACParserTokenManager tm)
-
Method Summary
-
-
-
Field Detail
-
token_source
public SACParserTokenManager token_source
-
token
public Token token
-
jj_nt
public Token jj_nt
-
lookingAhead
public boolean lookingAhead
-
-
Constructor Detail
-
SACParser
public SACParser()
-
SACParser
public SACParser(CharStream stream)
-
SACParser
public SACParser(SACParserTokenManager tm)
-
-
Method Detail
-
setLocale
public void setLocale(java.util.Locale locale) throws CSSException
Description copied from interface:Parser
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 interfaceParser
- Parameters:
locale
- A Java Locale object.- Throws:
CSSException
- Throws an exception (using the previous or default locale) if the requested locale is not supported.- See Also:
CSSException
,CSSParseException
-
setDocumentHandler
public void setDocumentHandler(DocumentHandler handler)
Description copied from interface:Parser
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 interfaceParser
- Parameters:
handler
- The document handler.- See Also:
DocumentHandler
-
setSelectorFactory
public void setSelectorFactory(SelectorFactory selectorFactory)
- Specified by:
setSelectorFactory
in interfaceParser
-
setConditionFactory
public void setConditionFactory(ConditionFactory conditionFactory)
- Specified by:
setConditionFactory
in interfaceParser
-
setErrorHandler
public void setErrorHandler(ErrorHandler handler)
Description copied from interface:Parser
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 interfaceParser
- Parameters:
handler
- The error handler.- See Also:
ErrorHandler
,CSSException
-
parseStyleSheet
public void parseStyleSheet(InputSource source) throws CSSException, java.io.IOException
Description copied from interface:Parser
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 interfaceParser
- Parameters:
source
- The input source for the top-level of the CSS document.- Throws:
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.- See Also:
InputSource
,Parser.parseStyleSheet(java.lang.String)
,Parser.setDocumentHandler(org.w3c.css.sac.DocumentHandler)
,Parser.setErrorHandler(org.w3c.css.sac.ErrorHandler)
-
parseStyleSheet
public void parseStyleSheet(java.lang.String uri) throws CSSException, java.io.IOException
Description copied from interface:Parser
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 interfaceParser
- Parameters:
uri
- The URI.- Throws:
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.- See Also:
Parser.parseStyleSheet(InputSource)
-
parseStyleDeclaration
public void parseStyleDeclaration(InputSource source) throws CSSException, java.io.IOException
Description copied from interface:Parser
Parse a CSS style declaration (without '{' and '}').- Specified by:
parseStyleDeclaration
in interfaceParser
- Throws:
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.
-
parseRule
public void parseRule(InputSource source) throws CSSException, java.io.IOException
Description copied from interface:Parser
Parse a CSS rule.- Specified by:
parseRule
in interfaceParser
- Throws:
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.
-
getParserVersion
public java.lang.String getParserVersion()
Description copied from interface:Parser
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 interfaceParser
-
parseSelectors
public SelectorList parseSelectors(InputSource source) throws CSSException, java.io.IOException
Description copied from interface:Parser
Parse a comma separated list of selectors.- Specified by:
parseSelectors
in interfaceParser
- Throws:
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.
-
parsePropertyValue
public LexicalUnit parsePropertyValue(InputSource source) throws CSSException, java.io.IOException
Description copied from interface:Parser
Parse a CSS property value.- Specified by:
parsePropertyValue
in interfaceParser
- Throws:
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.
-
parsePriority
public boolean parsePriority(InputSource source) throws CSSException, java.io.IOException
Description copied from interface:Parser
Parse a CSS priority value (e.g. "!important").- Specified by:
parsePriority
in interfaceParser
- Throws:
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.
-
styleSheet
public final void styleSheet() throws ParseException
- Throws:
ParseException
-
styleSheetRuleList
public final void styleSheetRuleList() throws ParseException
- Throws:
ParseException
-
styleSheetRuleSingle
public final void styleSheetRuleSingle() throws ParseException
- Throws:
ParseException
-
charsetRule
public final void charsetRule() throws ParseException
- Throws:
ParseException
-
unknownRule
public final void unknownRule() throws ParseException
- Throws:
ParseException
-
importRule
public final void importRule() throws ParseException
- Throws:
ParseException
-
mediaRule
public final void mediaRule() throws ParseException
- Throws:
ParseException
-
mediaQuery
public final void mediaQuery(SACMediaListImpl ml) throws ParseException
- Throws:
ParseException
-
mediaListOrExpression
public final void mediaListOrExpression(SACMediaListImpl ml) throws ParseException
- Throws:
ParseException
-
mediaExpression
public final void mediaExpression(SACMediaListImpl ml) throws ParseException
- Throws:
ParseException
-
mediaFeature
public final void mediaFeature(SACMediaListImpl ml) throws ParseException
- Throws:
ParseException
-
mediaList
public final void mediaList(SACMediaListImpl ml) throws ParseException
- Throws:
ParseException
-
mediaRuleList
public final void mediaRuleList() throws ParseException
- Throws:
ParseException
-
mediaRuleSingle
public final void mediaRuleSingle() throws ParseException
- Throws:
ParseException
-
medium
public final java.lang.String medium() throws ParseException
- Throws:
ParseException
-
pageRule
public final void pageRule() throws ParseException
- Throws:
ParseException
-
pseudoPage
public final java.lang.String pseudoPage() throws ParseException
- Throws:
ParseException
-
fontFaceRule
public final void fontFaceRule() throws ParseException
- Throws:
ParseException
-
operator
public final LexicalUnit operator(LexicalUnit prev) throws ParseException
- Throws:
ParseException
-
combinator
public final char combinator() throws ParseException
- Throws:
ParseException
-
unaryOperator
public final char unaryOperator() throws ParseException
- Throws:
ParseException
-
property
public final java.lang.String property() throws ParseException
- Throws:
ParseException
-
styleRule
public final void styleRule() throws ParseException
- Throws:
ParseException
-
styleRuleDeclarations
public final void styleRuleDeclarations() throws ParseException
- Throws:
ParseException
-
selectorList
public final SelectorList selectorList() throws ParseException
- Throws:
ParseException
-
selector
public final Selector selector() throws ParseException
- Throws:
ParseException
-
simpleSelector
public final Selector simpleSelector(Selector sel, char comb) throws ParseException
- Throws:
ParseException
-
_class
public final Condition _class(Condition pred) throws ParseException
- Throws:
ParseException
-
elementName
public final SimpleSelector elementName() throws ParseException
- Throws:
ParseException
-
attrib
public final Condition attrib(Condition pred) throws ParseException
- Throws:
ParseException
-
pseudo
public final Condition pseudo(Condition pred) throws ParseException
- Throws:
ParseException
-
hash
public final Condition hash(Condition pred) throws ParseException
- Throws:
ParseException
-
styleDeclaration
public final void styleDeclaration() throws ParseException
- Throws:
ParseException
-
declaration
public final void declaration() throws ParseException
- Throws:
ParseException
-
prio
public final boolean prio() throws ParseException
- Throws:
ParseException
-
expr
public final LexicalUnit expr() throws ParseException
- Throws:
ParseException
-
term
public final LexicalUnit term(LexicalUnit prev) throws ParseException
- Throws:
ParseException
-
function
public final LexicalUnit function(LexicalUnit prev) throws ParseException
- Throws:
ParseException
-
rgb
public final LexicalUnit rgb(LexicalUnit prev) throws ParseException
- Throws:
ParseException
-
hexcolor
public final LexicalUnit hexcolor(LexicalUnit prev) throws ParseException
- Throws:
ParseException
-
ReInit
public void ReInit(CharStream stream)
-
ReInit
public void ReInit(SACParserTokenManager tm)
-
getNextToken
public final Token getNextToken()
-
getToken
public final Token getToken(int index)
-
generateParseException
public ParseException generateParseException()
-
enable_tracing
public final void enable_tracing()
-
disable_tracing
public final void disable_tracing()
-
-