Package com.helger.css.parser
Class CSSParseHelper
java.lang.Object
com.helger.css.parser.CSSParseHelper
This class is used by the generated parsers to do some common stuff.
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charThe character used to quote elements in CSS URLs -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractStringValue(String sStr) Remove surrounding quotes (single or double) of a string (if present).static StringsplitNumber(StringBuilder aPattern) static StringRemove the leading "url(" and the trailing ")" from an URL CSS value.static StringunescapeOther(StringBuilder aImage) Unescape e.g.static StringunescapeUnicode(StringBuilder aImage) Unescape e.g.static StringunescapeURL(String sEscapedURL) Unescape all escaped characters in a CSS URL.static StringvalidateIdentifier(StringBuilder aPattern) In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit.
-
Field Details
-
URL_ESCAPE_CHAR
public static final char URL_ESCAPE_CHARThe character used to quote elements in CSS URLs- See Also:
-
-
Method Details
-
extractStringValue
Remove surrounding quotes (single or double) of a string (if present). If the start and the end quote are not equal, nothing happens.- Parameters:
sStr- The string where the quotes should be removed- Returns:
- The string without quotes.
-
unescapeURL
Unescape all escaped characters in a CSS URL. All characters masked with a '\\' character replaced.- Parameters:
sEscapedURL- The escaped URL. May not benull!- Returns:
- The unescaped URL or the original string, if not a single escape sequence is found.
-
trimUrl
Remove the leading "url(" and the trailing ")" from an URL CSS value. No check is performed for the existence of a leading "url("! This method should only be called from within the parser.- Parameters:
s- The value to remove the string from.- Returns:
- The trimmed value. Never
null.
-
splitNumber
-
validateIdentifier
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F".
CSS Variables on the other hand allow for double dashes: https://www.w3.org/TR/css-variables-1/#defining-variables
Source: http://stackoverflow.com/questions/30819462/can-css-identifiers-begin-with- two-hyphens- Parameters:
aPattern- pattern to check- Returns:
- The input string
-
unescapeUnicode
Unescape e.g.\26or\000026to&.- Parameters:
aImage- Source string- Returns:
- Unmasked string
-
unescapeOther
Unescape e.g.\xto x.- Parameters:
aImage- Source string- Returns:
- Unmasked string
-