Package org.apache.batik.css.parser
Class Parser
- java.lang.Object
-
- org.apache.batik.css.parser.Parser
-
- All Implemented Interfaces:
ExtendedParser
,Localizable
,org.w3c.css.sac.Parser
public class Parser extends java.lang.Object implements ExtendedParser, Localizable
This class implements theParser
interface.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BUNDLE_CLASSNAME
The default resource bundle base name.protected org.w3c.css.sac.ConditionFactory
conditionFactory
The condition factory.protected int
current
The current lexical unit.protected org.w3c.css.sac.DocumentHandler
documentHandler
The document handler.protected java.lang.String
documentURI
The document URI.protected org.w3c.css.sac.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 org.w3c.css.sac.SelectorFactory
selectorFactory
The selector factory.
-
Constructor Summary
Constructors Constructor Description Parser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.w3c.css.sac.CSSParseException
createCSSParseException(java.lang.String key)
Creates a parse exception.protected org.w3c.css.sac.CSSParseException
createCSSParseException(java.lang.String key, java.lang.Object[] params)
Creates a parse exception.protected Scanner
createScanner(org.w3c.css.sac.InputSource source)
Creates a scanner, given an InputSource.protected org.w3c.css.sac.LexicalUnit
dimension(boolean positive, org.w3c.css.sac.LexicalUnit prev)
Converts the current lexical unit to a dimension.java.lang.String
formatMessage(java.lang.String key, java.lang.Object[] args)
ImplementsLocalizable.formatMessage(String,Object[])
.java.util.Locale
getLocale()
ImplementsLocalizable.getLocale()
.java.lang.String
getParserVersion()
SAC: ImplementsParser.getParserVersion()
.protected org.w3c.css.sac.LexicalUnit
hexcolor(org.w3c.css.sac.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 org.w3c.css.sac.LexicalUnit
parseExpression(boolean param)
Parses a CSS2 expression.protected void
parseFontFaceRule()
Parses a font-face rule.protected org.w3c.css.sac.LexicalUnit
parseFunction(boolean positive, org.w3c.css.sac.LexicalUnit prev)
Parses a CSS2 function.protected void
parseImportRule()
Parses an import rule.org.w3c.css.sac.SACMediaList
parseMedia(java.lang.String mediaText)
ImplementsExtendedParser.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(java.lang.String source)
ImplementsExtendedParser.parsePriority(String)
.boolean
parsePriority(org.w3c.css.sac.InputSource source)
SAC: ImplementsParser.parsePriority(InputSource)
.protected boolean
parsePriorityInternal()
Parses the priority using the current scanner.org.w3c.css.sac.LexicalUnit
parsePropertyValue(java.lang.String source)
ImplementsExtendedParser.parsePropertyValue(String)
.org.w3c.css.sac.LexicalUnit
parsePropertyValue(org.w3c.css.sac.InputSource source)
SAC: ImplementsParser.parsePropertyValue(InputSource)
.protected org.w3c.css.sac.LexicalUnit
parsePropertyValueInternal()
Parses property value using the current scanner.protected void
parseRule()
Parses a rule.void
parseRule(java.lang.String source)
ImplementsExtendedParser.parseRule(String)
.void
parseRule(org.w3c.css.sac.InputSource source)
SAC: ImplementsParser.parseRule(InputSource)
.protected void
parseRuleInternal()
Parses a rule using the current scanner.protected void
parseRuleSet()
Parses a ruleset.protected org.w3c.css.sac.Selector
parseSelector()
Parses a selector.protected org.w3c.css.sac.SelectorList
parseSelectorList()
Parses a selector listorg.w3c.css.sac.SelectorList
parseSelectors(java.lang.String source)
ImplementsExtendedParser.parseSelectors(String)
.org.w3c.css.sac.SelectorList
parseSelectors(org.w3c.css.sac.InputSource source)
SAC: ImplementsParser.parseSelectors(InputSource)
.protected org.w3c.css.sac.SelectorList
parseSelectorsInternal()
Parses selectors using the current scanner.protected org.w3c.css.sac.SimpleSelector
parseSimpleSelector()
Parses a simple selector.protected void
parseStyleDeclaration(boolean inSheet)
Parses the given reader.void
parseStyleDeclaration(java.lang.String source)
ImplementsExtendedParser.parseStyleDeclaration(String)
.void
parseStyleDeclaration(org.w3c.css.sac.InputSource source)
SAC: ImplementsParser.parseStyleDeclaration(InputSource)
.protected void
parseStyleDeclarationInternal()
Parses a style declaration using the current scanner.void
parseStyleSheet(java.lang.String uri)
SAC: ImplementsParser.parseStyleSheet(String)
.void
parseStyleSheet(org.w3c.css.sac.InputSource source)
SAC: ImplementsParser.parseStyleSheet(InputSource)
.protected org.w3c.css.sac.LexicalUnit
parseTerm(org.w3c.css.sac.LexicalUnit prev)
Parses a CSS2 term.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.protected void
reportError(org.w3c.css.sac.CSSParseException e)
Reports a parsing error.void
setConditionFactory(org.w3c.css.sac.ConditionFactory factory)
SAC: ImplementsParser.setConditionFactory(ConditionFactory)
.void
setDocumentHandler(org.w3c.css.sac.DocumentHandler handler)
SAC: ImplementsParser.setDocumentHandler(DocumentHandler)
.void
setErrorHandler(org.w3c.css.sac.ErrorHandler handler)
SAC: ImplementsParser.setErrorHandler(ErrorHandler)
.void
setLocale(java.util.Locale locale)
SAC: ImplementsParser.setLocale(Locale)
.void
setSelectorFactory(org.w3c.css.sac.SelectorFactory factory)
SAC: ImplementsParser.setSelectorFactory(SelectorFactory)
.protected int
skipSpaces()
Skips the white spaces.protected int
skipSpacesAndCDOCDC()
Skips the white spaces and CDO/CDC units.
-
-
-
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 org.w3c.css.sac.DocumentHandler documentHandler
The document handler.
-
selectorFactory
protected org.w3c.css.sac.SelectorFactory selectorFactory
The selector factory.
-
conditionFactory
protected org.w3c.css.sac.ConditionFactory conditionFactory
The condition factory.
-
errorHandler
protected org.w3c.css.sac.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.
-
-
Method Detail
-
getParserVersion
public java.lang.String getParserVersion()
SAC: ImplementsParser.getParserVersion()
.- Specified by:
getParserVersion
in interfaceorg.w3c.css.sac.Parser
- Returns:
- "http://www.w3.org/TR/REC-CSS2".
-
setLocale
public void setLocale(java.util.Locale locale) throws org.w3c.css.sac.CSSException
SAC: ImplementsParser.setLocale(Locale)
.- Specified by:
setLocale
in interfaceLocalizable
- Specified by:
setLocale
in interfaceorg.w3c.css.sac.Parser
- Parameters:
locale
- The locale to set.- Throws:
org.w3c.css.sac.CSSException
-
getLocale
public java.util.Locale getLocale()
ImplementsLocalizable.getLocale()
.- Specified by:
getLocale
in interfaceLocalizable
-
formatMessage
public java.lang.String formatMessage(java.lang.String key, java.lang.Object[] args) throws java.util.MissingResourceException
ImplementsLocalizable.formatMessage(String,Object[])
.- Specified by:
formatMessage
in interfaceLocalizable
- 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(org.w3c.css.sac.DocumentHandler handler)
SAC: ImplementsParser.setDocumentHandler(DocumentHandler)
.- Specified by:
setDocumentHandler
in interfaceorg.w3c.css.sac.Parser
-
setSelectorFactory
public void setSelectorFactory(org.w3c.css.sac.SelectorFactory factory)
SAC: ImplementsParser.setSelectorFactory(SelectorFactory)
.- Specified by:
setSelectorFactory
in interfaceorg.w3c.css.sac.Parser
-
setConditionFactory
public void setConditionFactory(org.w3c.css.sac.ConditionFactory factory)
SAC: ImplementsParser.setConditionFactory(ConditionFactory)
.- Specified by:
setConditionFactory
in interfaceorg.w3c.css.sac.Parser
-
setErrorHandler
public void setErrorHandler(org.w3c.css.sac.ErrorHandler handler)
SAC: ImplementsParser.setErrorHandler(ErrorHandler)
.- Specified by:
setErrorHandler
in interfaceorg.w3c.css.sac.Parser
-
parseStyleSheet
public void parseStyleSheet(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException, java.io.IOException
SAC: ImplementsParser.parseStyleSheet(InputSource)
.- Specified by:
parseStyleSheet
in interfaceorg.w3c.css.sac.Parser
- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parseStyleSheet
public void parseStyleSheet(java.lang.String uri) throws org.w3c.css.sac.CSSException, java.io.IOException
SAC: ImplementsParser.parseStyleSheet(String)
.- Specified by:
parseStyleSheet
in interfaceorg.w3c.css.sac.Parser
- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parseStyleDeclaration
public void parseStyleDeclaration(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException, java.io.IOException
SAC: ImplementsParser.parseStyleDeclaration(InputSource)
.- Specified by:
parseStyleDeclaration
in interfaceorg.w3c.css.sac.Parser
- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parseStyleDeclarationInternal
protected void parseStyleDeclarationInternal() throws org.w3c.css.sac.CSSException, java.io.IOException
Parses a style declaration using the current scanner.- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parseRule
public void parseRule(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException, java.io.IOException
SAC: ImplementsParser.parseRule(InputSource)
.- Specified by:
parseRule
in interfaceorg.w3c.css.sac.Parser
- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parseRuleInternal
protected void parseRuleInternal() throws org.w3c.css.sac.CSSException, java.io.IOException
Parses a rule using the current scanner.- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parseSelectors
public org.w3c.css.sac.SelectorList parseSelectors(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException, java.io.IOException
SAC: ImplementsParser.parseSelectors(InputSource)
.- Specified by:
parseSelectors
in interfaceorg.w3c.css.sac.Parser
- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parseSelectorsInternal
protected org.w3c.css.sac.SelectorList parseSelectorsInternal() throws org.w3c.css.sac.CSSException, java.io.IOException
Parses selectors using the current scanner.- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parsePropertyValue
public org.w3c.css.sac.LexicalUnit parsePropertyValue(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException, java.io.IOException
SAC: ImplementsParser.parsePropertyValue(InputSource)
.- Specified by:
parsePropertyValue
in interfaceorg.w3c.css.sac.Parser
- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parsePropertyValueInternal
protected org.w3c.css.sac.LexicalUnit parsePropertyValueInternal() throws org.w3c.css.sac.CSSException, java.io.IOException
Parses property value using the current scanner.- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parsePriority
public boolean parsePriority(org.w3c.css.sac.InputSource source) throws org.w3c.css.sac.CSSException, java.io.IOException
SAC: ImplementsParser.parsePriority(InputSource)
.- Specified by:
parsePriority
in interfaceorg.w3c.css.sac.Parser
- Throws:
org.w3c.css.sac.CSSException
java.io.IOException
-
parsePriorityInternal
protected boolean parsePriorityInternal() throws org.w3c.css.sac.CSSException, java.io.IOException
Parses the priority using the current scanner.- Throws:
org.w3c.css.sac.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 org.w3c.css.sac.SelectorList parseSelectorList()
Parses a selector list
-
parseSelector
protected org.w3c.css.sac.Selector parseSelector()
Parses a selector.
-
parseSimpleSelector
protected org.w3c.css.sac.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 org.w3c.css.sac.CSSException
Parses the given reader.- Throws:
org.w3c.css.sac.CSSException
-
parseExpression
protected org.w3c.css.sac.LexicalUnit parseExpression(boolean param)
Parses a CSS2 expression.- Parameters:
param
- whether the expression to be parsed is a function parameter
-
parseTerm
protected org.w3c.css.sac.LexicalUnit parseTerm(org.w3c.css.sac.LexicalUnit prev)
Parses a CSS2 term.
-
parseFunction
protected org.w3c.css.sac.LexicalUnit parseFunction(boolean positive, org.w3c.css.sac.LexicalUnit prev)
Parses a CSS2 function.
-
hexcolor
protected org.w3c.css.sac.LexicalUnit hexcolor(org.w3c.css.sac.LexicalUnit prev)
Converts a hash unit to a RGB color.
-
createScanner
protected Scanner createScanner(org.w3c.css.sac.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 org.w3c.css.sac.LexicalUnit dimension(boolean positive, org.w3c.css.sac.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(org.w3c.css.sac.CSSParseException e)
Reports a parsing error.
-
createCSSParseException
protected org.w3c.css.sac.CSSParseException createCSSParseException(java.lang.String key)
Creates a parse exception.
-
createCSSParseException
protected org.w3c.css.sac.CSSParseException createCSSParseException(java.lang.String key, java.lang.Object[] params)
Creates a parse exception.
-
parseStyleDeclaration
public void parseStyleDeclaration(java.lang.String source) throws org.w3c.css.sac.CSSException, java.io.IOException
ImplementsExtendedParser.parseStyleDeclaration(String)
.- Specified by:
parseStyleDeclaration
in interfaceExtendedParser
- Parameters:
source
- The declaration.- Throws:
org.w3c.css.sac.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(java.lang.String source) throws org.w3c.css.sac.CSSException, java.io.IOException
ImplementsExtendedParser.parseRule(String)
.- Specified by:
parseRule
in interfaceExtendedParser
- Throws:
org.w3c.css.sac.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.
-
parseSelectors
public org.w3c.css.sac.SelectorList parseSelectors(java.lang.String source) throws org.w3c.css.sac.CSSException, java.io.IOException
ImplementsExtendedParser.parseSelectors(String)
.- Specified by:
parseSelectors
in interfaceExtendedParser
- Throws:
org.w3c.css.sac.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 org.w3c.css.sac.LexicalUnit parsePropertyValue(java.lang.String source) throws org.w3c.css.sac.CSSException, java.io.IOException
ImplementsExtendedParser.parsePropertyValue(String)
.- Specified by:
parsePropertyValue
in interfaceExtendedParser
- Throws:
org.w3c.css.sac.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 org.w3c.css.sac.CSSException, java.io.IOException
ImplementsExtendedParser.parsePriority(String)
.- Specified by:
parsePriority
in interfaceExtendedParser
- Throws:
org.w3c.css.sac.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 org.w3c.css.sac.SACMediaList parseMedia(java.lang.String mediaText) throws org.w3c.css.sac.CSSException, java.io.IOException
ImplementsExtendedParser.parseMedia(String)
.- Specified by:
parseMedia
in interfaceExtendedParser
- Throws:
org.w3c.css.sac.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.
-
-