Class SelectorUtils


  • public final class SelectorUtils
    extends Object
    Methods to handle selector validation.
    Author:
    nhant01, GeorgeLuo
    • Method Detail

      • isSimpleSelectorSequenceStart

        public static boolean isSimpleSelectorSequenceStart​(@Nonnull
                                                            com.steadystate.css.parser.Token token)
        Whether or not the provided token could be the start of a simple selector sequence. See the simple_selector_sequence production in http://www.w3.org/TR/css3-selectors/#grammar.
        Parameters:
        token - to analyze
        Returns:
        is SimpleSelector Sequence Start
      • isDelim

        public static boolean isDelim​(@Nonnull
                                      com.steadystate.css.parser.Token token,
                                      @Nonnull
                                      String delimChar)
        Helper function for determining whether the provided token is a specific delimiter.
        Parameters:
        token - to analyze
        delimChar - to check
        Returns:
        if this is a delim char
      • combinatorTypeForToken

        public static Combinator.CombinatorType combinatorTypeForToken​(@Nonnull
                                                                       com.steadystate.css.parser.Token token)
                                                                throws CssValidationException
        The CombinatorType for a given token; helper function used when constructing a Combinator instance.
        Parameters:
        token - the token
        Returns:
        the combinator type
        Throws:
        CssValidationException - the CssValidationException
      • parseATypeSelector

        public static TypeSelector parseATypeSelector​(@Nonnull
                                                      TokenStream tokenStream)
        tokenStream.current() is the first token of the type selector.
        Parameters:
        tokenStream - token stream
        Returns:
        the type selector
      • extractAFunction

        public static List<com.steadystate.css.parser.Token> extractAFunction​(@Nonnull
                                                                              TokenStream tokenStream,
                                                                              @Nonnull
                                                                              List<ErrorToken> errors)
                                                                       throws CssValidationException
        Returns a function's contents in tokenList, including the leading FunctionToken, but excluding the trailing CloseParen token and appended with an EOFToken instead.
        Parameters:
        tokenStream - token stream
        errors - array of error tokens
        Returns:
        the list of token
        Throws:
        CssValidationException - the CssValidationException