Class CSSParser
- Direct Known Subclasses:
 CSSOMParser
Additionally to NSAC, it includes several other methods.
 By default, the methods that take a Reader or an InputSource
 as argument can process streams up to 0x6000000 (100MB) in size, and
 throw a SecurityException if they hit that limit. See also
 setStreamSizeLimit(int).
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSmall extension toCSSHandlerto deal with declaration rules.Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.nsac.Parser
Parser.Flag, Parser.NamespaceMap - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionclone()protected MediaQueryFactoryvoidparseDeclarationRule(Reader reader) voidparseFontFeatureValuesBody(String blockList) voidparseKeyFramesBody(String blockList) voidparseMediaQueryList(String media, MediaQueryFactory queryFactory, MediaQueryHandler mqhandler) Parse a media query string into the given handler.parseMediaQueryList(String media, Node owner) Parse a media query string.voidparsePageRuleBody(String blockList) parsePageSelectorList(String pageSelectorStr) booleanparsePriority(Reader reader) Parse a CSS priority value (e.g. "!parsePropertyValue(InputSource source) parsePropertyValue(Reader reader) Parse a CSS property value.parsePropertyValue(String propertyName, Reader reader) parsePseudoElement(String pseudoElement) voidparseRule(InputSource source) voidParse a namespaceless CSS rule.voidparseRule(Reader reader, Parser.NamespaceMap nsmap) Parse a CSS rule.parseSelectors(InputSource source) parseSelectors(Reader reader) Parse a comma separated list of selectors.parseSelectors(String seltext) parseSelectors(String selectorText, Parser.NamespaceMap nsmap) Parse a comma separated list of selectors.voidparseStyleDeclaration(InputSource source) voidparseStyleDeclaration(Reader reader) Parse a CSS style declaration (without '{' and '}').voidparseStyleSheet(InputSource source) Parse a CSS style sheet.voidparseStyleSheet(Reader reader) Parse a CSS style sheet.voidparseStyleSheet(String uri) Parse a CSS sheet from a URI.parseSupportsCondition(String conditionText, CSSRule rule) Parse the condition text of a@supportsrule.voidsetDocumentHandler(CSSHandler handler) Allow an application to set a document event handler.voidsetErrorHandler(CSSErrorHandler handler) Allow an application to set an error event handler.voidsetFlag(Parser.Flag flag) Set a parser flag.voidsetStreamSizeLimit(int streamSizeLimit) Set a new limit for the stream size that can be processed.voidunsetFlag(Parser.Flag flag) Unset a parser flag. 
- 
Constructor Details
- 
CSSParser
public CSSParser()Instantiate a parser instance with no flags. - 
CSSParser
 
 - 
 - 
Method Details
- 
setDocumentHandler
Description copied from interface:ParserAllow an application to set a document event handler.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:
 setDocumentHandlerin interfaceParser- Parameters:
 handler- The document handler.- See Also:
 
 - 
setErrorHandler
Description copied from interface:ParserAllow an application to set an error event handler.If the application does not register an error event handler, any error will result in a CSSParseException being thrown.
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:
 setErrorHandlerin interfaceParser- Parameters:
 handler- The error handler.- See Also:
 
 - 
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
public void parseStyleSheet(Reader reader) throws CSSParseException, IOException, IllegalStateException Description copied from interface:ParserParse a CSS style sheet.- Specified by:
 parseStyleSheetin interfaceParser- Parameters:
 reader- the character stream containing the CSS sheet.- Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- if a I/O error was found while retrieving the sheet.IllegalStateException- if theCSSHandleris not set.- See Also:
 
 - 
parseStyleSheet
public void parseStyleSheet(String uri) throws CSSParseException, IOException, IllegalStateException Parse a CSS sheet from a URI.The sheet is parsed as a rule list, that is, XML's
CDO-CDCcomments are not expected.The timeout to establish a connection is of 30 seconds.
Usage of this method may have security implications. Please make sure that the URI being passed is safe to use.
- Specified by:
 parseStyleSheetin interfaceParser- Parameters:
 uri- The URI locating the sheet.- Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- ifuriis an invalid URL or a I/O error was found while retrieving the sheet.IllegalStateException- if theCSSHandleris not set.- See Also:
 
 - 
parseStyleSheet
public void parseStyleSheet(InputSource source) throws CSSParseException, IOException, IllegalStateException, IllegalArgumentException Description copied from interface:ParserParse a CSS style sheet.- Specified by:
 parseStyleSheetin interfaceParser- Parameters:
 source- the input source of the CSS sheet.- Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- if a I/O error was found while retrieving the sheet.IllegalStateException- if theCSSHandleris not set.IllegalArgumentException- if no stream could be obtained from thesource.- See Also:
 
 - 
parseStyleDeclaration
public void parseStyleDeclaration(Reader reader) throws CSSParseException, IOException, IllegalStateException Description copied from interface:ParserParse a CSS style declaration (without '{' and '}').- Specified by:
 parseStyleDeclarationin interfaceParser- Parameters:
 reader- the character stream containing the CSS style declaration.- Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- if a I/O error was found while retrieving the declaration.IllegalStateException- if theCSSHandleris not set.
 - 
parseStyleDeclaration
public void parseStyleDeclaration(InputSource source) throws CSSException, IOException, IllegalStateException  - 
parseDeclarationRule
- Throws:
 CSSParseExceptionIOException
 - 
parsePageSelectorList
- Throws:
 DOMException
 - 
parseRule
Description copied from interface:ParserParse a namespaceless CSS rule.- Specified by:
 parseRulein interfaceParser- Parameters:
 reader- the character stream containing the CSS rule.- Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- if a I/O error was found while retrieving the rule.IllegalStateException- if theCSSHandleris not set.
 - 
parseRule
public void parseRule(Reader reader, Parser.NamespaceMap nsmap) throws CSSParseException, IOException, IllegalStateException Description copied from interface:ParserParse a CSS rule.- Specified by:
 parseRulein interfaceParser- Parameters:
 reader- the character stream containing the CSS rule.nsmap- the namespace map.- Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- if a I/O error was found while retrieving the rule.IllegalStateException- if theCSSHandleris not set.
 - 
parseRule
- Throws:
 CSSParseExceptionIOException
 - 
parsePageRuleBody
- Throws:
 CSSParseException
 - 
parseKeyFramesBody
- Throws:
 CSSParseException
 - 
parseFontFeatureValuesBody
- Throws:
 CSSParseException
 - 
parseSupportsCondition
public BooleanCondition parseSupportsCondition(String conditionText, CSSRule rule) throws CSSParseException, CSSBudgetException 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 thatNOT_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:
 CSSParseException- if there is a syntax problem and there is no error handler.CSSBudgetException- if a hard-coded limit in nested expressions was reached.
 - 
parseMediaQueryList
public void parseMediaQueryList(String media, MediaQueryFactory queryFactory, MediaQueryHandler mqhandler) throws CSSBudgetException Parse a media query string into the given handler.- Specified by:
 parseMediaQueryListin interfaceParser- Parameters:
 media- the media query text.queryFactory- the query factory.mqhandler- the media query list handler.- Throws:
 CSSBudgetException- if a hard-coded limit in nested expressions was reached.
 - 
parseMediaQueryList
Parse a media query string.- Specified by:
 parseMediaQueryListin interfaceParser- Parameters:
 media- the media query text.owner- the node that owns the responsibility to handle the errors in the query list.- Returns:
 - the media query list.
 - Throws:
 CSSBudgetException- if a hard-coded limit in nested expressions was reached.
 - 
getMediaQueryFactory
 - 
parseSelectors
public SelectorList parseSelectors(Reader reader) throws CSSParseException, CSSBudgetException, IOException Description copied from interface:ParserParse a comma separated list of selectors.- Specified by:
 parseSelectorsin interfaceParser- Parameters:
 reader- the character stream containing the selector list.- Returns:
 - the selector list.
 - Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- if a I/O error was found while retrieving the list.CSSBudgetException
 - 
parseSelectors
public SelectorList parseSelectors(String selectorText, Parser.NamespaceMap nsmap) throws CSSParseException Description copied from interface:ParserParse a comma separated list of selectors.- Specified by:
 parseSelectorsin interfaceParser- Parameters:
 selectorText- theStringcontaining the selector list.nsmap- the namespace map to apply to the selector list, if it contains namespace prefixes.- Returns:
 - the selector list.
 - Throws:
 CSSParseException- if an error was found and no error handler was set.
 - 
parseSelectors
- Throws:
 CSSParseExceptionIOException
 - 
parseSelectors
- Throws:
 CSSException
 - 
parsePseudoElement
- Throws:
 CSSException
 - 
parsePropertyValue
Description copied from interface:ParserParse a CSS property value.- Specified by:
 parsePropertyValuein interfaceParser- Parameters:
 reader- the character stream containing the CSS property value.- Returns:
 - the lexical unit containing the value, possibly chained to subsequent lexical units.
 - Throws:
 CSSParseException- if an error was found and no error handler was set.IOException- if a I/O error was found while retrieving the value.
 - 
parsePropertyValue
public LexicalUnit parsePropertyValue(String propertyName, Reader reader) throws CSSParseException, IOException - Throws:
 CSSParseExceptionIOException
 - 
parsePropertyValue
- Throws:
 CSSParseExceptionIOException
 - 
parsePriority
Description copied from interface:ParserParse a CSS priority value (e.g. "!important").- Specified by:
 parsePriorityin interfaceParser- Parameters:
 reader- the character stream containing the CSS priority.- Returns:
 trueif the priority is important.- Throws:
 IOException- if a I/O error was found while retrieving the priority.
 - 
clone
 
 -