## org.apache.batik.css.parser
Class Parser

    java.lang.Object
      org.apache.batik.css.parser.Parser

All Implemented Interfaces:
  ExtendedParser, Localizable, Parser

public class Parser
extends java.lang.Object
implements ExtendedParser, Localizable

This class implements the `Parser` interface.

Field Summary
`static java.lang.String` `BUNDLE_CLASSNAME` The default resource bundle base name.
`protected ConditionFactory` `conditionFactory` The condition factory.
`protected int` `current` The current lexical unit.
`protected DocumentHandler` `documentHandler` The document handler.
`protected java.lang.String` `documentURI` The document URI.
`protected ErrorHandler` `errorHandler` The error handler.
`protected LocalizableSupport` `localizableSupport` The localizable support.
`protected java.lang.String` `pseudoElement` To store the current pseudo element.
`protected Scanner` `scanner` The scanner used to scan the input source.
`protected SelectorFactory` `selectorFactory` The selector factory.

Constructor Summary
`Parser()`

Method Summary
`protected CSSParseException` `createCSSParseException(java.lang.String key)` Creates a parse exception.
`protected CSSParseException` `createCSSParseException(java.lang.String key, java.lang.Object[] params)` Creates a parse exception.
`protected Scanner` `createScanner(InputSource source)` Creates a scanner, given an InputSource.
`protected LexicalUnit` `dimension(boolean positive, LexicalUnit prev)` Converts the current lexical unit to a dimension.
`java.lang.String` `formatMessage(java.lang.String key, java.lang.Object[] args)` Implements `Localizable.formatMessage(String,Object[])`.
`java.util.Locale` `getLocale()` Implements `Localizable.getLocale()`.
`java.lang.String` `getParserVersion()` SAC: Implements `Parser.getParserVersion()`.
`protected LexicalUnit` `hexcolor(LexicalUnit prev)` Converts a hash unit to a RGB color.
`protected boolean` `isPseudoElement(java.lang.String s)` Tells whether or not the given string represents a pseudo-element.
`protected int` `next()` Advances to the next token, ignoring comments.
`protected int` `nextIgnoreSpaces()` Advances to the next token and skip the spaces, ignoring comments.
`protected float` `number(boolean positive)` Converts the current lexical unit to a float.
`protected void` `parseAtRule()` Parses an unknown rule.
`protected LexicalUnit` `parseExpression(boolean param)` Parses a CSS2 expression.
`protected void` `parseFontFaceRule()` Parses a font-face rule.
`protected LexicalUnit` `parseFunction(boolean positive, LexicalUnit prev)` Parses a CSS2 function.
`protected void` `parseImportRule()` Parses an import rule.
`SACMediaList` `parseMedia(java.lang.String mediaText)` Implements `ExtendedParser.parseMedia(String)`.
`protected CSSSACMediaList` `parseMediaList()` Parses a media list.
`protected void` `parseMediaRule()` Parses a media rule.
`protected void` `parsePageRule()` Parses a page rule.
`boolean` `parsePriority(InputSource source)` SAC: Implements `Parser.parsePriority(InputSource)`.
`boolean` `parsePriority(java.lang.String source)` Implements `ExtendedParser.parsePriority(String)`.
`protected boolean` `parsePriorityInternal()` Parses the priority using the current scanner.
`LexicalUnit` `parsePropertyValue(InputSource source)` SAC: Implements `Parser.parsePropertyValue(InputSource)`.
`LexicalUnit` `parsePropertyValue(java.lang.String source)` Implements `ExtendedParser.parsePropertyValue(String)`.
`protected LexicalUnit` `parsePropertyValueInternal()` Parses property value using the current scanner.
`protected void` `parseRule()` Parses a rule.
`void` `parseRule(InputSource source)` SAC: Implements `Parser.parseRule(InputSource)`.
`void` `parseRule(java.lang.String source)` Implements `ExtendedParser.parseRule(String)`.
`protected void` `parseRuleInternal()` Parses a rule using the current scanner.
`protected void` `parseRuleSet()` Parses a ruleset.
`protected Selector` `parseSelector()` Parses a selector.
`protected SelectorList` `parseSelectorList()` Parses a selector list
`SelectorList` `parseSelectors(InputSource source)` SAC: Implements `Parser.parseSelectors(InputSource)`.
`SelectorList` `parseSelectors(java.lang.String source)` Implements `ExtendedParser.parseSelectors(String)`.
`protected SelectorList` `parseSelectorsInternal()` Parses selectors using the current scanner.
`protected SimpleSelector` `parseSimpleSelector()` Parses a simple selector.
`protected void` `parseStyleDeclaration(boolean inSheet)` Parses the given reader.
`void` `parseStyleDeclaration(InputSource source)` SAC: Implements `Parser.parseStyleDeclaration(InputSource)`.
`void` `parseStyleDeclaration(java.lang.String source)` Implements `ExtendedParser.parseStyleDeclaration(String)`.
`protected void` `parseStyleDeclarationInternal()` Parses a style declaration using the current scanner.
`void` `parseStyleSheet(InputSource source)` SAC: Implements `Parser.parseStyleSheet(InputSource)`.
`void` `parseStyleSheet(java.lang.String uri)` SAC: Implements `Parser.parseStyleSheet(String)`.
`protected LexicalUnit` `parseTerm(LexicalUnit prev)` Parses a CSS2 term.
`protected void` `reportError(CSSParseException e)` Reports a parsing error.
`protected void` `reportError(java.lang.String key)` Reports a parsing error.
`protected void` `reportError(java.lang.String key, java.lang.Object[] params)` Reports a parsing error.
`void` `setConditionFactory(ConditionFactory factory)` SAC: Implements `Parser.setConditionFactory(ConditionFactory)`.
`void` `setDocumentHandler(DocumentHandler handler)` SAC: Implements `Parser.setDocumentHandler(DocumentHandler)`.
`void` `setErrorHandler(ErrorHandler handler)` SAC: Implements `Parser.setErrorHandler(ErrorHandler)`.
`void` `setLocale(java.util.Locale locale)` SAC: Implements `Parser.setLocale(Locale)`.
`void` `setSelectorFactory(SelectorFactory factory)` SAC: Implements `Parser.setSelectorFactory(SelectorFactory)`.
`protected int` `skipSpaces()` Skips the white spaces.
`protected int` `skipSpacesAndCDOCDC()` Skips the white spaces and CDO/CDC units.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### BUNDLE_CLASSNAME

    public static final java.lang.String BUNDLE_CLASSNAME

  The default resource bundle base name.

  See Also:
    Constant Field Values

### localizableSupport

    protected LocalizableSupport localizableSupport

  The localizable support.

### scanner

    protected Scanner scanner

  The scanner used to scan the input source.

### current

    protected int current

  The current lexical unit.

### documentHandler

    protected DocumentHandler documentHandler

  The document handler.

### selectorFactory

    protected SelectorFactory selectorFactory

  The selector factory.

### conditionFactory

    protected ConditionFactory conditionFactory

  The condition factory.

### errorHandler

    protected ErrorHandler errorHandler

  The error handler.

### pseudoElement

    protected java.lang.String pseudoElement

  To store the current pseudo element.

### documentURI

    protected java.lang.String documentURI

  The document URI.

Constructor Detail

### Parser

    public Parser()

Method Detail

### getParserVersion

    public java.lang.String getParserVersion()

  SAC: Implements `Parser.getParserVersion()`.

  Specified by:
    `getParserVersion` in interface `Parser`
  Returns:
    "http://www.w3.org/TR/REC-CSS2".

### setLocale

    public void setLocale(java.util.Locale locale)
                   throws CSSException

  SAC: Implements `Parser.setLocale(Locale)`.

  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`

### getLocale

    public java.util.Locale getLocale()

  Implements `Localizable.getLocale()`.

  Specified by:
    `getLocale` in interface `Localizable`

### formatMessage

    public java.lang.String formatMessage(java.lang.String key,
                                          java.lang.Object[] args)
                                   throws java.util.MissingResourceException

  Implements `Localizable.formatMessage(String,Object[])`.

  Specified by:
    `formatMessage` in interface `Localizable`
  Parameters:
    `key` - The key used to retreive the message from the resource bundle.
    `args` - The objects that compose the message.
  Throws:
    `java.util.MissingResourceException` - if the key is not in the bundle.

### setDocumentHandler

    public void setDocumentHandler(DocumentHandler handler)

  SAC: Implements `Parser.setDocumentHandler(DocumentHandler)`.

  Specified by:
    `setDocumentHandler` in interface `Parser`
  Parameters:
    `handler` - The document handler.
  See Also:
    `DocumentHandler`

### setSelectorFactory

    public void setSelectorFactory(SelectorFactory factory)

  SAC: Implements `Parser.setSelectorFactory(SelectorFactory)`.

  Specified by:
    `setSelectorFactory` in interface `Parser`

### setConditionFactory

    public void setConditionFactory(ConditionFactory factory)

  SAC: Implements `Parser.setConditionFactory(ConditionFactory)`.

  Specified by:
    `setConditionFactory` in interface `Parser`

### setErrorHandler

    public void setErrorHandler(ErrorHandler handler)

  SAC: Implements `Parser.setErrorHandler(ErrorHandler)`.

  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

  SAC: Implements `Parser.parseStyleSheet(InputSource)`.

  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

  SAC: Implements `Parser.parseStyleSheet(String)`.

  Specified by:
    `parseStyleSheet` in interface `Parser`
  Parameters:
    `uri` - The URI.
  Throws:
    `java.io.IOException` - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
    `CSSException` - Any CSS exception, possibly wrapping another exception.
  See Also:
    `Parser.parseStyleSheet(InputSource)`

### parseStyleDeclaration

    public void parseStyleDeclaration(InputSource source)
                               throws CSSException,
                                      java.io.IOException

  SAC: Implements `Parser.parseStyleDeclaration(InputSource)`.

  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.

### parseStyleDeclarationInternal

    protected void parseStyleDeclarationInternal()
                                          throws CSSException,
                                                 java.io.IOException

  Parses a style declaration using the current scanner.

  Throws:
    `CSSException`
    `java.io.IOException`

### parseRule

    public void parseRule(InputSource source)
                   throws CSSException,
                          java.io.IOException

  SAC: Implements `Parser.parseRule(InputSource)`.

  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.

### parseRuleInternal

    protected void parseRuleInternal()
                              throws CSSException,
                                     java.io.IOException

  Parses a rule using the current scanner.

  Throws:
    `CSSException`
    `java.io.IOException`

### parseSelectors

    public SelectorList parseSelectors(InputSource source)
                                throws CSSException,
                                       java.io.IOException

  SAC: Implements `Parser.parseSelectors(InputSource)`.

  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.

### parseSelectorsInternal

    protected SelectorList parseSelectorsInternal()
                                           throws CSSException,
                                                  java.io.IOException

  Parses selectors using the current scanner.

  Throws:
    `CSSException`
    `java.io.IOException`

### parsePropertyValue

    public LexicalUnit parsePropertyValue(InputSource source)
                                   throws CSSException,
                                          java.io.IOException

  SAC: Implements `Parser.parsePropertyValue(InputSource)`.

  Specified by:
    `parsePropertyValue` in interface `Parser`
  Throws:
    `java.io.IOException` - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
    `CSSException` - Any CSS exception, possibly wrapping another exception.

### parsePropertyValueInternal

    protected LexicalUnit parsePropertyValueInternal()
                                              throws CSSException,
                                                     java.io.IOException

  Parses property value using the current scanner.

  Throws:
    `CSSException`
    `java.io.IOException`

### parsePriority

    public boolean parsePriority(InputSource source)
                          throws CSSException,
                                 java.io.IOException

  SAC: Implements `Parser.parsePriority(InputSource)`.

  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.

### parsePriorityInternal

    protected boolean parsePriorityInternal()
                                     throws CSSException,
                                            java.io.IOException

  Parses the priority using the current scanner.

  Throws:
    `CSSException`
    `java.io.IOException`

### parseRule

    protected void parseRule()

  Parses a rule.

### parseAtRule

    protected void parseAtRule()

  Parses an unknown rule.

### parseImportRule

    protected void parseImportRule()

  Parses an import rule. Assumes the current token is '@import'.

### parseMediaList

    protected CSSSACMediaList parseMediaList()

  Parses a media list.

### parseFontFaceRule

    protected void parseFontFaceRule()

  Parses a font-face rule.

### parsePageRule

    protected void parsePageRule()

  Parses a page rule.

### parseMediaRule

    protected void parseMediaRule()

  Parses a media rule.

### parseRuleSet

    protected void parseRuleSet()

  Parses a ruleset.

### parseSelectorList

    protected SelectorList parseSelectorList()

  Parses a selector list

### parseSelector

    protected Selector parseSelector()

  Parses a selector.

### parseSimpleSelector

    protected SimpleSelector parseSimpleSelector()

  Parses a simple selector.

### isPseudoElement

    protected boolean isPseudoElement(java.lang.String s)

  Tells whether or not the given string represents a pseudo-element.

### parseStyleDeclaration

    protected void parseStyleDeclaration(boolean inSheet)
                                  throws CSSException

  Parses the given reader.

  Throws:
    `CSSException`

### parseExpression

    protected LexicalUnit parseExpression(boolean param)

  Parses a CSS2 expression.

### parseTerm

    protected LexicalUnit parseTerm(LexicalUnit prev)

  Parses a CSS2 term.

### parseFunction

    protected LexicalUnit parseFunction(boolean positive,
                                        LexicalUnit prev)

  Parses a CSS2 function.

### hexcolor

    protected LexicalUnit hexcolor(LexicalUnit prev)

  Converts a hash unit to a RGB color.

### createScanner

    protected Scanner createScanner(InputSource source)

  Creates a scanner, given an InputSource.

### skipSpaces

    protected int skipSpaces()

  Skips the white spaces.

### skipSpacesAndCDOCDC

    protected int skipSpacesAndCDOCDC()

  Skips the white spaces and CDO/CDC units.

### number

    protected float number(boolean positive)

  Converts the current lexical unit to a float.

### dimension

    protected LexicalUnit dimension(boolean positive,
                                    LexicalUnit prev)

  Converts the current lexical unit to a dimension.

### next

    protected int next()

  Advances to the next token, ignoring comments.

### nextIgnoreSpaces

    protected int nextIgnoreSpaces()

  Advances to the next token and skip the spaces, ignoring comments.

### reportError

    protected void reportError(java.lang.String key)

  Reports a parsing error.

### reportError

    protected void reportError(java.lang.String key,
                               java.lang.Object[] params)

  Reports a parsing error.

### reportError

    protected void reportError(CSSParseException e)

  Reports a parsing error.

### createCSSParseException

    protected CSSParseException createCSSParseException(java.lang.String key)

  Creates a parse exception.

### createCSSParseException

    protected CSSParseException createCSSParseException(java.lang.String key,
                                                        java.lang.Object[] params)

  Creates a parse exception.

### parseStyleDeclaration

    public void parseStyleDeclaration(java.lang.String source)
                               throws CSSException,
                                      java.io.IOException

  Implements `ExtendedParser.parseStyleDeclaration(String)`.

  Specified by:
    `parseStyleDeclaration` in interface `ExtendedParser`
  Throws:
    `java.io.IOException` - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
    `CSSException` - Any CSS exception, possibly wrapping another exception.

### parseRule

    public void parseRule(java.lang.String source)
                   throws CSSException,
                          java.io.IOException

  Implements `ExtendedParser.parseRule(String)`.

  Specified by:
    `parseRule` in interface `ExtendedParser`
  Throws:
    `java.io.IOException` - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
    `CSSException` - Any CSS exception, possibly wrapping another exception.

### parseSelectors

    public SelectorList parseSelectors(java.lang.String source)
                                throws CSSException,
                                       java.io.IOException

  Implements `ExtendedParser.parseSelectors(String)`.

  Specified by:
    `parseSelectors` in interface `ExtendedParser`
  Throws:
    `java.io.IOException` - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
    `CSSException` - Any CSS exception, possibly wrapping another exception.

### parsePropertyValue

    public LexicalUnit parsePropertyValue(java.lang.String source)
                                   throws CSSException,
                                          java.io.IOException

  Implements `ExtendedParser.parsePropertyValue(String)`.

  Specified by:
    `parsePropertyValue` in interface `ExtendedParser`
  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(java.lang.String source)
                          throws CSSException,
                                 java.io.IOException

  Implements `ExtendedParser.parsePriority(String)`.

  Specified by:
    `parsePriority` in interface `ExtendedParser`
  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.

### parseMedia

    public SACMediaList parseMedia(java.lang.String mediaText)
                            throws CSSException,
                                   java.io.IOException

  Implements `ExtendedParser.parseMedia(String)`.

  Specified by:
    `parseMedia` in interface `ExtendedParser`
  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.

Copyright © 2004 Apache Software Foundation. All Rights Reserved.