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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSmall extension to SAC'sDocumentHandlerto deal with declaration rules.Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.nsac.Parser2
Parser2.Flag, Parser2.NamespaceMap -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidparseDeclarationRule(InputSource source) voidparseFontFeatureValuesBody(String blockList) voidparseKeyFramesBody(String blockList) voidparseMediaQuery(String media, MediaConditionFactory condFactory, MediaQueryHandler mqhandler) Parse a media query.booleanparsePriority(InputSource source) parsePropertyValue(String propertyName, Reader reader) parsePropertyValue(InputSource source) voidparseRule(InputSource source) voidparseRule(InputSource source, Parser2.NamespaceMap nsmap) Parse a CSS rule.parseSelectors(String seltext) parseSelectors(InputSource source) voidparseStyleDeclaration(InputSource source) voidparseStyleSheet(String uri) voidparseStyleSheet(InputSource source) parseSupportsCondition(String conditionText, ExtendedCSSRule rule) Parse the condition text of a@supportsrule.voidsetConditionFactory(ConditionFactory conditionFactory) voidsetDocumentHandler(DocumentHandler handler) voidsetErrorHandler(ErrorHandler handler) voidsetFlag(Parser2.Flag flag) Set a parser flag.voidvoidsetSelectorFactory(SelectorFactory selectorFactory) voidsetStreamSizeLimit(int streamSizeLimit) Set a new limit for the stream size that can be processed.voidunsetFlag(Parser2.Flag flag) Unset a parser flag.
-
Constructor Details
-
CSSParser
public CSSParser()
-
-
Method Details
-
setLocale
- Specified by:
setLocalein interfaceParser- Throws:
CSSException
-
setDocumentHandler
- Specified by:
setDocumentHandlerin interfaceParser
-
setSelectorFactory
- Specified by:
setSelectorFactoryin interfaceParser
-
setConditionFactory
- Specified by:
setConditionFactoryin interfaceParser
-
setErrorHandler
- Specified by:
setErrorHandlerin interfaceParser
-
setFlag
Set a parser flag.Currently only
STARHACKis 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:
parseStyleSheetin interfaceParser- Throws:
CSSExceptionIOException
-
parseStyleSheet
- Specified by:
parseStyleSheetin interfaceParser- Throws:
CSSExceptionIOException
-
parseStyleDeclaration
- Specified by:
parseStyleDeclarationin interfaceParser- Throws:
CSSExceptionIOException
-
parseDeclarationRule
- Throws:
CSSExceptionIOException
-
parseRule
- Specified by:
parseRulein interfaceParser- Throws:
CSSExceptionIOException
-
parseRule
public void parseRule(InputSource source, Parser2.NamespaceMap nsmap) throws CSSException, IOException Description copied from interface:Parser2Parse a CSS rule.- Specified by:
parseRulein 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@supportsrule.- 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_ERRexceptions are always thrown instead of being processed by the rule.- Returns:
- the
@supportscondition, ornullif 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_ERRif 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_ERRif a hard-coded limit in nested expressions was reached.
-
getParserVersion
- Specified by:
getParserVersionin interfaceParser
-
parseSelectors
- Specified by:
parseSelectorsin interfaceParser- Throws:
CSSExceptionIOException
-
parseSelectors
- Throws:
CSSException
-
parsePropertyValue
- Specified by:
parsePropertyValuein interfaceParser- Throws:
CSSExceptionIOException
-
parsePropertyValue
public LexicalUnit2 parsePropertyValue(String propertyName, Reader reader) throws CSSException, IOException - Throws:
CSSExceptionIOException
-
parsePriority
- Specified by:
parsePriorityin interfaceParser- Throws:
CSSExceptionIOException
-