Class 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.SACParserCSS3
    A utility to parse css text into a list of tokens.
    Author:
    nhant01, GeorgeLuo
    • Field Summary

      • Fields inherited from class com.steadystate.css.parser.SACParserCSS3

        jj_nt, token, token_source
      • Fields inherited from interface com.steadystate.css.parser.SACParserCSS3Constants

        A_LETTER, AND, ANGLE_DEG, ANGLE_GRAD, ANGLE_RAD, ASTERISK, ATKEYWORD, C_LETTER, CDC, CDO, CH, CHARSET_SYM, COLON, COMMA, COMMENT, COMMENT_, CUSTOM_PROPERTY_NAME, D_LETTER, DASHMATCH, DEFAULT, DIMENSION, DOT, E_LETTER, EMS, EOF, EQUALS, ESCAPE, EXS, F_LETTER, FONT_FACE_SYM, FREQ_HZ, FREQ_KHZ, FUNCTION, FUNCTION_CALC, FUNCTION_LANG, FUNCTION_NOT, FUNCTION_VAR, 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, REM, 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, VH, VMAX, VMIN, VW, W, X_LETTER, Z_LETTER
    • Constructor Summary

      Constructors 
      Constructor Description
      CssParser​(String cssText, int line, int col, List<ErrorToken> errors)
      Constructor.
    • 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 exception
        ex - 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:
        setDocumentHandler in interface org.w3c.css.sac.Parser
      • getErrorHandler

        protected org.w3c.css.sac.ErrorHandler getErrorHandler()
      • setErrorHandler

        public void setErrorHandler​(org.w3c.css.sac.ErrorHandler arg0)
        Specified by:
        setErrorHandler in interface org.w3c.css.sac.Parser
      • getInputSource

        protected org.w3c.css.sac.InputSource getInputSource()
      • setIeStarHackAccepted

        public void setIeStarHackAccepted​(boolean arg0)
        Specified by:
        setIeStarHackAccepted in interface com.steadystate.css.parser.SACParser
      • isIeStarHackAccepted

        public boolean isIeStarHackAccepted()
        Specified by:
        isIeStarHackAccepted in interface com.steadystate.css.parser.SACParser
      • setLocale

        public void setLocale​(Locale arg0)
        Specified by:
        setLocale in interface org.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:
        setSelectorFactory in interface org.w3c.css.sac.Parser
      • getConditionFactory

        protected com.steadystate.css.sac.ConditionFactoryExt getConditionFactory()
      • setConditionFactory

        public void setConditionFactory​(org.w3c.css.sac.ConditionFactory arg0)
        Specified by:
        setConditionFactory in interface org.w3c.css.sac.Parser
      • getSACParserMessages

        protected ResourceBundle getSACParserMessages()
      • createLocator

        protected org.w3c.css.sac.Locator createLocator​(com.steadystate.css.parser.Token arg0)
      • add_escapes

        protected String add_escapes​(String 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:
        parseStyleSheet in interface org.w3c.css.sac.Parser
        Throws:
        IOException
      • parseStyleSheet

        public void parseStyleSheet​(String arg0)
                             throws IOException
        Specified by:
        parseStyleSheet in interface org.w3c.css.sac.Parser
        Throws:
        IOException
      • parseStyleDeclaration

        public void parseStyleDeclaration​(org.w3c.css.sac.InputSource arg0)
                                   throws IOException
        Specified by:
        parseStyleDeclaration in interface org.w3c.css.sac.Parser
        Throws:
        IOException
      • parseRule

        public void parseRule​(org.w3c.css.sac.InputSource arg0)
                       throws IOException
        Specified by:
        parseRule in interface org.w3c.css.sac.Parser
        Throws:
        IOException
      • parseSelectors

        public org.w3c.css.sac.SelectorList parseSelectors​(org.w3c.css.sac.InputSource arg0)
                                                    throws IOException
        Specified by:
        parseSelectors in interface org.w3c.css.sac.Parser
        Throws:
        IOException
      • parsePropertyValue

        public org.w3c.css.sac.LexicalUnit parsePropertyValue​(org.w3c.css.sac.InputSource arg0)
                                                       throws IOException
        Specified by:
        parsePropertyValue in interface org.w3c.css.sac.Parser
        Throws:
        IOException
      • parsePriority

        public boolean parsePriority​(org.w3c.css.sac.InputSource arg0)
                              throws IOException
        Specified by:
        parsePriority in interface org.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)
      • handleEndPage

        protected void handleEndPage​(String arg0,
                                     String arg1)
      • 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)
      • unescape

        public String unescape​(String arg0,
                               boolean arg1)