|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.webharvest.utils.CommonUtil
public class CommonUtil
Basic evaluation utilities
| Nested Class Summary | |
|---|---|
static class |
CommonUtil.IntPair
Contains pair of intger values |
| Constructor Summary | |
|---|---|
CommonUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
adaptFilename(java.lang.String filePath)
|
static int |
countChars(java.lang.String text,
char ch,
int from,
int to)
Counts number of specified characters in give text. |
static Variable |
createVariable(java.lang.Object value)
Creates appropriate AbstractVariable instance for the specified object. |
static java.lang.String |
encodeUrl(java.lang.String url,
java.lang.String charset)
|
static java.lang.String |
escapeXml(java.lang.String s)
Escapes XML string - special characters: &'"<> are replaced with XML escape sequences: & ' " < > |
static boolean |
existsInStringArray(java.lang.String[] array,
java.lang.String s,
boolean caseSensitive)
Checks if specified string exists in given array |
static int |
findValueInCollection(java.util.Collection c,
java.lang.Object value)
Searches specified value in given collection |
static java.lang.String |
fullUrl(java.lang.String pageUrl,
java.lang.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 java.lang.String |
getAbsoluteFilename(java.lang.String workingPath,
java.lang.String filePath)
For the goven working path and file path returns absolute file path. |
static boolean |
getBooleanValue(java.lang.String value,
boolean defaultValue)
Reads boolean value from string |
static java.lang.String |
getClassName(java.lang.Object o)
Returns class name without packages for the specified object |
static java.lang.String |
getDirectoryFromPath(java.lang.String path)
Extracts a filename and directory from an absolute path. |
static double |
getDoubleValue(java.lang.String value,
double defaultValue)
Reads double value from string |
static java.lang.String |
getFileFromPath(java.lang.String path)
Extracts a filename from an absolute path. |
static int |
getIntValue(java.lang.String value,
int defaultValue)
Reads integer value from string |
static java.lang.String |
getValidIdentifier(java.lang.String value)
For the given string creates valid identifier name. |
static boolean |
isBooleanTrue(java.lang.String value)
Checks if specified string value represents boolean true value. |
static boolean |
isEmpty(java.lang.String s)
|
static boolean |
isEmptyString(java.lang.Object o)
|
static boolean |
isFullUrl(java.lang.String link)
Checks if specified link is full URL. |
static boolean |
isPathAbsolute(java.lang.String path)
Checks if specified file path is absolute. |
static boolean |
isValidXmlIdentifier(java.lang.String name)
Checks if given string is valid XML identifier, i.e. |
static java.lang.String |
nvl(java.lang.Object value,
java.lang.String defaultValue)
|
static byte[] |
readBytesFromFile(java.io.File file)
|
static java.lang.String |
readStringFromFile(java.io.File file,
java.lang.String encoding)
|
static java.lang.String |
readStringFromUrl(java.net.URL url)
Reads content from specified URL |
static java.lang.String |
replicate(java.lang.String s,
int count)
|
static void |
saveStringToFile(java.io.File file,
java.lang.String content,
java.lang.String charset)
Saves specified content to the file with specified charset. |
static java.lang.String |
serializeItem(net.sf.saxon.om.Item item)
Serializes item after XPath or XQuery processor execution using Saxon. |
static java.lang.String[] |
tokenize(java.lang.String s,
java.lang.String delimiters)
Tokenize given string for specified delimiter(s). |
static java.lang.String[] |
tokenize(java.lang.String s,
java.lang.String delimiters,
boolean trimTokens,
boolean allowEmptyTokens)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CommonUtil()
| Method Detail |
|---|
public static boolean isEmptyString(java.lang.Object o)
public static java.lang.String nvl(java.lang.Object value,
java.lang.String defaultValue)
public static java.lang.String adaptFilename(java.lang.String filePath)
public static boolean isEmpty(java.lang.String s)
public static boolean isValidXmlIdentifier(java.lang.String name)
name - String to be checked
public static boolean isPathAbsolute(java.lang.String path)
path -
public static java.lang.String getAbsoluteFilename(java.lang.String workingPath,
java.lang.String filePath)
workingPath - filePath -
public static java.lang.String getDirectoryFromPath(java.lang.String path)
public static java.lang.String getFileFromPath(java.lang.String path)
public static java.lang.String getClassName(java.lang.Object o)
public static java.lang.String replicate(java.lang.String s,
int count)
public static java.lang.String encodeUrl(java.lang.String url,
java.lang.String charset)
public static boolean isBooleanTrue(java.lang.String value)
public static boolean getBooleanValue(java.lang.String value,
boolean defaultValue)
value - defaultValue - value to be returned if string value is not recognized
public static int getIntValue(java.lang.String value,
int defaultValue)
value - defaultValue - value to be returned if string value is not valid integer
public static double getDoubleValue(java.lang.String value,
double defaultValue)
value - defaultValue - value to be returned if string value is not valid doublepublic static java.lang.String escapeXml(java.lang.String s)
public static java.lang.String serializeItem(net.sf.saxon.om.Item item)
throws net.sf.saxon.trans.XPathException
net.sf.saxon.trans.XPathException
public static java.lang.String readStringFromFile(java.io.File file,
java.lang.String encoding)
throws java.io.IOException
java.io.IOException
public static void saveStringToFile(java.io.File file,
java.lang.String content,
java.lang.String charset)
throws java.io.IOException
file - content - charset -
java.io.IOException
java.io.UnsupportedEncodingException
public static byte[] readBytesFromFile(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static boolean isFullUrl(java.lang.String link)
link -
public static java.lang.String fullUrl(java.lang.String pageUrl,
java.lang.String link)
public static Variable createVariable(java.lang.Object value)
value -
public static java.lang.String readStringFromUrl(java.net.URL url)
throws java.io.IOException
url -
java.io.IOException
public static int countChars(java.lang.String text,
char ch,
int from,
int to)
text - Text to be parsedch - Character to be countedfrom - Text offsetto - Text end
public static boolean existsInStringArray(java.lang.String[] array,
java.lang.String s,
boolean caseSensitive)
array - Array of stringss - String to be looked for in arraycaseSensitive - Tells whether search is case sensitive
public static java.lang.String[] tokenize(java.lang.String s,
java.lang.String delimiters)
s - String to be tokenizeddelimiters - Delimiter character(s)
public static java.lang.String[] tokenize(java.lang.String s,
java.lang.String delimiters,
boolean trimTokens,
boolean allowEmptyTokens)
public static java.lang.String getValidIdentifier(java.lang.String value)
value - String to be transformed to valid identifier
public static int findValueInCollection(java.util.Collection c,
java.lang.Object value)
c - Collection to be searchedvalue - Object searched for
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||