|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jalios.util.Util
public class Util
This class provides a set of static methods which perform various utility operations.
Field Summary | |
---|---|
static HashMap |
basicEntitiesDecodingMap
|
static HashMap |
basicEntitiesEncodingMap
|
static HashMap<String,String> |
cookieTransTable
|
static TreeSet |
EMPTY_TREESET
The empty TreeSet (immutable). Use emptyTreeSet() for generics compliance. |
static char |
ESCAPE_CHAR
|
protected static org.apache.oro.text.regex.Perl5Compiler |
hexaPercentCompiler
|
protected static org.apache.oro.text.regex.Pattern |
hexaPercentPattern
|
protected static org.apache.oro.text.regex.Perl5Substitution |
hexaPercentSubst
|
static HashMap<String,String> |
isoLatin1_xml
|
static HashMap<String,String> |
regexpEscaped1
|
static HashMap<String,String> |
regexpEscaped2
|
static HashMap<String,String> |
regexpEscaped3
|
static String |
REVISION
|
Method Summary | ||
---|---|---|
static
|
addAll(Collection<T> collection,
Enumeration<T> enu)
Add all element of the enumerate to the collection return the collection modified. |
|
static
|
addAll(Collection<T> collection,
Iterator<T> it)
Add all element of the iterator to the collection return the collection modified. |
|
static
|
addAll(T[] array,
Collection<T> coll)
Copy all non-null objects from the given array to given collection. |
|
static
|
addInMapHashSet(Map<K,Set<V>> map,
K key,
V value)
A convenient method that add the given value to a set bound to the given key in the given map. |
|
static
|
addInMapLinkedHashSet(Map<K,LinkedHashSet<V>> map,
K key,
V value)
A convenient method that add the given value to a set bound to the given key in the given map. |
|
static boolean |
arrayContains(Object[] array,
Object key)
Test if an array contains a given object. |
|
static String |
asciiIndent(String text,
int cols,
int rows,
String tailString)
Indent a given text according a number of column and row. |
|
static String |
buildCamelID(String str)
Build a Camel Case ID from the given String: remove the blanks, unaccentuates, removes non-alphanum chars. |
|
static String |
buildID(String str)
Build an ID from the given String: replaces the blanks with '_', unaccentuates, removes non-alphanum chars and lowercases. |
|
static String |
buildID(String str,
String charRange)
Build an ID from the given String: replaces the blanks with '_', unaccentuates, removes chars out of the given range and lowercases. |
|
static String |
buildUID(String str,
Set<String> strSet)
Build an ID from the given String: replaces the blanks with '_', unaccentuates, removes non-alphanum chars and lowercases. |
|
static
|
cleanCollection(Collection<T> coll)
Remove the null entries of the given collection. |
|
static Object[] |
cleanObjectArray(Object[] array)
Creates a new array that contains all elements of the given array without null. |
|
static String[] |
cleanStringArray(String[] array)
Creates a new array that contains all elements of the given array except empty Strings (ie null or empty). |
|
static
|
collectionToCleanSet(Collection<T> coll)
Returns a set which contains all the non empty element of the given collection. |
|
static
|
compareMap(Map<K,V> map1,
Map<K,V> map2)
Returns the first common Map.Entry of the given maps. |
|
static String |
conceal(String clearStr)
Conceal the given string with an internally choosen encryption algorithm. WARNING: This method is not mathematically safe and is only used to hide sensitive data on first look. |
|
static String |
cryptMD5(String str)
Encrypt the given string with the MD5 algorithm and BASE64 |
|
static String |
cryptUnix(String str)
Encrypt the given string with the Unix crypt algorithm |
|
static String |
decodeBASE64(String str)
Decode the given string using BASE64 algorithm |
|
static String |
decodeCookie(String src)
|
|
static String |
decodeHtmlBasicEntities(String src)
Does the opposite job of encodeHtmlBasicEntities. |
|
static int[] |
decodeIntArray(String param)
|
|
static int[] |
decodeIntArray(String param,
char separator)
|
|
static Object |
decodeObject(String encoded)
Returns the object decoded from the given String. |
|
static String[] |
decodeStringArray(String param)
|
|
static String[] |
decodeStringArray(String param,
char separator)
|
|
static String |
decodeUrl(String str)
|
|
static String |
decryptDES3(String encryptedStr)
Decrypt the specified string using DESede StringEncrypter using same internal key
used by encryptDES3(String) . |
|
static
|
emptyTreeSet()
Returns the empty TreeSet (immutable). |
|
static String |
encodeBASE64(String str)
Encode the given string using BASE64 algorithm. |
|
static String |
encodeBASE64(String str,
boolean isChunck)
Encode the given string using BASE64 algorithm. |
|
static String |
encodeCookie(String src)
|
|
static String |
encodeHtmlBasicEntities(String src)
Encode given string according to the following table. |
|
static String |
encodeIntArray(int[] array)
|
|
static String |
encodeIntArray(int[] array,
char separator)
|
|
static String |
encodeJavaScriptQuote(String str)
Deprecated. use com.jalios.jcms.HttpUtil.encodeForJavaScript |
|
static String |
encodeObject(Object obj)
Returns the encoded objected as a String. |
|
static String |
encodeStringArray(String[] array)
|
|
static String |
encodeStringArray(String[] array,
char separator)
|
|
static String |
encodeUrl(String s)
Same implementation as URLEncoder.encode(String, String) ,
but space is encoded with %20 and '/' is not encoded. |
|
static String |
encodeUrl(String s,
String enc)
Same implementation as URLEncoder.encode(String, String) ,
but space is encoded with %20 and '/' is not encoded. |
|
static String |
encryptDES3(String clearStr)
Encrypt the specified string using DESede StringEncrypter with an internal key.WARNING: This method is not mathematically safe and is only used to hide sensitive data on first look. |
|
static String |
entitiesToIsoLatin1(String src)
Does the opposite of isoLatin1ToEntities. |
|
static String |
escapeBackslash(String str)
Escape all the '\' in the given String ('\\') |
|
static String |
escapeChars(String str,
String charsToEscape)
Escape specified characters in a String. |
|
static String |
escapeHtml(String str)
Escapes some special HTML characters such as <, >, & and ". |
|
static String |
escapeHtmlQuote(String str)
Deprecated. use com.jalios.jcms.HttpUtil.encodeFor[HTML|HTMLAttribute|Javascript] depending on the context |
|
static String |
escapeInputQuote(String str)
Deprecated. use com.jalios.jcms.HttpUtil.encodeFor[HTML|HTMLAttribute|Javascript] depending on the context |
|
static String |
escapeJavaScriptQuote(String str)
Deprecated. use com.jalios.jcms.HttpUtil.encodeForJavaScript |
|
static String |
escapeJavaStringChar(String str)
Escape all the invalide char in Java String: '\' -> "\\" CR -> "\n" '"' -> \" |
|
static String |
escapeLuceneQuery(String str)
Escape Lucene special chars. |
|
static String |
escapePercent(String url)
This method replace % in wrong hexa character by '_' character |
|
static String |
escapeRegexp(String string)
Escape a (OROMatcher) regular expression with support of basic regexp (* and ?). |
|
static String |
escapeRegexp(String string,
boolean basicRegexp)
Escape a (OROMatcher) regular expression with support of basic regexp (* and ?). |
|
static int |
exec(String... cmdarray)
Executes the specified command and arguments in a separate process. |
|
static int |
exec(String[] cmdarray,
OutputStream stdout,
OutputStream stderr)
Executes the specified command and arguments in a separate process. |
|
static int |
exec(String[] cmdarray,
StringBuilder stdout,
StringBuilder stderr)
Executes the specified command and arguments in a separate process. |
|
static boolean |
forceFullGarbageCollection(long timeout)
Force the garbage collection |
|
static String |
formatDuration(Date begin,
Date end)
Deprecated. Use DateUtil.formatDuration(Date,Date) instead |
|
static String |
formatDuration(Date begin,
Date end,
Locale locale)
Deprecated. Use DateUtil.formatDuration(Date,Date,Locale) instead |
|
static String |
formatDuration(long time)
Deprecated. Use DateUtil.formatDuration(long) instead |
|
static String |
formatDuration(long time,
Locale locale)
Deprecated. Use DateUtil.formatDuration(long,Locale) instead |
|
static String |
formatFileSize(long size)
This method format the given size on the greatest unit. |
|
static String |
formatFileSize(long size,
Locale locale)
This method format the given size on the greatest unit. |
|
static String |
formatFileSize(long size,
Locale locale,
boolean htmlDisplay)
This method format the given size on the greatest unit. |
|
static String |
formatIso8601Date(Date date)
Deprecated. Use DateUtil.formatIso8601Date(Date) instead |
|
static String |
formatNoSpaceDate(Date date)
Deprecated. Use DateUtil.formatNoSpaceDate(Date) instead |
|
static String |
formatRfc822Date(Date date)
Deprecated. Use DateUtil.formatRfc822Date(Date) instead |
|
static String |
formatSize(long size,
Locale locale)
This method format the given size on the greatest unit. |
|
static String |
formatW3cDate(Date date)
Deprecated. Use DateUtil.formatW3cDate(Date) instead |
|
static String |
generatePassword()
Generates a basic password (consonnants / voyels) of 8 characters. |
|
static String |
generatePassword(int length)
Generates a basic password (consonnants / voyels) of the specified length. |
|
static String |
generatePronounceablePassword(int pwdLength)
Generates pronounceable passwords of specified length. |
|
static Set |
getAllChildren(TreeNode node,
Set nodeSet)
Fill the given set with every children of the given treenode, including the node itself, returns the filled set. |
|
static TreeSet |
getAllChildrenSet(TreeNode node)
Returns a TreeSet with all children of the given treenode, (including the node itself) |
|
static
|
getArrayList(T... array)
Returns a new ArrayList filled with the given objects (skip null object). |
|
static boolean |
getBoolean(boolean[] array,
int index,
boolean defaultValue)
|
|
static Object |
getChildListMap(Map map,
String key)
Returns the first Value matching the given key |
|
static List |
getChildrenListMap(Map map,
String key)
Returns values matching the given key. |
|
static List |
getChildrenListMap(Map map,
String[] keys)
Returns a new List of values matching the ordered given keys. |
|
static Set<String> |
getClassFiles(String realPath,
String fullname,
boolean java)
Returns a Set of relative path to all class files including inner class and java. |
|
static String |
getClassNameFromFilename(String filename)
Returns the class name from the filename of a class (e.g. |
|
static String |
getClassShortName(Class clazz)
Returns the short name of the given class (e.g. |
|
static String |
getClassShortName(Object object)
Returns the short name of the given object's class (e.g. |
|
static String |
getClassShortName(String fullname)
Returns the short name of the given class name (e.g. |
|
static String |
getCurrentStackTrace()
Returns the current StackTrace in a String. |
|
static
|
getFirst(Collection<T> coll)
Returns the first itemp of the given collection (or null if the collection is empty). |
|
static
|
getFirst(T[] array)
Returns the first itemp of the given array (or null if the array is empty). |
|
static Class |
getFirstCommonClass(Class parent,
Class child)
Follow class tree of parent to find a class or an interface that is also parent of the child. |
|
static String |
getFirstSentences(String text,
int limit)
Get the first sentences in a given string. |
|
static
|
getHashMap(K key,
V value)
Returns a new HashMap filled with the given key/value pair (if the key is not null). |
|
static
|
getHashMap(Map<K,V> map)
Returns a new HashMap filled with the given map (if it is not null) |
|
static
|
getHashSet(T... array)
Returns a new HashSet filled with the given objects (skip null object). |
|
static String |
getHtmlIcon(String src,
String alt)
Build an icon |
|
static int |
getInt(int[] array,
int index,
int defaultValue)
|
|
static
|
getKey(Map<K,V> map,
V value)
Iterate over a Map, looking for a Key associated to a given value. |
|
static
|
getKeys(Map<K,V> map,
V value)
Iterate over a Map, looking for a Keys associated to a given value. |
|
static
|
getLinkedHashMap(K key,
V value)
Returns a new LinkedHashMap filled with the given key/value pair (if the key is not null). |
|
static
|
getLinkedHashMap(Map<K,V> map)
Returns a new LinkedHashMap filled with the given map (if it is not null) |
|
static String |
getMatch(Pattern pattern,
String str,
int group)
Return the group matching the given regexp for the given String or null if do not match or exception happens |
|
static String |
getMatch(String regexp,
String str,
int group)
Return the group matching the given regexp for the given String or null if do not match or exception happens |
|
static Date |
getNewDateWithoutMillis()
Deprecated. Use DateUtil.getNewDateWithoutMillis() instead |
|
static Object |
getObject(Object[] array,
int index,
Object defaultValue)
|
|
static int |
getSize(boolean[] array)
Returns the size of the given array. |
|
static int |
getSize(byte[] array)
Returns the size of the given array. |
|
static int |
getSize(char[] array)
Returns the size of the given array. |
|
static int |
getSize(Collection coll)
Returns the size of the given collection. |
|
static int |
getSize(double[] array)
Returns the size of the given array. |
|
static int |
getSize(float[] array)
Returns the size of the given array. |
|
static int |
getSize(int[] array)
Returns the size of the given array. |
|
static int |
getSize(long[] array)
Returns the size of the given array. |
|
static int |
getSize(Map map)
Returns the size of the given map. |
|
static int |
getSize(Object[] array)
Returns the size of the given array. |
|
static int |
getSize(short[] array)
Returns the size of the given array. |
|
static int |
getSize(String str)
Returns the size of the given String. |
|
static String |
getStackTrace(Throwable throwable)
This method print the stack trace into a String and return it. |
|
static String |
getString(Object[] array,
int index,
String defaultValue)
Call the method getString() with the Object in the array specified at the given index. |
|
static String |
getString(Object obj,
String defaultValue)
Return the String representation of the given object if it is not null nor empty, otherwise it returns the default value. |
|
static List |
getSuperclassList(Class clazz,
Class ancestor,
boolean addClass,
boolean addAncestor)
Returns a list of classes the given class is an ancestor of. |
|
static TreeSet |
getTreeDescendantSet(TreeNode node)
Returns a TreeSet with all descendant of the given treenode, (excluding the node itself) |
|
static Set |
getTreeDescendantSet(TreeNode node,
Set nodeSet)
|
|
static
|
getTreeMap(K key,
V value)
Returns a new TreeMap filled with the given key/value pair (if the key is not null). |
|
static
|
getTreeMap(Map<K,V> map)
Returns a new TreeMap filled with the given map (if it is not null) |
|
static
|
getTreeSet(T... array)
Returns a new TreeSet filled with the given objects (skip null object). |
|
static boolean |
hasAppenderDefined(org.apache.log4j.Logger logger)
Checks if the given Logger has any appender defined. |
|
static String |
html2Ascii(String str)
Convert the specified string from HTML to raw text, preserving and converting as much spaces as possibles (space, <br>, carriage return, line feeds, ...). |
|
static String |
html2text(String html)
Extract all text from the specified html and returns it. |
|
static int |
indexOf(Object elem,
Object[] array)
Searches for the first occurence of the given argument in a given array, testing for equality using the equals method. |
|
static boolean[] |
insertArray(boolean[] array,
int index,
boolean elt)
Insert an element into a boolean array and return a duplicate copy of it. |
|
static int[] |
insertArray(int[] array,
int index,
int elt)
Insert an element into an int array and return a duplicate copy of it. |
|
static Object[] |
insertArray(Object[] array,
int index,
Object elt)
Insert an element into an Object array and return a duplicate copy of it. |
|
static
|
interMap(Map<? extends K,? extends V> map,
Set<? extends K> keys)
This method will return a new Map containing only values of specified map with given keys. |
|
static Set |
interSet(Set... sets)
Returns the intersection of an array of Set . |
|
static Set |
interSet(Set set1,
Set set2)
Returns the intersection of two Set . |
|
static Set |
interSet(Set set1,
Set set2,
Set set3)
Returns the intersection of three Set . |
|
static boolean |
isChildNode(TreeNode node,
TreeNode child)
Test if a node is a child of an other node Return false if child == node |
|
static boolean |
isEmpty(boolean[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(byte[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(char[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(Collection<?> c)
Returns true if this collection is
null or empty. |
|
static boolean |
isEmpty(Collection<?> c,
boolean deep)
Returns true if this collection is
null or empty. |
|
static boolean |
isEmpty(double[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(File file)
Returns true if this file is
null or empty. |
|
static boolean |
isEmpty(File file,
FileFilter fileFilter)
Returns true if this file is
null or empty. |
|
static boolean |
isEmpty(float[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(int[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(long[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(Map<?,?> map)
Returns true if this map is
null or empty. |
|
static boolean |
isEmpty(Object object)
Returns true if this object is
null or empty. |
|
static boolean |
isEmpty(Object[] array)
Returns true if this array is
null or empty. |
|
static boolean |
isEmpty(Object[] array,
boolean recursive)
Returns true if this array is
null or empty. |
|
static boolean |
isEmpty(short[] array)
Returns true if this array is null or empty. |
|
static boolean |
isEmpty(SQLQueryResult sqr)
Returns true if this SQLQueryResult is
null or empty. |
|
static boolean |
isEmpty(String s)
Returns true if this string is null or
empty (once trimmed). |
|
static
|
isMapFilled(Map<K,V> map)
Returns true if the given map contains at least one value not empty. |
|
static boolean |
isNumber(String str)
Returns true if the given string only contains 0-9 characters |
|
static String |
isoLatin1ToEntities(String src)
Convert all the isoLatin1 accent into XML entities (e.g. |
|
static boolean |
isSameContent(boolean[] array1,
boolean[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(byte[] array1,
byte[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(char[] array1,
char[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(Date date1,
Date date2)
Returns true if date1 has same content than date2. |
|
static boolean |
isSameContent(double[] array1,
double[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(org.jdom.Element elt1,
org.jdom.Element elt2)
Returns true if elt1 has same content than elt2. |
|
static boolean |
isSameContent(float[] array1,
float[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(int[] array1,
int[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(List list1,
List list2)
Returns true if list1 has same content than list2. |
|
static boolean |
isSameContent(long[] array1,
long[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(Map map1,
Map map2)
Returns true if map1 has same content than map2. |
|
static boolean |
isSameContent(Object[] array1,
Object[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(Set set1,
Set set2)
Returns true if set1 has same content than set2. |
|
static boolean |
isSameContent(short[] array1,
short[] array2)
Returns true if array1 has same content than array2. |
|
static boolean |
isSameContent(String str1,
String str2)
Returns true if str1 has same content than str2. |
|
static boolean |
isSameDay(Date date1,
Date date2)
Deprecated. Use DateUtil.isSameDay(Date,Date) instead |
|
static boolean |
isToday(Date date)
Deprecated. Use DateUtil.isToday(Date) instead |
|
static boolean |
isTomorrow(Date date)
Deprecated. Use DateUtil.isTomorrow(Date) instead |
|
static boolean |
isYesterday(Date date)
Deprecated. Use DateUtil.isYesterday(Date) instead |
|
static String |
join(boolean[] array,
String sep)
Joins an array of boolean with the given separator. |
|
static String |
join(boolean[] array,
String sep,
int max,
String suffix)
Joins an array of boolean with the given separator. |
|
static String |
join(Collection<?> col,
String sep)
Joins a collection of Object with the given separator into a String. |
|
static String |
join(Collection<?> col,
String sep,
int max,
String suffix)
Joins a collection of Object with the given separator into a String. |
|
static String |
join(double[] array,
String sep)
Joins an array of double with the given separator. |
|
static String |
join(double[] array,
String sep,
int max,
String suffix)
Joins an array of double with the given separator. |
|
static String |
join(int[] array,
String sep)
Joins an array of int with the given separator. |
|
static String |
join(int[] array,
String sep,
int max,
String suffix)
Joins an array of int with the given separator. |
|
static String |
join(Iterator<?> it,
String sep)
Joins a collection of Object with the given separator into a String. |
|
static String |
join(Iterator<?> it,
String sep,
int max,
String suffix)
Joins a collection of Object with the given separator into a String. |
|
static String |
join(long[] array,
String sep)
Joins an array of long with the given separator. |
|
static String |
join(long[] array,
String sep,
int max,
String suffix)
Joins an array of long with the given separator. |
|
static String |
join(Object[] array,
String sep)
Joins an array of String with the given separator. |
|
static String |
join(Object[] array,
String sep,
int max,
String suffix)
Joins an array of String with the given separator. |
|
static String |
join(String... str)
Join String with a given separator First String is the separator Always return a String If Str1 or Str2 is null then return the other value without separator |
|
static String |
joinMap(Map<? extends Object,? extends Object> map,
String keyValueSep,
String entrySep)
Joins the entries of a map into a String. |
|
static void |
listDictionary(Dictionary<?,?> dict)
Lists a Dictionnary on System.out . |
|
static void |
listDictionary(Dictionary<?,?> dict,
PrintStream out)
Lists a Dictionnary on the given PrintStream . |
|
static void |
listDictionary(Dictionary<?,?> dict,
PrintStream out,
String sep)
Lists a dictionnary on the given PrintStream with
the given separator. |
|
static void |
listMap(Map<?,?> map)
Lists a map on System.out . |
|
static void |
listMap(Map<?,?> map,
PrintStream out)
Lists a map on the given PrintStream . |
|
static void |
listMap(Map<?,?> map,
PrintStream out,
String sep)
Lists a map on the given PrintStream with the given
separator. |
|
static void |
mainRemoveArray(String[] args)
|
|
static void |
mainSwapArray(String[] args)
|
|
static void |
mainTestBuildID(String[] args)
|
|
static void |
mainTestEmpty(String[] args)
|
|
static void |
mainTestEscapeLuceneQuery(String[] args)
|
|
static void |
mainTestFormatDuration(String[] args)
Deprecated. Use DateUtil.mainTestFormatDuration(String[]) instead |
|
static void |
mainTestGeneratePassword(String[] args)
|
|
static void |
mainTestInterUnionSubSet(String[] args)
|
|
static void |
mainTestJoin(String[] args)
|
|
static boolean |
notEmpty(Collection<?> c)
Returns true if this collection is not
null nor empty. |
|
static boolean |
notEmpty(File file)
Returns true if this File is not
null nor empty. |
|
static boolean |
notEmpty(File file,
FileFilter fileFilter)
Returns true if this File is not
null nor empty. |
|
static boolean |
notEmpty(int[] array)
Returns true if this array is not null nor empty. |
|
static boolean |
notEmpty(Map<?,?> map)
Returns true if this map is not
null nor empty. |
|
static boolean |
notEmpty(Object object)
Returns true if this object is not
null nor empty. |
|
static boolean |
notEmpty(Object[] array)
Returns true if this array is not
null nor empty. |
|
static boolean |
notEmpty(Object[] array,
boolean recursive)
Returns true if this array is not
null nor empty. |
|
static boolean |
notEmpty(SQLQueryResult map)
Returns true if this SQLQueryResult is not
null nor empty. |
|
static boolean |
notEmpty(String s)
Returns true if this string is not null
nor empty (once trimmed). |
|
static Date |
parseIso8601Date(String source)
Deprecated. Use DateUtil.parseIso8601Date(String) instead |
|
static Date |
parseNoSpaceDate(String source)
Deprecated. Use DateUtil.parseNoSpaceDate(String) instead |
|
static Date |
parseRfc822Date(String source)
Deprecated. Use DateUtil.parseRfc822Date(String) instead |
|
static Date |
parseW3cDate(String source)
Deprecated. Use DateUtil.parseW3cDate(String) instead |
|
static String |
performDecoding(String src,
HashMap transMap)
Replace all occurences of values found in transMap with their assiocated keys. |
|
static String |
performEncodeDecode(String src,
HashMap transMap,
boolean decode)
Encode or decode the given String using the given translation Map. |
|
static String |
performEncoding(String src,
HashMap transMap)
Replace all occurences of keys found in transMap with their assiocated values. |
|
static Set<String> |
prefixSet(Set<String> set,
String prefix)
Prefix all elements of a Set of String with a given prefix |
|
static
|
putAll(K[] array,
Map<K,V> map,
V value)
Copy all non-null objects from the given array to given map with a given value. |
|
static String |
randomString(int length)
|
|
static String |
recapitalize(String str)
Force the first char of a String to be a uppercase char. |
|
static String |
reduceBlankLines(String text)
Right trim all the lines in the message and reduced many CRLF to only one line. |
|
static boolean[] |
removeArray(boolean[] array,
int index)
Remove an element of an Array of boolean |
|
static boolean[] |
removeArray(boolean[] array,
int from,
int to)
Remove n elements of an Array of boolean |
|
static int[] |
removeArray(int[] array,
int index)
Remove an element of an Array of int |
|
static int[] |
removeArray(int[] array,
int from,
int to)
Remove n elements of an Array of int |
|
static Object[] |
removeArray(Object[] array,
int index)
Remove an element of an Array of object |
|
static Object[] |
removeArray(Object[] array,
int from,
int to)
Remove n elements of an Array of object |
|
static Object[] |
removeArray(Object[] array,
Object obj)
Remove an element of an Array of object |
|
static String |
removeBlankLines(String str)
Cleans the given string : remove pure blank lines and remove leadings white spaces. |
|
static
|
removeFromMapHashSet(Map<K,Set<V>> map,
K key,
V value)
A convenient method that remove the given value to a set bound to the given key in the given map. |
|
static
|
removeFromMapLinkedHashSet(Map<K,LinkedHashSet<V>> map,
K key,
V value)
A convenient method that remove the given value to a set bound to the given key in the given map. |
|
static String |
removeJavaScriptQuote(String str)
Deprecated. use com.jalios.jcms.HttpUtil.encodeForJavaScript |
|
static String |
repeat(String pattern,
int count)
Repeat a String pattern count times |
|
static String |
replace(String text,
org.apache.oro.text.regex.Pattern pattern,
RegexpSubstitution substitution)
Replaces the given pattern in the given text with the given substitution function. |
|
static String |
replace(String str,
String pattern)
Search and replace a string by another one |
|
static String |
replace(String text,
String regexp,
RegexpSubstitution substitution)
Replaces the given regexp in the given text with the given substitution function. |
|
static String |
replace(String str,
String match,
String rep)
Search and replace a string by another one (Note the input string must not contains '#' char) |
|
static String |
replaceAll(String input,
String searchString,
String replaceString)
Replace all occurence of searchString with replaceString in input string. |
|
static String |
reveal(String concealedStr)
Reveal the specified hidden string with an internally choosen encryption algorithm. |
|
static
|
reverseMap(Map<K,V> originalMap,
Map<V,K> reverseMap)
Fill the reverse map with the original map replacing keys by values and values by keys. |
|
static long |
roundDuration(long duration)
Deprecated. Use DateUtil.roundDuration(long) instead |
|
static String[] |
split(String str,
char delim,
String emptyToken)
Splits a String into an array of String. |
|
static String[] |
split(String str,
String delim)
Splits a String into an array of String. |
|
static int[] |
splitToIntArray(String str,
String delim)
Splits a String into an array of int. |
|
static ArrayList<String> |
splitToList(String str,
String delim)
Splits a String into a list of String. |
|
static String[] |
splitWithPattern(String text,
String pattern)
Splits a String according a given pattern and returns an array of String. |
|
static String |
startsWith(String str,
Collection<String> coll)
Returns the String in the given collection that is a starting string og given str |
|
static Set<String> |
stringArrayToCleanSet(String[] array)
Returns a set which contains all the non empty cells of the given array. |
|
static
|
subMap(Map<K,V> map,
Set<K> keys)
This method will return a new Map containing all values of specified map without given keys. |
|
static Set |
subSet(Set... sets)
Returns the subset of an array of Set . |
|
static Set |
subSet(Set set1,
Set set2)
Returns the subset of an array of Set . |
|
static Set |
subSet(Set set1,
Set set2,
Set set3)
Returns the subset of an array of Set . |
|
static String |
surround(String inside,
String begin,
String end)
Surround a given text (the first argument) with the two other arguments, only if the given text is not empty. |
|
static String |
surroundWithTag(String inside,
String tag)
Surround a given text (the first argument) with a html tag. |
|
static boolean[] |
swapArray(boolean[] array,
int from,
int to,
boolean roll,
boolean copy)
Swap two cells of a boolean array. |
|
static int[] |
swapArray(int[] array,
int from,
int to,
boolean roll,
boolean copy)
Swap two cells of an int array. |
|
static Object[] |
swapArray(Object[] array,
int from,
int to,
boolean roll,
boolean copy)
Swap two cells of an Object array. |
|
static boolean |
toBoolean(Object obj,
boolean def)
Convert an Object (assert to be either a String or a Boolean) to a boolean |
|
static byte |
toByte(Object obj,
byte def)
Convert an Object (assert to be either a String or a Byte ) to a byte |
|
static char |
toChar(Object obj,
char def)
Convert an Object (assert to be either a String or a Character ) to a char |
|
static Date |
toDate(String str,
String format,
Locale loc,
Date def)
Parse a String and Convert it into a Date |
|
static double |
toDouble(Object obj,
double def)
Convert an Object (assert to be either a String or a Double ) to a double |
|
static float |
toFloat(Object obj,
float def)
Convert an Object (assert to be either a String or a Float ) to a float |
|
static int |
toInt(Object obj,
int def)
Convert an Object (assert to be either a String or a Integer ) to a int |
|
static int[] |
toIntArray(Object[] objs,
int def)
Convert an Object[] (assert to be either a String or a Integer ) to a int |
|
static Locale |
toLocale(String str,
Locale def)
|
|
static long |
toLong(Object obj,
long def)
Convert an Object (assert to be either a String or a Long ) to a long |
|
static short |
toShort(Object obj,
short def)
Convert an Object (assert to be either a String or a Short ) to a short |
|
static String |
toWordLine(String str)
Split a text in a String with one word by line (used for diffing 2 strings at word level). |
|
static String[] |
trim(String[] array)
Remove the trailing empty cells of the given String array. |
|
static String |
trimEnd(String str)
Trim the end of a String |
|
static
|
trimList(List<T> list)
Returns a copy of the given list without any null values at the end. |
|
static String[] |
trimStringArray(String[] array)
Remove the trailing empty cells of the given String array. |
|
static String |
truncate(String str,
int length)
Truncates the given String. |
|
static String |
truncate(String str,
int length,
String suffix)
Truncates the given String |
|
static String |
truncateHtml(String text,
int length,
boolean trim)
Truncate an HTML string. |
|
static String |
unaccentuate(String str)
Removes all the accentuate chars of the given string. |
|
static String |
unaccentuateRegexp(String str)
Build an unaccentuated version of the given regexp. |
|
static String |
uncapitalize(String str)
Force the first char of a String to be a lowercase char. |
|
static String |
unescapeChar(String str)
Unescape escaped character in a String. |
|
static Set<?> |
unionSet(Set<?>... sets)
Returns the union of an array of Set . |
|
static Set |
unionSet(Set set1,
Set set2)
Returns the union of two Set . |
|
static Set |
unionSet(Set set1,
Set set2,
Set set3)
Returns the union of three Set . |
|
static void |
updateListMap(Map map,
Object key,
Object value,
boolean lazy)
Updated Map with the given key/value pair. |
|
static boolean |
validateRegexp(String regexp)
Tell if a String is a valid Perl 5 regexp. |
|
static String |
wordWrap(String str,
int width)
Wraps a single line of text, identifying words by ' ' . |
|
static String |
wordWrap(String str,
int wrapLength,
String newLineStr,
boolean wrapLongWords)
Wraps a single line of text, identifying words by ' ' . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
public static final TreeSet EMPTY_TREESET
emptyTreeSet()
for generics compliance.
public static final HashMap<String,String> regexpEscaped1
public static final HashMap<String,String> regexpEscaped2
public static final HashMap<String,String> regexpEscaped3
protected static org.apache.oro.text.regex.Pattern hexaPercentPattern
protected static org.apache.oro.text.regex.Perl5Substitution hexaPercentSubst
protected static org.apache.oro.text.regex.Perl5Compiler hexaPercentCompiler
public static final char ESCAPE_CHAR
public static final HashMap<String,String> cookieTransTable
public static final HashMap<String,String> isoLatin1_xml
public static final HashMap basicEntitiesEncodingMap
public static final HashMap basicEntitiesDecodingMap
Method Detail |
---|
public static final <T> TreeSet<T> emptyTreeSet()
This example illustrates the type-safe way to obtain an empty set:
TreeSet<String> s = Util.emptyTreeSet();
EMPTY_TREESET
public static <K,V> Object getKey(Map<K,V> map, V value)
map
- the Map to searhc onvalue
- the value to search
public static <K,V> Set<K> getKeys(Map<K,V> map, V value)
map
- the Map to searhc onvalue
- the value to search
public static void updateListMap(Map map, Object key, Object value, boolean lazy)
map
- Map to work withkey
- Object key of the Mapvalue
- Object value of the maplazy
- boolean true to create List only after 2 elementspublic static Object getChildListMap(Map map, String key)
map
- the Mapkey
- Object key of the Map
public static List getChildrenListMap(Map map, String key)
map
- the Mapkey
- Object key of the Map
public static List getChildrenListMap(Map map, String[] keys)
map
- the Mapkeys
- Object key of the Map
public static <K,V> Map<V,K> reverseMap(Map<K,V> originalMap, Map<V,K> reverseMap)
K
- V
- originalMap
- reverseMap
-
public static <K,V> Map.Entry<K,V> compareMap(Map<K,V> map1, Map<K,V> map2)
map1
- the first mapmap2
- the second map.
public static <K,V> boolean isMapFilled(Map<K,V> map)
map
- the map.
public static <T> Collection<T> addAll(Collection<T> collection, Enumeration<T> enu)
collection
- enu
-
public static <T> Collection<T> addAll(Collection<T> collection, Iterator<T> it)
collection
- the collectionit
- the iterator
public static String startsWith(String str, Collection<String> coll)
str
- the String to matchcoll
- a Collection of String that may be start of str
public static String getString(Object obj, String defaultValue)
obj
- the objectdefaultValue
- the default value
public static String getString(Object[] array, int index, String defaultValue)
array
- the object arrayindex
- the indexdefaultValue
- the default value
public static Object getObject(Object[] array, int index, Object defaultValue)
public static int getInt(int[] array, int index, int defaultValue)
public static boolean getBoolean(boolean[] array, int index, boolean defaultValue)
public static int getSize(String str)
str
- the String.
public static int getSize(Object[] array)
array
- the array.
public static int getSize(byte[] array)
array
- an array of byte.
public static int getSize(short[] array)
array
- an array of short.
public static int getSize(int[] array)
array
- an array of int.
public static int getSize(long[] array)
array
- an array of long.
public static int getSize(float[] array)
array
- an array of float.
public static int getSize(double[] array)
array
- an array of double.
public static int getSize(boolean[] array)
array
- an array of boolean.
public static int getSize(char[] array)
array
- an array of char.
public static int getSize(Collection coll)
coll
- the collection.
public static int getSize(Map map)
map
- the map.
public static boolean notEmpty(File file)
true
if this File is not
null
nor empty.
file
- the file to test
public static boolean isEmpty(File file)
true
if this file is
null
or empty.
file
- the file to test
public static boolean notEmpty(File file, FileFilter fileFilter)
true
if this File is not
null
nor empty.
file
- the file to testfileFilter
- the filter
public static boolean isEmpty(File file, FileFilter fileFilter)
true
if this file is
null
or empty.
file
- the file to testfileFilter
- the filter
public static boolean notEmpty(Object object)
true
if this object is not
null
nor empty.
object
- the object to test
public static boolean isEmpty(Object object)
true
if this object is
null
or empty.
object
- the object to test
public static boolean notEmpty(int[] array)
true
if this array is not null
nor empty.
array
- the array to test
public static boolean isEmpty(int[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean isEmpty(long[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean isEmpty(byte[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean isEmpty(short[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean isEmpty(float[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean isEmpty(double[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean isEmpty(boolean[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean isEmpty(char[] array)
true
if this array is null
or empty.
array
- the array to test
public static boolean notEmpty(Object[] array)
true
if this array is not
null
nor empty.
array
- the array to test
public static boolean isEmpty(Object[] array)
true
if this array is
null
or empty.
array
- the array to test
public static boolean notEmpty(Object[] array, boolean recursive)
true
if this array is not
null
nor empty.
array
- the array to testrecursive
- check if arrays elements are empty
public static boolean isEmpty(Object[] array, boolean recursive)
true
if this array is
null
or empty.
array
- the array to testrecursive
- check if arrays elements are empty
public static boolean notEmpty(Collection<?> c)
true
if this collection is not
null
nor empty.
c
- the collection to test
public static boolean isEmpty(Collection<?> c)
true
if this collection is
null
or empty.
c
- the collection to test
public static boolean isEmpty(Collection<?> c, boolean deep)
true
if this collection is
null
or empty.
c
- the collection to testdeep
- to call Util.isEmpty on content otherwise check only == null
public static boolean notEmpty(Map<?,?> map)
true
if this map is not
null
nor empty.
map
- the map to test
public static boolean isEmpty(SQLQueryResult sqr)
true
if this SQLQueryResult is
null
or empty.
sqr
- the SQLQueryResult to test
public static boolean notEmpty(SQLQueryResult map)
true
if this SQLQueryResult is not
null
nor empty.
map
- the SQLQueryResult to test
public static boolean isEmpty(Map<?,?> map)
true
if this map is
null
or empty.
map
- the map to test
public static void mainTestEmpty(String[] args)
public static String join(Collection<?> col, String sep)
toString()
method for each iterated
Object.
col
- the collectionsep
- the separator
public static String join(Collection<?> col, String sep, int max, String suffix)
toString()
method for each iterated
Object.
col
- the collectionsep
- the separatormax
- the maximum of item to joinsuffix
- the suffix to add if the maximum has been reached
public static String join(Iterator<?> it, String sep)
toString()
method for each iterated
Object.
it
- the iterator of the collectionsep
- the separator
public static String join(Iterator<?> it, String sep, int max, String suffix)
toString()
method for each iterated
Object.
it
- the iterator of the collectionsep
- the separatormax
- the maximum of item to joinsuffix
- the suffix to add if the maximum has been reached
public static String joinMap(Map<? extends Object,? extends Object> map, String keyValueSep, String entrySep)
Mapmap = new LinkedHashMap (); map.put("simpleobject", "bar"); map.put("stringarray", new String[] { "hi", "hello" } ); List