public class CommonUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CommonUtil.IntPair
Contains pair of intger values
|
| Constructor and Description |
|---|
CommonUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
adaptFilename(String filePath) |
static int |
countChars(String text,
char ch,
int from,
int to)
Counts number of specified characters in give text.
|
static Variable |
createVariable(Object value)
Creates appropriate AbstractVariable instance for the specified object.
|
static String |
encodeUrl(String url,
String charset) |
static String |
escapeXml(String s)
Escapes XML string - special characters: &'"<> are
replaced with XML escape sequences: & ' " < >
|
static boolean |
existsInStringArray(String[] array,
String s,
boolean caseSensitive)
Checks if specified string exists in given array
|
static int |
findValueInCollection(Collection c,
Object value)
Searches specified value in given collection
|
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 |
getAbsoluteFilename(String workingPath,
String filePath)
For the goven working path and file path returns absolute file path.
|
static boolean |
getBooleanValue(String value,
boolean defaultValue)
Reads boolean value from string
|
static String |
getClassName(Object o)
Returns class name without packages for the specified object
|
static String |
getDirectoryFromPath(String path)
Extracts a filename and directory from an absolute path.
|
static double |
getDoubleValue(String value,
double defaultValue)
Reads double value from string
|
static String |
getFileFromPath(String path)
Extracts a filename from an absolute path.
|
static int |
getIntValue(String value,
int defaultValue)
Reads integer value from string
|
static String |
getValidIdentifier(String value)
For the given string creates valid identifier name.
|
static boolean |
isBooleanTrue(String value)
Checks if specified string value represents boolean true value.
|
static boolean |
isEmpty(String s) |
static boolean |
isEmptyString(Object o) |
static boolean |
isFullUrl(String link)
Checks if specified link is full URL.
|
static boolean |
isPathAbsolute(String path)
Checks if specified file path is absolute.
|
static boolean |
isValidXmlIdentifier(String name)
Checks if given string is valid XML identifier, i.e.
|
static String |
nvl(Object value,
String defaultValue) |
static byte[] |
readBytesFromFile(File file) |
static String |
readStringFromFile(File file,
String encoding) |
static String |
readStringFromUrl(URL url)
Reads content from specified URL
|
static String |
replicate(String s,
int count) |
static void |
saveStringToFile(File file,
String content,
String charset)
Saves specified content to the file with specified charset.
|
static String |
serializeItem(net.sf.saxon.om.Item item)
Serializes item after XPath or XQuery processor execution using Saxon.
|
static String[] |
tokenize(String s,
String delimiters)
Tokenize given string for specified delimiter(s).
|
static String[] |
tokenize(String s,
String delimiters,
boolean trimTokens,
boolean allowEmptyTokens) |
public static boolean isEmptyString(Object o)
public static boolean isEmpty(String s)
public static boolean isValidXmlIdentifier(String name)
name - String to be checkedpublic static boolean isPathAbsolute(String path)
path - public static String getAbsoluteFilename(String workingPath, String filePath)
workingPath - filePath - public static String getDirectoryFromPath(String path)
public static String getFileFromPath(String path)
public static String getClassName(Object o)
public static boolean isBooleanTrue(String value)
public static boolean getBooleanValue(String value, boolean defaultValue)
value - defaultValue - value to be returned if string value is not recognizedpublic static int getIntValue(String value, int defaultValue)
value - defaultValue - value to be returned if string value is not valid integerpublic static double getDoubleValue(String value, double defaultValue)
value - defaultValue - value to be returned if string value is not valid doublepublic static String escapeXml(String s)
public static String serializeItem(net.sf.saxon.om.Item item) throws net.sf.saxon.trans.XPathException
net.sf.saxon.trans.XPathExceptionpublic static String readStringFromFile(File file, String encoding) throws IOException
IOExceptionpublic static void saveStringToFile(File file, String content, String charset) throws IOException
file - content - charset - IOExceptionUnsupportedEncodingExceptionpublic static byte[] readBytesFromFile(File file) throws IOException
IOExceptionpublic static boolean isFullUrl(String link)
link - public static String fullUrl(String pageUrl, String link)
public static Variable createVariable(Object value)
value - public static String readStringFromUrl(URL url) throws IOException
url - IOExceptionpublic static int countChars(String text, char ch, int from, int to)
text - Text to be parsedch - Character to be countedfrom - Text offsetto - Text endpublic static boolean existsInStringArray(String[] array, String s, boolean caseSensitive)
array - Array of stringss - String to be looked for in arraycaseSensitive - Tells whether search is case sensitivepublic static String[] tokenize(String s, String delimiters)
s - String to be tokenizeddelimiters - Delimiter character(s)public static String[] tokenize(String s, String delimiters, boolean trimTokens, boolean allowEmptyTokens)
public static String getValidIdentifier(String value)
value - String to be transformed to valid identifierpublic static int findValueInCollection(Collection c, Object value)
c - Collection to be searchedvalue - Object searched forCopyright © 2022 WSO2. All rights reserved.