java.lang.Object
io.sf.carte.doc.style.css.parser.CSSParser
CSS parser implementing the NSAC API.
Additionally to NSAC, it adds a few methods to parse media queries,
@supports
conditions and the bodies of other rules
(you probably want to use them through the Object Model instead of calling
them directly).
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Small extension to SAC'sDocumentHandler
to deal with declaration rules.Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.nsac.Parser2
Parser2.Flag, Parser2.NamespaceMap
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
parseDeclarationRule
(InputSource source) void
parseFontFeatureValuesBody
(String blockList) void
parseKeyFramesBody
(String blockList) void
parseMediaQuery
(String media, MediaConditionFactory condFactory, MediaQueryHandler mqhandler) Parse a media query.boolean
parsePriority
(InputSource source) parsePropertyValue
(String propertyName, Reader reader) parsePropertyValue
(InputSource source) void
parseRule
(InputSource source) void
parseRule
(InputSource source, Parser2.NamespaceMap nsmap) Parse a CSS rule.parseSelectors
(String seltext) parseSelectors
(InputSource source) void
parseStyleDeclaration
(InputSource source) void
parseStyleSheet
(String uri) void
parseStyleSheet
(InputSource source) parseSupportsCondition
(String conditionText, ExtendedCSSRule rule) Parse the condition text of a@supports
rule.void
setConditionFactory
(ConditionFactory conditionFactory) void
setDocumentHandler
(DocumentHandler handler) void
setErrorHandler
(ErrorHandler handler) void
setFlag
(Parser2.Flag flag) Set a parser flag.void
void
setSelectorFactory
(SelectorFactory selectorFactory) void
setStreamSizeLimit
(int streamSizeLimit) Set a new limit for the stream size that can be processed.void
unsetFlag
(Parser2.Flag flag) Unset a parser flag.
-
Constructor Details
-
CSSParser
public CSSParser()
-
-
Method Details
-
setLocale
- Specified by:
setLocale
in interfaceParser
- Throws:
CSSException
-
setDocumentHandler
- Specified by:
setDocumentHandler
in interfaceParser
-
setSelectorFactory
- Specified by:
setSelectorFactory
in interfaceParser
-
setConditionFactory
- Specified by:
setConditionFactory
in interfaceParser
-
setErrorHandler
- Specified by:
setErrorHandler
in interfaceParser
-
setFlag
Set a parser flag.Currently only
STARHACK
is supported, and it only applies to the parsing of full sheets. -
unsetFlag
Unset a parser flag. -
setStreamSizeLimit
public void setStreamSizeLimit(int streamSizeLimit) Set a new limit for the stream size that can be processed.Calling this method does not affect the parsing that was already ongoing.
- Parameters:
streamSizeLimit
- the new limit to be enforced by new processing by this parser.- Throws:
IllegalArgumentException
- if a limit below 64K was used.
-
parseStyleSheet
- Specified by:
parseStyleSheet
in interfaceParser
- Throws:
CSSException
IOException
-
parseStyleSheet
- Specified by:
parseStyleSheet
in interfaceParser
- Throws:
CSSException
IOException
-
parseStyleDeclaration
- Specified by:
parseStyleDeclaration
in interfaceParser
- Throws:
CSSException
IOException
-
parseDeclarationRule
- Throws:
CSSException
IOException
-
parseRule
- Specified by:
parseRule
in interfaceParser
- Throws:
CSSException
IOException
-
parseRule
public void parseRule(InputSource source, Parser2.NamespaceMap nsmap) throws CSSException, IOException Description copied from interface:Parser2
Parse a CSS rule.- Specified by:
parseRule
in interfaceParser2
- Parameters:
source
- the rule's source.nsmap
- the namespace map.- Throws:
CSSException
- Any CSS exception, possibly wrapping another exception.IOException
- An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
-
parseKeyFramesBody
- Throws:
CSSParseException
-
parseFontFeatureValuesBody
-
parseSupportsCondition
public BooleanCondition parseSupportsCondition(String conditionText, ExtendedCSSRule rule) throws CSSException Parse the condition text of a@supports
rule.- Parameters:
conditionText
- the condition text.rule
- the rule that would process the error. ifnull
, a problem while parsing shall result in an exception. Note thatSAC_NOT_SUPPORTED_ERR
exceptions are always thrown instead of being processed by the rule.- Returns:
- the
@supports
condition, ornull
if a rule was specified to handle the errors, and an error was produced. - Throws:
CSSException
- if there is a syntax problem and there is no error handler, orCSSException.SAC_NOT_SUPPORTED_ERR
if a hard-coded limit in nested expressions was reached.
-
parseMediaQuery
public void parseMediaQuery(String media, MediaConditionFactory condFactory, MediaQueryHandler mqhandler) throws CSSException Parse a media query.- Parameters:
media
- the media query text.condFactory
- the condition factory.mqhandler
- the media query handler.- Throws:
CSSException
-CSSException.SAC_NOT_SUPPORTED_ERR
if a hard-coded limit in nested expressions was reached.
-
getParserVersion
- Specified by:
getParserVersion
in interfaceParser
-
parseSelectors
- Specified by:
parseSelectors
in interfaceParser
- Throws:
CSSException
IOException
-
parseSelectors
- Throws:
CSSException
-
parsePropertyValue
- Specified by:
parsePropertyValue
in interfaceParser
- Throws:
CSSException
IOException
-
parsePropertyValue
public LexicalUnit2 parsePropertyValue(String propertyName, Reader reader) throws CSSException, IOException - Throws:
CSSException
IOException
-
parsePriority
- Specified by:
parsePriority
in interfaceParser
- Throws:
CSSException
IOException
-