Package dev.amp.validator.css
Class CssParser
- java.lang.Object
-
- com.steadystate.css.parser.SACParserCSS3
-
- dev.amp.validator.css.CssParser
-
- All Implemented Interfaces:
com.steadystate.css.parser.SACParser,com.steadystate.css.parser.SACParserCSS3Constants,org.w3c.css.sac.Parser
public final class CssParser extends com.steadystate.css.parser.SACParserCSS3A utility to parse css text into a list of tokens.- Author:
- nhant01, GeorgeLuo
-
-
Field Summary
-
Fields inherited from interface com.steadystate.css.parser.SACParserCSS3Constants
A_LETTER, AND, ANGLE_DEG, ANGLE_GRAD, ANGLE_RAD, ASTERISK, ATKEYWORD, C_LETTER, CDC, CDO, CHARSET_SYM, COLON, COMMA, COMMENT, COMMENT_, D_LETTER, DASHMATCH, DEFAULT, DIMENSION, DOT, E_LETTER, EMS, EOF, EQUALS, ESCAPE, EXS, F_LETTER, FONT_FACE_SYM, FREQ_HZ, FREQ_KHZ, FUNCTION, FUNCTION_LANG, FUNCTION_NOT, G_LETTER, GREATER, H, H_LETTER, H_PLACEHOLDER, HASH, HNUM, I_LETTER, IDENT, IMPORT_SYM, IMPORTANT_SYM, INCLUDES, INHERIT, K_LETTER, L_LETTER, LBRACE, LENGTH_CM, LENGTH_IN, LENGTH_MM, LENGTH_PC, LENGTH_PT, LENGTH_PX, LROUND, LSQUARE, M_LETTER, MEDIA_SYM, MINUS, N_LETTER, NAME, NL, NMCHAR, NMSTART, NONASCII, NOT, NUM, NUMBER, O_LETTER, ONLY, P_LETTER, PAGE_SYM, PERCENTAGE, PLUS, PREFIXMATCH, R_LETTER, RBRACE, RESOLUTION_DPCM, RESOLUTION_DPI, RROUND, RSQUARE, S, S_LETTER, SEMICOLON, SLASH, STRING, STRING1, STRING2, SUBSTRINGMATCH, SUFFIXMATCH, T_LETTER, TILDE, TIME_MS, TIME_S, tokenImage, U_LETTER, UNICODE, UNICODE_RANGE, UNKNOWN, URI, URL, V_LETTER, W, X_LETTER, Z_LETTER
-
-
Constructor Summary
Constructors Constructor Description CssParser(String cssText, int line, int col, List<ErrorToken> errors)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Stringadd_escapes(String arg0)protected org.w3c.css.sac.LocatorcreateLocator(com.steadystate.css.parser.Token arg0)protected org.w3c.css.sac.CSSParseExceptioncreateSkipWarning(String arg0, org.w3c.css.sac.CSSParseException arg1)protected org.w3c.css.sac.LexicalUnitfunctionInternal(org.w3c.css.sac.LexicalUnit arg0, String arg1, org.w3c.css.sac.LexicalUnit arg2)protected com.steadystate.css.sac.ConditionFactoryExtgetConditionFactory()protected com.steadystate.css.sac.DocumentHandlerExtgetDocumentHandler()protected org.w3c.css.sac.ErrorHandlergetErrorHandler()List<ErrorToken>getErrors()Returns the token errors.protected org.w3c.css.sac.InputSourcegetInputSource()protected LocalegetLocale()protected ResourceBundlegetSACParserMessages()protected com.steadystate.css.sac.SelectorFactoryExtgetSelectorFactory()protected voidhandleCharset(String arg0, org.w3c.css.sac.Locator arg1)protected voidhandleEndDocument()protected voidhandleEndFontFace()protected voidhandleEndMedia(org.w3c.css.sac.SACMediaList arg0)protected voidhandleEndPage(String arg0, String arg1)protected voidhandleEndSelector(org.w3c.css.sac.SelectorList arg0)protected voidhandleIgnorableAtRule(String arg0, org.w3c.css.sac.Locator arg1)protected voidhandleImportStyle(String arg0, org.w3c.css.sac.SACMediaList arg1, String arg2, org.w3c.css.sac.Locator arg3)protected voidhandleMedium(String arg0, org.w3c.css.sac.Locator arg1)protected voidhandleProperty(String arg0, org.w3c.css.sac.LexicalUnit arg1, boolean arg2, org.w3c.css.sac.Locator arg3)protected voidhandleSelector(org.w3c.css.sac.Selector arg0)protected voidhandleStartDocument()protected voidhandleStartFontFace(org.w3c.css.sac.Locator arg0)protected voidhandleStartMedia(org.w3c.css.sac.SACMediaList arg0, org.w3c.css.sac.Locator arg1)protected voidhandleStartPage(String arg0, String arg1, org.w3c.css.sac.Locator arg2)protected voidhandleStartSelector(org.w3c.css.sac.SelectorList arg0, org.w3c.css.sac.Locator arg1)protected org.w3c.css.sac.LexicalUnithexcolorInternal(org.w3c.css.sac.LexicalUnit arg0, com.steadystate.css.parser.Token arg1)booleanisIeStarHackAccepted()org.w3c.css.sac.SACMediaListparseMedia(org.w3c.css.sac.InputSource arg0)booleanparsePriority(org.w3c.css.sac.InputSource arg0)org.w3c.css.sac.LexicalUnitparsePropertyValue(org.w3c.css.sac.InputSource arg0)voidparseRule(org.w3c.css.sac.InputSource arg0)org.w3c.css.sac.SelectorListparseSelectors(org.w3c.css.sac.InputSource arg0)voidparseStyleDeclaration(org.w3c.css.sac.InputSource arg0)voidparseStyleSheet(String arg0)voidparseStyleSheet(org.w3c.css.sac.InputSource arg0)voidsetConditionFactory(org.w3c.css.sac.ConditionFactory arg0)voidsetDocumentHandler(org.w3c.css.sac.DocumentHandler arg0)voidsetErrorHandler(org.w3c.css.sac.ErrorHandler arg0)voidsetIeStarHackAccepted(boolean arg0)voidsetLocale(Locale arg0)voidsetSelectorFactory(org.w3c.css.sac.SelectorFactory arg0)protected org.w3c.css.sac.CSSParseExceptiontoCSSParseException(com.steadystate.css.parser.TokenMgrError ex)protected org.w3c.css.sac.CSSParseExceptiontoCSSParseException(String key, com.steadystate.css.parser.ParseException ex)Override to handle specific validation errors encountered during tokenization.protected org.w3c.css.sac.CSSParseExceptiontoCSSParseException(String arg0, Object[] arg1, org.w3c.css.sac.Locator arg2)protected org.w3c.css.sac.CSSParseExceptiontoCSSParseException(DOMException arg0)List<com.steadystate.css.parser.Token>tokenize()Generates a list of cssparser Tokens extracted from cssText.Stringunescape(String arg0, boolean arg1)-
Methods inherited from class com.steadystate.css.parser.SACParserCSS3
_class, attrib, charsetRule, combinator, declaration, disable_tracing, elementName, enable_tracing, expr, fontFaceRule, function, generateParseException, getGrammarUri, getNextToken, getParserVersion, getToken, hash, hexcolor, importRule, mediaExpression, mediaList, mediaQuery, mediaRule, mediaRuleList, medium, negation_arg, operator, pageRule, pageSelector, pageSelectorList, parseSelectorsInternal, prio, property, pseudo, pseudoPage, ReInit, ReInit, selector, selectorList, simpleSelector, styleDeclaration, styleRule, styleSheet, styleSheetRuleList, styleSheetRuleSingle, term, trace_enabled, unaryOperator, unicodeRange, unknownAtRule
-
-
-
-
Constructor Detail
-
CssParser
public CssParser(@Nonnull String cssText, int line, int col, @Nonnull List<ErrorToken> errors)Constructor.- Parameters:
cssText- the stylesheet data.line- line number.col- column number.errors- the global error token list for css validation errors.
-
-
Method Detail
-
toCSSParseException
protected org.w3c.css.sac.CSSParseException toCSSParseException(String key, @Nonnull com.steadystate.css.parser.ParseException ex)
Override to handle specific validation errors encountered during tokenization.- Parameters:
key- the type of the exceptionex- the exception to handle- Returns:
- a populated CSSParseException
-
toCSSParseException
protected org.w3c.css.sac.CSSParseException toCSSParseException(com.steadystate.css.parser.TokenMgrError ex)
-
tokenize
public List<com.steadystate.css.parser.Token> tokenize() throws IOException
Generates a list of cssparser Tokens extracted from cssText.- Returns:
- a list of Tokens found.
- Throws:
IOException- IO exception.
-
getErrors
public List<ErrorToken> getErrors()
Returns the token errors.- Returns:
- returns the token errors.
-
getDocumentHandler
protected com.steadystate.css.sac.DocumentHandlerExt getDocumentHandler()
-
setDocumentHandler
public void setDocumentHandler(org.w3c.css.sac.DocumentHandler arg0)
- Specified by:
setDocumentHandlerin interfaceorg.w3c.css.sac.Parser
-
getErrorHandler
protected org.w3c.css.sac.ErrorHandler getErrorHandler()
-
setErrorHandler
public void setErrorHandler(org.w3c.css.sac.ErrorHandler arg0)
- Specified by:
setErrorHandlerin interfaceorg.w3c.css.sac.Parser
-
getInputSource
protected org.w3c.css.sac.InputSource getInputSource()
-
setIeStarHackAccepted
public void setIeStarHackAccepted(boolean arg0)
- Specified by:
setIeStarHackAcceptedin interfacecom.steadystate.css.parser.SACParser
-
isIeStarHackAccepted
public boolean isIeStarHackAccepted()
- Specified by:
isIeStarHackAcceptedin interfacecom.steadystate.css.parser.SACParser
-
setLocale
public void setLocale(Locale arg0)
- Specified by:
setLocalein interfaceorg.w3c.css.sac.Parser
-
getLocale
protected Locale getLocale()
-
getSelectorFactory
protected com.steadystate.css.sac.SelectorFactoryExt getSelectorFactory()
-
setSelectorFactory
public void setSelectorFactory(org.w3c.css.sac.SelectorFactory arg0)
- Specified by:
setSelectorFactoryin interfaceorg.w3c.css.sac.Parser
-
getConditionFactory
protected com.steadystate.css.sac.ConditionFactoryExt getConditionFactory()
-
setConditionFactory
public void setConditionFactory(org.w3c.css.sac.ConditionFactory arg0)
- Specified by:
setConditionFactoryin interfaceorg.w3c.css.sac.Parser
-
getSACParserMessages
protected ResourceBundle getSACParserMessages()
-
createLocator
protected org.w3c.css.sac.Locator createLocator(com.steadystate.css.parser.Token arg0)
-
toCSSParseException
protected org.w3c.css.sac.CSSParseException toCSSParseException(DOMException arg0)
-
toCSSParseException
protected org.w3c.css.sac.CSSParseException toCSSParseException(String arg0, Object[] arg1, org.w3c.css.sac.Locator arg2)
-
createSkipWarning
protected org.w3c.css.sac.CSSParseException createSkipWarning(String arg0, org.w3c.css.sac.CSSParseException arg1)
-
parseStyleSheet
public void parseStyleSheet(org.w3c.css.sac.InputSource arg0) throws IOException- Specified by:
parseStyleSheetin interfaceorg.w3c.css.sac.Parser- Throws:
IOException
-
parseStyleSheet
public void parseStyleSheet(String arg0) throws IOException
- Specified by:
parseStyleSheetin interfaceorg.w3c.css.sac.Parser- Throws:
IOException
-
parseStyleDeclaration
public void parseStyleDeclaration(org.w3c.css.sac.InputSource arg0) throws IOException- Specified by:
parseStyleDeclarationin interfaceorg.w3c.css.sac.Parser- Throws:
IOException
-
parseRule
public void parseRule(org.w3c.css.sac.InputSource arg0) throws IOException- Specified by:
parseRulein interfaceorg.w3c.css.sac.Parser- Throws:
IOException
-
parseSelectors
public org.w3c.css.sac.SelectorList parseSelectors(org.w3c.css.sac.InputSource arg0) throws IOException- Specified by:
parseSelectorsin interfaceorg.w3c.css.sac.Parser- Throws:
IOException
-
parsePropertyValue
public org.w3c.css.sac.LexicalUnit parsePropertyValue(org.w3c.css.sac.InputSource arg0) throws IOException- Specified by:
parsePropertyValuein interfaceorg.w3c.css.sac.Parser- Throws:
IOException
-
parsePriority
public boolean parsePriority(org.w3c.css.sac.InputSource arg0) throws IOException- Specified by:
parsePriorityin interfaceorg.w3c.css.sac.Parser- Throws:
IOException
-
parseMedia
public org.w3c.css.sac.SACMediaList parseMedia(org.w3c.css.sac.InputSource arg0) throws IOException- Throws:
IOException
-
handleStartDocument
protected void handleStartDocument()
-
handleEndDocument
protected void handleEndDocument()
-
handleIgnorableAtRule
protected void handleIgnorableAtRule(String arg0, org.w3c.css.sac.Locator arg1)
-
handleCharset
protected void handleCharset(String arg0, org.w3c.css.sac.Locator arg1)
-
handleImportStyle
protected void handleImportStyle(String arg0, org.w3c.css.sac.SACMediaList arg1, String arg2, org.w3c.css.sac.Locator arg3)
-
handleStartMedia
protected void handleStartMedia(org.w3c.css.sac.SACMediaList arg0, org.w3c.css.sac.Locator arg1)
-
handleMedium
protected void handleMedium(String arg0, org.w3c.css.sac.Locator arg1)
-
handleEndMedia
protected void handleEndMedia(org.w3c.css.sac.SACMediaList arg0)
-
handleStartPage
protected void handleStartPage(String arg0, String arg1, org.w3c.css.sac.Locator arg2)
-
handleStartFontFace
protected void handleStartFontFace(org.w3c.css.sac.Locator arg0)
-
handleEndFontFace
protected void handleEndFontFace()
-
handleSelector
protected void handleSelector(org.w3c.css.sac.Selector arg0)
-
handleStartSelector
protected void handleStartSelector(org.w3c.css.sac.SelectorList arg0, org.w3c.css.sac.Locator arg1)
-
handleEndSelector
protected void handleEndSelector(org.w3c.css.sac.SelectorList arg0)
-
handleProperty
protected void handleProperty(String arg0, org.w3c.css.sac.LexicalUnit arg1, boolean arg2, org.w3c.css.sac.Locator arg3)
-
functionInternal
protected org.w3c.css.sac.LexicalUnit functionInternal(org.w3c.css.sac.LexicalUnit arg0, String arg1, org.w3c.css.sac.LexicalUnit arg2)
-
hexcolorInternal
protected org.w3c.css.sac.LexicalUnit hexcolorInternal(org.w3c.css.sac.LexicalUnit arg0, com.steadystate.css.parser.Token arg1)
-
-