Class CssVariableUtil
java.lang.Object
com.itextpdf.styledxmlparser.util.CssVariableUtil
Utility class for resolving css variables in declarations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate static final intMax count of css var expressions in single declaration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsVarExpression(String expression) Checks for var expression.private static List<CssDeclaration> expandShorthand(CssDeclaration declaration) static booleanisCssVariable(String property) Checks property for css variable.static voidresolveCssVariables(Map<String, String> styles) Resolve all css variables in style mapprivate static CssDeclarationResolve single css var expression recursivelyprivate static StringresolveVarExpression(String varExpression, Map<String, String> styles) Resolve css variable expression, if there is a fallback value and primary value is null, default value will be returned.private static StringresolveVarRecursively(String expression, Map<String, String> styles, int level) Resolves variables without taking into account default values
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
MAX_CSS_VAR_COUNT
private static final int MAX_CSS_VAR_COUNTMax count of css var expressions in single declaration.- See Also:
-
-
Constructor Details
-
CssVariableUtil
private CssVariableUtil()
-
-
Method Details
-
resolveCssVariables
-
containsVarExpression
Checks for var expression.- Parameters:
expression- css expression to check- Returns:
- true if there is a var expression, false otherwise
-
isCssVariable
Checks property for css variable.- Parameters:
property- css property to check- Returns:
- true if it is a css variable, false otherwise
-
expandShorthand
-
resolveSingleVar
private static CssDeclaration resolveSingleVar(String key, String expression, Map<String, String> styles) Resolve single css var expression recursively- Parameters:
key- css style propertyexpression- css expressionstyles- css styles map- Returns:
- resolved var expression if present or null if none found
-
resolveVarRecursively
-
resolveVarExpression
Resolve css variable expression, if there is a fallback value and primary value is null, default value will be returned.- Parameters:
varExpression- expression as the following: var(.+?(?:,.*?)?)styles- map of styles containing resolved variables- Returns:
- resolved var expression
-