public class Utils extends Object
Common utilities.
Modifier and Type | Field and Description |
---|---|
static Map<Character,String> |
RESERVED_XML_CHARS |
static String |
VAR_END |
static String |
VAR_START |
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static String |
escapeXml(String s,
CleanerProperties props,
boolean isDomCreation)
Escapes XML string.
|
static String |
evaluateTemplate(String template,
Map variables)
Evaluates string template for specified map of variables.
|
static String |
fullUrl(String pageUrl,
String link)
Calculates full URL for specified page URL and link
which could be full, absolute or relative like there can
be found in A or IMG tags.
|
static String |
getCharsetFromContent(URL url) |
static String |
getCharsetFromContentTypeString(String contentType) |
static String |
getXmlName(String name) |
static String |
getXmlNSPrefix(String name) |
static boolean |
isEmptyString(Object o) |
static boolean |
isFullUrl(String link)
Checks if specified link is full URL.
|
static boolean |
isHexadecimalDigit(char ch) |
static boolean |
isIdentifierHelperChar(char ch)
Checks if specified character can be part of xml identifier (tag name of attribute name)
and is not standard identifier character.
|
static boolean |
isReservedXmlChar(char ch) |
static boolean |
isValidInt(String s,
int radix) |
static boolean |
isValidXmlChar(char ch) |
static boolean |
isValidXmlIdentifier(String s)
Chacks whether specified string can be valid tag name or attribute name in xml.
|
static boolean |
isWhitespaceString(Object object)
Checks whether specified object's string representation is empty string (containing of only whitespaces).
|
static String |
ltrim(String s)
Trims specified string from left.
|
static String |
rtrim(String s)
Trims specified string from right.
|
static String[] |
tokenize(String s,
String delimiters) |
static void |
updateTagTransformations(CleanerTransformations transformations,
String key,
String value) |
public static String getCharsetFromContentTypeString(String contentType)
public static String getCharsetFromContent(URL url) throws IOException
IOException
public static boolean isHexadecimalDigit(char ch)
public static boolean isValidXmlChar(char ch)
public static boolean isReservedXmlChar(char ch)
public static boolean isValidInt(String s, int radix)
public static String escapeXml(String s, CleanerProperties props, boolean isDomCreation)
s
- String to be escapedprops
- Cleaner properties gover affect escaping behaviourisDomCreation
- Tells if escaped content will be part of the DOMpublic static boolean isWhitespaceString(Object object)
object
- Object whose string representation is checkedpublic static boolean isIdentifierHelperChar(char ch)
ch
- Character to be checkedpublic static boolean isValidXmlIdentifier(String s)
s
- String to be checkedpublic static boolean isEmptyString(Object o)
o
- public static String evaluateTemplate(String template, Map variables)
template
- Template stringvariables
- Map of variables (can be null)public static void updateTagTransformations(CleanerTransformations transformations, String key, String value)
public static boolean isFullUrl(String link)
link
- public static String fullUrl(String pageUrl, String link)
public static String getXmlNSPrefix(String name)
name
- Copyright © 2006–2018. All rights reserved.