com.steadystate.css.parser
Class SACParser

java.lang.Object
  extended by 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
 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
SACParser()
           
SACParser(CharStream stream)
           
SACParser(SACParserTokenManager tm)
           
 
Method Summary
 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()
           
 java.lang.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()
           
 java.lang.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(InputSource source)
          Parse a CSS document.
 void parseStyleSheet(java.lang.String uri)
          Parse a CSS document from a URI.
 boolean prio()
           
 java.lang.String property()
           
 Condition pseudo(Condition pred)
           
 java.lang.String pseudoPage()
           
 void ReInit(CharStream stream)
           
 void ReInit(SACParserTokenManager tm)
           
 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(java.util.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 styleRuleDeclarations()
           
 void styleSheet()
           
 void styleSheetRuleList()
           
 void styleSheetRuleSingle()
           
 LexicalUnit term(LexicalUnit prev)
           
 char unaryOperator()
           
 void unknownRule()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 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.
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 interface Parser
Parameters:
handler - The document handler.
See Also:
DocumentHandler

setSelectorFactory

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

setConditionFactory

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

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 interface Parser
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 interface Parser
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 interface Parser
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 interface Parser
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 interface Parser
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 interface Parser

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 interface Parser
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 interface Parser
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 interface Parser
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()