Class CssSelectorParser
java.lang.Object
com.itextpdf.styledxmlparser.css.parse.CssSelectorParser
Utility class for parsing CSS selectors.
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<ICssSelector>parseCommaSeparatedSelectors(String arguments) Parses a comma-separated list of CSS selectors from a string and returns a list ofICssSelectorobjects that represent the selectors.static List<ICssSelectorItem>parseSelectorItems(String selector) Parses the given CSS selector string into a list ofICssSelectorItemobjects.static List<ICssSelectorItem>parseSelectorItems(String selector, boolean allowRelativeSelectorAtStart) Parses the given CSS selector string into a list ofICssSelectorItemobjects, with an option to allow a relative selector at the beginning.splitByTopLevelComma(String input) Splits a string by top-level commas, ignoring commas inside parentheses or quoted strings.
-
Method Details
-
parseCommaSeparatedSelectors
Parses a comma-separated list of CSS selectors from a string and returns a list ofICssSelectorobjects that represent the selectors.- Parameters:
-
arguments- the string containing a comma-separated list of CSS selectors - Returns:
-
a list of
ICssSelectorobjects representing the parsed selectors
-
parseSelectorItems
Parses the given CSS selector string into a list ofICssSelectorItemobjects. This method processes the selector string character by character, handling state transitions and escape sequences to generate a structured representation of the selector components.- Parameters:
-
selector- the CSS selector string to be parsed - Returns:
-
a list of
ICssSelectorItemobjects representing the components of the parsed selector
-
parseSelectorItems
public static List<ICssSelectorItem> parseSelectorItems(String selector, boolean allowRelativeSelectorAtStart) Parses the given CSS selector string into a list ofICssSelectorItemobjects, with an option to allow a relative selector at the beginning. This method processes the selector character by character, handling state transitions and escaped sequences to properly parse the structure.- Parameters:
-
selector- the CSS selector string to be parsed -
allowRelativeSelectorAtStart- a boolean flag indicating whether a relative selector is allowed at the start of the selector string - Returns:
-
a list of
ICssSelectorItemobjects representing the parsed components of the CSS selector
-
splitByTopLevelComma
Splits a string by top-level commas, ignoring commas inside parentheses or quoted strings. This handles escape sequences for quotes correctly.- Parameters:
-
input- the string to split - Returns:
- a list of string parts split by top-level commas
-