Class CssSelectorParser

java.lang.Object
com.itextpdf.styledxmlparser.css.parse.CssSelectorParser

public final class CssSelectorParser extends Object
Utilities class to parse a CSS selector.
  • Field Details

    • LEGACY_PSEUDO_ELEMENTS

      private static final Set<String> LEGACY_PSEUDO_ELEMENTS
      Set of legacy pseudo elements (first-line, first-letter, before, after).
    • SELECTOR_PATTERN_STR

      private static final String SELECTOR_PATTERN_STR
      The pattern string for selectors.
      See Also:
    • selectorPattern

      private static final Pattern selectorPattern
      The pattern for selectors.
  • Constructor Details

    • CssSelectorParser

      private CssSelectorParser()
      Creates a new CssSelectorParser instance.
  • Method Details

    • parseSelectorItems

      public static List<ICssSelectorItem> parseSelectorItems(String selector)
      Parses the selector items.
      Parameters:
      selector - the selectors in the form of a String
      Returns:
      the resulting list of ICssSelectorItem
    • appendPseudoSelector

      private static void appendPseudoSelector(List<ICssSelectorItem> selectorItems, String pseudoSelector, Matcher match, String source)
      Resolves a pseudo selector and appends it to list.
      Parameters:
      selectorItems - list of items to which new selector will be added to
      pseudoSelector - the pseudo selector
      match - the corresponding Matcher.
      source - is the original source
    • handleBracketsOfPseudoSelector

      private static String handleBracketsOfPseudoSelector(String pseudoSelector, Matcher match, String source)
      Resolves a pseudo selector if it contains brackets. Updates internal state of Matcher if necessary.
      Parameters:
      pseudoSelector - the pseudo selector
      match - the corresponding Matcher.
      source - is the original source