|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.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
|
static int |
FILE_SIZE_UNIT_DIV
|
static String[] |
FILE_SIZE_UNIT_EN_PLAIN_TEXT
|
static HashMap |
FILE_SIZE_UNIT_MAP_HTML
|
static HashMap |
FILE_SIZE_UNIT_MAP_PLAIN_TEXT
|
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 long |
convertFileSizeWidgetElt(String value,
String unit)
convert widget element in file size (use in adminProperties.jsp to manage quotas) |
|
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(boolean skipNull,
boolean trim,
T... array)
|
|
static
|
getArrayList(T... array)
Returns a new ArrayList filled with the given objects (skip null object). |
|
static
|
getBatchSet(Collection<T> coll,
int batchSize)
Convenient method to convert a Collection of object into many smaller collections allowing batch processing. |
|
static boolean |
getBoolean(boolean[] array,
int index,
boolean defaultValue)
|
|
static byte[] |
getBytesUtf8(String string)
Encodes the specified String into a sequence of bytes using the given
UTF-8 charset, storing the result into a
new byte array. |
|
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 Class<?> |
getCommonSuperClass(Class<?>... classes)
Retrieve the common super class of the specified classes. |
|
static String |
getCurrentStackTrace()
Returns the current StackTrace in a String. |
|
static String[] |
getFileSizeWidgetElt(long size)
Convert file size to size and unit (unit are english value of FILE_SIZE_UNIT_EN_PLAIN_TEXT). |
|
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 String |
getStringUtf8(byte[] bytes)
Decode the specified array of bytes into a new String
using the UTF-8 charset. |
|
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)
Deprecated. use HtmlUtil.html2text(String) |
|
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 |
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
public static int FILE_SIZE_UNIT_DIV
public static String[] FILE_SIZE_UNIT_EN_PLAIN_TEXT
public static HashMap FILE_SIZE_UNIT_MAP_PLAIN_TEXT
public static HashMap FILE_SIZE_UNIT_MAP_HTML
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
map
- the map to join akeyValueSep
- the separator to use between key and the valueentrySep
- the separator to use between each entry
public static void listMap(Map<?,?> map)
System.out
.
map
- the map to listpublic static void listMap(Map<?,?> map, PrintStream out)
PrintStream
.
map
- the map to listout
- the PrintStream to use to list the mappublic static void listMap(Map<?,?> map, PrintStream out, String sep)
PrintStream
with the given
separator.
map
- the map to listout
- the PrintStream to use to list the mapsep
- the separatorpublic static void listDictionary(Dictionary<?,?> dict)
System.out
.
dict
- the Dictionnary to listpublic static void listDictionary(Dictionary<?,?> dict, PrintStream out)
PrintStream
.
dict
- the Dictionnary to listout
- the PrintStream to use to list the dictionnarypublic static void listDictionary(Dictionary<?,?> dict, PrintStream out, String sep)
PrintStream
with
the given separator.
dict
- the dictionnary to listout
- the PrintStream to use to list the dictionnarsep
- the separatorpublic static <K,V> Map<K,V> subMap(Map<K,V> map, Set<K> keys)
map
- Map to work onkeys
- Set of key to remove
public static <K,V> Map<? extends K,? extends V> interMap(Map<? extends K,? extends V> map, Set<? extends K> keys)
map
- Map to work onkeys
- Set of key
public static Set<String> prefixSet(Set<String> set, String prefix)
set
- Set of Stringprefix
- a String to prefix
public static Set<?> unionSet(Set<?>... sets)
Set
. The result set does not contains null item.
sets
- an array of Set
Set
(same class as the first set)public static Set unionSet(Set set1, Set set2)
Set
.
set1
- the first Set
set2
- the second Set
Set
public static Set unionSet(Set set1, Set set2, Set set3)
Set
.
set1
- the first Set
set2
- the second Set
set3
- the thrid Set
Set
public static Set interSet(Set... sets)
Set
.
sets
- an array of Set
Set
(same class as the first set, with same comparator for TreeSet)
containing only element presents in all the given set.
does not return a new set if only one set was given, instead return the given set.public static Set interSet(Set set1, Set set2)
Set
.
set1
- the first Set
set2
- the second Set
Set
public static Set interSet(Set set1, Set set2, Set set3)
Set
.
set1
- the first Set
set2
- the second Set
set3
- the thrid Set
Set
public static Set subSet(Set... sets)
Set
. The subset
contains all the elements of the first Set
without
those of the other Set
.
sets
- an array of Set
Set
(same class as the first set)public static Set subSet(Set set1, Set set2)
Set
. The subset
contains all the elements of the first Set
without
those of the second Set
.
set1
- the first Set
set2
- the second Set
Set
public static Set subSet(Set set1, Set set2, Set set3)
Set
. The subset
contains all the elements of the first Set
without
those of the second and third Set
.
set1
- the first Set
set2
- the second Set
set3
- the third Set
Set
public static <T> ArrayList<T> getArrayList(T... array)
T
- any typearray
- a varargs of objects
public static <T> ArrayList<T> getArrayList(boolean skipNull, boolean trim, T... array)
T
- any typeskipNull
- remove null objecttrim
- if true remove the null at the end of the arrayarray
- a varargs of objects
public static <T> HashSet<T> getHashSet(T... array)
T
- any typearray
- a varargs of objects
public static <T> TreeSet<T> getTreeSet(T... array)
T
- any typearray
- a varargs of objects
public static <K,V> HashMap<K,V> getHashMap(K key, V value)
K
- any typeV
- any typekey
- the first key to be addedvalue
- the first value to be added
public static <K,V> HashMap<K,V> getHashMap(Map<K,V> map)
K
- any typeV
- any typemap
- the map to be added
public static <K,V> TreeMap<K,V> getTreeMap(K key, V value)
K
- any typeV
- any typekey
- the first key to be addedvalue
- the first value to be added
public static <K,V> TreeMap<K,V> getTreeMap(Map<K,V> map)
K
- any typeV
- any typemap
- the map to be added
public static <K,V> LinkedHashMap<K,V> getLinkedHashMap(K key, V value)
K
- any typeV
- any typekey
- the first key to be addedvalue
- the first value to be added
public static <K,V> LinkedHashMap<K,V> getLinkedHashMap(Map<K,V> map)
K
- any typeV
- any typemap
- the map to be added
public static <T> T getFirst(Collection<T> coll)
coll
- the collection
public static <T> T getFirst(T[] array)
array
- the array
public static <K,V> void addInMapHashSet(Map<K,Set<V>> map, K key, V value)
map
- the mapkey
- the keyvalue
- the valuepublic static <K,V> void removeFromMapHashSet(Map<K,Set<V>> map, K key, V value)
map
- the mapkey
- the keyvalue
- the valuepublic static <K,V> void addInMapLinkedHashSet(Map<K,LinkedHashSet<V>> map, K key, V value)
map
- the mapkey
- the keyvalue
- the valuepublic static <K,V> void removeFromMapLinkedHashSet(Map<K,LinkedHashSet<V>> map, K key, V value)
map
- the mapkey
- the keyvalue
- the valuepublic static <T> Collection<T> cleanCollection(Collection<T> coll)
coll
- the collection to be cleaned
public static <T> Set<T> collectionToCleanSet(Collection<T> coll)
coll
- the collection
public static Set<String> stringArrayToCleanSet(String[] array)
array
- the array
public static <T> Collection<T> addAll(T[] array, Collection<T> coll)
array
- the array to copy fromcoll
- the collection to copy to
public static <K,V> Map<K,V> putAll(K[] array, Map<K,V> map, V value)
array
- the array to copy frommap
- the collection to copy tovalue
- the value to set
public static int[] swapArray(int[] array, int from, int to, boolean roll, boolean copy)
array
- the arrayfrom
- the location of the first element (< 0 not to swap)to
- the location of the element to swap with (-2 to roll back, -1 to roll forward)roll
- if should roll from end to startcopy
- return a copy of of the array
public static boolean[] swapArray(boolean[] array, int from, int to, boolean roll, boolean copy)
array
- the array of arrayfrom
- the location of the first element (< 0 not to swap)to
- the location of the element to swap with (-2 to roll back, -1 to roll forward)roll
- if should roll from end to startcopy
- return a copy of of the array
public static Object[] swapArray(Object[] array, int from, int to, boolean roll, boolean copy)
array
- the array of arrayfrom
- the location of the first element (< 0 not to swap)to
- the location of the element to swap with (-2 to roll back, -1 to roll forward)roll
- if should roll from end to startcopy
- return a copy of of the array
public static int[] insertArray(int[] array, int index, int elt)
array
- the arrayindex
- the location where the element must be inserted (use -1 to insert ahead and array.length (or greater) to insert at the end)elt
- the element to be inserted
public static boolean[] insertArray(boolean[] array, int index, boolean elt)
array
- the arrayindex
- the location where the element must be inserted (use -1 to insert ahead, array.length (or greater) to insert at the end)elt
- the element to be inserted
public static Object[] insertArray(Object[] array, int index, Object elt)
array
- the arrayindex
- the location where the element must be inserted (use -1 to insert ahead, array.length (or greater) to insert at the end)elt
- the element to be inserted
public static Object[] removeArray(Object[] array, int index)
array
- the array of objectindex
- the location of the element to be removed from
public static Object[] removeArray(Object[] array, Object obj)
array
- the array of objectobj
- the object to be removed
public static int[] removeArray(int[] array, int index)
array
- the array of intindex
- the location of the element to be removed from
public static boolean[] removeArray(boolean[] array, int index)
array
- the array of booleanindex
- the location of the element to be removed from
public static Object[] removeArray(Object[] array, int from, int to)
array
- the array of intfrom
- the location of the first element to be removed fromto
- the location of the last element to be removed from
public static int[] removeArray(int[] array, int from, int to)
array
- the array of intfrom
- the location of the first element to be removed fromto
- the location of the last element to be removed from
public static boolean[] removeArray(boolean[] array, int from, int to)
array
- the array of booleanfrom
- the location of the first element to be removed fromto
- the location of the last element to be removed from
public static boolean isSameContent(boolean[] array1, boolean[] array2)
array1
- a boolean arrayarray2
- a boolean array
public static boolean isSameContent(byte[] array1, byte[] array2)
array1
- a byte arrayarray2
- a byte array
public static boolean isSameContent(char[] array1, char[] array2)
array1
- a char arrayarray2
- a char array
public static boolean isSameContent(double[] array1, double[] array2)
array1
- a double arrayarray2
- a double array
public static boolean isSameContent(float[] array1, float[] array2)
array1
- a float arrayarray2
- a float array
public static boolean isSameContent(int[] array1, int[] array2)
array1
- an int arrayarray2
- an int array
public static boolean isSameContent(long[] array1, long[] array2)
array1
- a long arrayarray2
- a long array
public static boolean isSameContent(short[] array1, short[] array2)
array1
- a short arrayarray2
- a short array
public static boolean isSameContent(Object[] array1, Object[] array2)
array1
- an object arrayarray2
- an object array
public static boolean isSameContent(Set set1, Set set2)
set1
- a Setset2
- a Set
public static boolean isSameContent(List list1, List list2)
list1
- a Listlist2
- a List
public static boolean isSameContent(Map map1, Map map2)
map1
- a Mapmap2
- a Map
public static boolean isSameContent(String str1, String str2)
str1
- a Stringstr2
- a String
public static boolean isSameContent(Date date1, Date date2)
date1
- a Datedate2
- a Date
public static boolean isSameContent(org.jdom.Element elt1, org.jdom.Element elt2)
elt1
- a JDom Elementelt2
- a JDom Element
public static TreeSet getTreeDescendantSet(TreeNode node)
node
- the node
public static Set getTreeDescendantSet(TreeNode node, Set nodeSet)
public static TreeSet getAllChildrenSet(TreeNode node)
node
- the node
public static Set getAllChildren(TreeNode node, Set nodeSet)
node
- the parent nodenodeSet
- the set to fill, if null, returns null
public static boolean isChildNode(TreeNode node, TreeNode child)
node
- the parent nodechild
- the node to seek
public static String getHtmlIcon(String src, String alt)
src
- the image sourcealt
- the iamge title
public static boolean notEmpty(String s)
true
if this string is not null
nor empty (once trimmed).
s
- the string to test
public static boolean isEmpty(String s)
true
if this string is null
or
empty (once trimmed).
s
- the string to test
public static int[] splitToIntArray(String str, String delim)
str
- the String to splitdelim
- the delimiter (same as StringTokenizer)
splitToList(String, String)
,
StringTokenizer
public static String[] split(String str, String delim)
str
- the String to splitdelim
- the delimiter (same as StringTokenizer)
splitToList(String, String)
,
StringTokenizer
public static ArrayList<String> splitToList(String str, String delim)
str
- the String to splitdelim
- the delimiter (same as StringTokenizer)
StringTokenizer
public static String[] split(String str, char delim, String emptyToken)
str
- the String to splitdelim
- the delimiteremptyToken
- the value to used when encounter an empty token
public static String[] splitWithPattern(String text, String pattern)
text: foo [one: 1] [two: 2] bar [three: 3] bar
pattern: "\\[([^\\]]+)\\]"
String[] {"one: 1", "two: 2", "three: 3" }
text: foo [one: 1] [two: 2] bar [three: 3] bar
pattern: "\\[[^\\]]+\\]"
String[] {"[one: 1]", "[two: 2]", "[three: 3]" }
text
- the text to split.pattern
- the pattern to split with.
public static String trimEnd(String str)
str
- the String to trim
public static String getMatch(String regexp, String str, int group)
regexp
- the regular expressionstr
- the String to matchgroup
- the group to match
public static String getMatch(Pattern pattern, String str, int group)
pattern
- java.util.regex.Patternstr
- the String to matchgroup
- the group to match
public static String wordWrap(String str, int width)
Wraps a single line of text, identifying words by ' '
.
New lines will be separated by the system property line separator. Very long words, such as URLs will not be wrapped.
Leading spaces on a new line are stripped. Trailing spaces are not stripped.
Util.wordWrap(null, *) = null Util.wordWrap("", *) = ""
str
- the String to be word wrapped, may be nullwidth
- the column to wrap the words at, less than 1 is treated as 1
null
if null input
TODO: replace with jakarta WordUtils.wrap()public static String wordWrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords)
Wraps a single line of text, identifying words by ' '
.
Leading spaces on a new line are stripped. Trailing spaces are not stripped.
Util.wordWrap(null, *, *, *) = null Util.wordWrap("", *, *, *) = ""
str
- the String to be word wrapped, may be nullwrapLength
- the column to wrap the words at, less than 1 is treated as 1newLineStr
- the string to insert for a new line,
null
uses the system property line separatorwrapLongWords
- true if long words (such as URLs) should be wrapped
null
if null input
TODO: replace with jakarta WordUtils.wrap()public static void mainTestGeneratePassword(String[] args)
public static void mainTestJoin(String[] args)
public static String join(Object[] array, String sep)
array
- the array of String to join.sep
- the separator
public static String join(Object[] array, String sep, int max, String suffix)
array
- the array of String to join.sep
- the separatormax
- the maximum of item to joinsuffix
- the suffix to add if the maximum has been reached
public static String join(int[] array, String sep)
array
- the array of int to join.sep
- the separator
public static String join(int[] array, String sep, int max, String suffix)
array
- the array of int to join.sep
- the separatormax
- the maximum of item to joinsuffix
- the suffix to add if the maximum has been reached
public static String join(String... str)
public static String join(long[] array, String sep)
array
- the array of long to join.sep
- the separator
public static String join(long[] array, String sep, int max, String suffix)
array
- the array of long to join.sep
- the separatormax
- the maximum of item to joinsuffix
- the suffix to add if the maximum has been reached
public static String join(double[] array, String sep)
array
- the array of long to join.sep
- the separator
public static String join(double[] array, String sep, int max, String suffix)
array
- the array of double to join.sep
- the separatormax
- the maximum of item to joinsuffix
- the suffix to add if the maximum has been reached
public static String join(boolean[] array, String sep)
array
- the array of boolean to join.sep
- the separator
public static String join(boolean[] array, String sep, int max, String suffix)
array
- the array of boolean to join.sep
- the separatormax
- the maximum of item to joinsuffix
- the suffix to add if the maximum has been reached
public static String toWordLine(String str)
str
- the string to split
public static String repeat(String pattern, int count)
count
times
pattern
- the patterncount
- the number of times the pattern must be repeated
public static boolean arrayContains(Object[] array, Object key)
array
- the array to be searched.key
- the value to be searched for.
public static String[] trim(String[] array)
array
- the array to be trimmed
public static String[] trimStringArray(String[] array)
array
- the array to be trimmed
public static <T> List<T> trimList(List<T> list)
T
- any typelist
- the list to be trimmed
public static String[] cleanStringArray(String[] array)
array
- the array to be cleaned
public static Object[] cleanObjectArray(Object[] array)
array
- the array to be cleaned
public static String unaccentuate(String str)
str
- the String to unaccentuate.
public static String unaccentuateRegexp(String str)
str
- the String of the regexp to unaccentuate.
public static String recapitalize(String str)
str
- the String to proceed
public static String uncapitalize(String str)
str
- the String to proceed
public static String asciiIndent(String text, int cols, int rows, String tailString)
text
- the text to indentcols
- Number of columnrows
- Number of rowstailString
- the string to append if the text has been truncated
public static String cryptUnix(String str)
str
- the String to encrypt
public static String cryptMD5(String str)
str
- the String to encrypt
public static String encodeBASE64(String str)
str
- the String to encode
public static String encodeBASE64(String str, boolean isChunck)
str
- the string to encodeisChunck
- - if true this encoder will chunk the base64 output into 76 character blocks
public static String decodeBASE64(String str)
str
- the String to decode
public static String encryptDES3(String clearStr) throws StringEncrypter.EncryptionException
StringEncrypter
with an internal key.
clearStr
- the string to encrypt.
StringEncrypter.EncryptionException
- if the encryption could not be performedpublic static String decryptDES3(String encryptedStr) throws StringEncrypter.EncryptionException
StringEncrypter
using same internal key
used by encryptDES3(String)
.
encryptedStr
- the encrypted string to decrypt.
if null or empty, the return
StringEncrypter.EncryptionException
- if the decryption could not be performedpublic static String conceal(String clearStr)
clearStr
- the String to encrypt
public static String reveal(String concealedStr)
concealedStr
- the String to encrypt
public static String buildID(String str, String charRange)
str
- the String to used as base for the IDcharRange
- a perl5 char range. All the chars out of this
range will be ignored (e.g. "0-9a-z_A-Z" to keep only alpha-num
chars)
public static String buildID(String str)
str
- the String to used as base for the ID
public static String buildCamelID(String str)
str
- the String to used as base for the ID
public static String buildUID(String str, Set<String> strSet)
str
- the String to used as base for the IDstrSet
- the set of String of existing ids
public static void mainTestBuildID(String[] args)
public static String escapePercent(String url)
url
- the utf-8 string to escape
public static String escapeRegexp(String string)
string
- the regexp string to be escaped
escapeRegexp(String,boolean)
public static String escapeRegexp(String string, boolean basicRegexp)
string
- the regexp string to be escapedbasicRegexp
- if true convert * and ? to Perl5 regular expression
public static String escapeChars(String str, String charsToEscape)
Example:
Util.escapeChar("ab|cde%fg|hi=j", "|="); // -> ab%7ccde%25fg%7chi%3dj
str
- the stringcharsToEscape
- a string containing all the chararacters to escape
charToEscape
escapedpublic static String unescapeChar(String str)
Example:
Util.unescapeChar("ab%7ccde%25fg%7chij"); // -> ab|cde%fg|hij
str
- the string
charToUnescape
unescapedpublic static String escapeLuceneQuery(String str)
str
- the string to escape
public static void mainTestEscapeLuceneQuery(String[] args)
public static String replace(String str, String match, String rep)
str
- the input Stringmatch
- a Perl5 regexprep
- a Perl5 replace pattern
public static String replace(String str, String pattern)
str
- the input Stringpattern
- the Perl5 substitution pattern (e.g. s!regexp!replace!)
public static String replace(String text, String regexp, RegexpSubstitution substitution) throws org.apache.oro.text.regex.MalformedPatternException
text
- the textregexp
- the regexpsubstitution
- the RegexpSubstitution function called.
org.apache.oro.text.regex.MalformedPatternException
public static String replace(String text, org.apache.oro.text.regex.Pattern pattern, RegexpSubstitution substitution)
text
- the textpattern
- the patternsubstitution
- the RegexpSubstitution function called.
public static String replaceAll(String input, String searchString, String replaceString)
input
- represents input stringsearchString
- represents substring for replacereplaceString
- represents replaced string value
public static String removeBlankLines(String str)
str
- the String to be cleaned
public static String escapeBackslash(String str)
str
- the String to escape
public static String removeJavaScriptQuote(String str)
str
- the String to escape
public static String encodeJavaScriptQuote(String str)
str
- the String to encode
public static String escapeJavaScriptQuote(String str)
str
- the String to escape
public static String escapeJavaStringChar(String str)
str
- the String to escape
public static String getFirstSentences(String text, int limit)
text
- the string to get the first sentence.limit
- how many sentences to get (return the original text if limit <0).
public static void mainSwapArray(String[] args)
public static void mainRemoveArray(String[] args)
public static String truncateHtml(String text, int length, boolean trim)
Use HtmlUtil.truncate(String, int, String)
for advanced HTML support.
text
- the HTML content to be truncatedlength
- the length to keep.trim
- if true trims the input text
public static String truncate(String str, int length)
str
- the String to truncatelength
- the length to truncate to
public static String truncate(String str, int length, String suffix)
str
- the String to truncatelength
- the length to truncate tosuffix
- the suffix to add if the string has been truncated
public static String html2Ascii(String str)
Contrary to the behavior implied by the method name, the returned text may contained unicode characters.
Important limitation note : as of current implementation, the conversion
is performed using regular expression. This processing can lead to StackErrorOverflow
when a large and invalid HTML content is specified. If you don't need to preserve
and convert spaces from the HTML, uses html2text(String)
.
More information on this problem in JIRA issue
JCMS-2628
str
- the html to convert
html2text(String)
public static String html2text(String html)
HtmlUtil.html2text(String)
html
- the html from which text should be extracted
public static String surround(String inside, String begin, String end)
inside
- The text to be surrounded.begin
- The text at the beginning.end
- The text at the end.
public static String surroundWithTag(String inside, String tag)
inside
- The text to be surrounded.tag
- The tag
public static String decodeUrl(String str)
public static String encodeUrl(String s)
URLEncoder.encode(String, String)
,
but space is encoded with %20 and '/' is not encoded.
s
- String
to be translated.
String
.public static String encodeUrl(String s, String enc)
URLEncoder.encode(String, String)
,
but space is encoded with %20 and '/' is not encoded.
s
- String
to be translated.enc
- String
encoding
String
.public static String encodeCookie(String src)
public static String decodeCookie(String src)
public static String isoLatin1ToEntities(String src)
src
- the String to convert
public static String entitiesToIsoLatin1(String src)
src
- the String to convert
public static String encodeHtmlBasicEntities(String src)
src
- the String to convert
public static String decodeHtmlBasicEntities(String src)
src
- the String to convert
public static String performEncoding(String src, HashMap transMap)
src
- the String to converttransMap
- the translation map
public static String performDecoding(String src, HashMap transMap)
src
- the String to converttransMap
- the translation map
public static String performEncodeDecode(String src, HashMap transMap, boolean decode)
src
- the String to converttransMap
- the translation mapdecode
- if true use values else use keys
public static String encodeIntArray(int[] array)
public static int[] decodeIntArray(String param)
public static String encodeIntArray(int[] array, char separator)
public static int[] decodeIntArray(String param, char separator)
public static String encodeStringArray(String[] array)
public static String[] decodeStringArray(String param)
public static String encodeStringArray(String[] array, char separator)
public static String[] decodeStringArray(String param, char separator)
public static String encodeObject(Object obj)
obj
- the object to be encoded
public static Object decodeObject(String encoded)
encoded
- the String that contains the encoded object
public static boolean isNumber(String str)
str
- the String to be checked
public static int[] toIntArray(Object[] objs, int def)
String
or a Integer
) to a int
objs
- the object array to convertdef
- default int value to use is object is empty, not a String
nor a Integer
int[]
or null if objs is nulltoInt(Object, int)
public static int toInt(Object obj, int def)
String
or a Integer
) to a int
obj
- the object to convertdef
- default int value to use is object is empty, not a String
nor a Integer
int
public static float toFloat(Object obj, float def)
String
or a Float
) to a float
obj
- the object to convertdef
- default float value to use is object is empty, not a String
nor a Float
float
public static byte toByte(Object obj, byte def)
String
or a Byte
) to a byte
obj
- the object to convertdef
- default byte value to use is object is empty, not a String
nor a Byte
byte
public static short toShort(Object obj, short def)
String
or a Short
) to a short
obj
- the object to convertdef
- default short value to use is object is empty, not a String
nor a Short
short
public static long toLong(Object obj, long def)
String
or a Long
) to a long
obj
- the object to convertdef
- default long value to use is object is empty, not a String
nor a Long
long
public static double toDouble(Object obj, double def)
String
or a Double
) to a double
obj
- the object to convertdef
- default double value to use is object is empty, not a String
nor a Double
double
public static char toChar(Object obj, char def)
String
or a Character
) to a char
obj
- the object to convertdef
- default char value to use is object is empty, not a String
nor a Character
char
public static boolean toBoolean(Object obj, boolean def)
obj
- the object to convertdef
- default boolean value to use is object is empty, not a String
nor a Boolean
boolean
public static Date toDate(String str, String format, Locale loc, Date def)
str
- the String to parseformat
- the date Format (can be null)loc
- the Locale tio use (can be null)def
- the default Date to return if errors append.
public static Locale toLocale(String str, Locale def)
public static String formatSize(long size, Locale locale)
size
- the size to formatlocale
- the locale to use for the unit
public static String formatFileSize(long size)
The format used is plain text.
size
- the size to format
public static String formatFileSize(long size, Locale locale)
The format used is HTML (with detailled abbreviations).
size
- the size to formatlocale
- the locale to use for the unit
public static String formatFileSize(long size, Locale locale, boolean htmlDisplay)
size
- the size to formatlocale
- the locale to use for the unithtmlDisplay
- if true, uses an html format, with detailled abbreviation, otherwise, use only plain text
public static String[] getFileSizeWidgetElt(long size)
size
- the real size
public static long convertFileSizeWidgetElt(String value, String unit)
value
- unit
-
@Deprecated public static String formatDuration(Date begin, Date end)
DateUtil.formatDuration(Date,Date)
instead
begin
- the begin dateend
- the end date
@Deprecated public static String formatDuration(Date begin, Date end, Locale locale)
DateUtil.formatDuration(Date,Date,Locale)
instead
begin
- the begin dateend
- the end datelocale
- the locale to use
@Deprecated public static String formatDuration(long time)
DateUtil.formatDuration(long)
instead
time
- the duration to format (in milliseconds)
@Deprecated public static String formatDuration(long time, Locale locale)
DateUtil.formatDuration(long,Locale)
instead
time
- the duration to format (in milliseconds)locale
- the locale to use
@Deprecated public static void mainTestFormatDuration(String[] args)
DateUtil.mainTestFormatDuration(String[])
instead
@Deprecated public static long roundDuration(long duration)
DateUtil.roundDuration(long)
instead
As of current implementation, the following rules are applied
Util.formatDuration(Util.roundDuration(38000)); // 38 s => 38 s Util.formatDuration(Util.roundDuration(76000)); // 1 min 16 s => 1 min 16 s Util.formatDuration(Util.roundDuration(1564512)); // 26 min 4 s => 26 min Util.formatDuration(Util.roundDuration(5890000)); // 1 h 38 min 10 s => 1 h 38 min Util.formatDuration(Util.roundDuration(33165000)); // 9 h 12 min 45 s => 9 h Util.formatDuration(Util.roundDuration(35025000)); // 9 h 43 min 45 s => 10 h Util.formatDuration(Util.roundDuration(130993000)); // 1 day 12 h 23 min 13 s => 1 day 12 h Util.formatDuration(Util.roundDuration(236158000)); // 2 days 17 h 35 min 58 s => 2 days 18 h Util.formatDuration(Util.roundDuration(731675000)); // 8 days 11 h 14 min 35 s => 8 days Util.formatDuration(Util.roundDuration(5934547000L)); // 68 days 16 h 29 min 7 s => 68 days
duration
- a duration in milliseconds
public static String generatePassword()
public static String generatePassword(int length)
length
- the length of the password to be generated
public static String generatePronounceablePassword(int pwdLength)
pwdLength
- The length of the password to be generated
public static String getStackTrace(Throwable throwable)
throwable
- the exception or throwable to print
public static String getCurrentStackTrace()
public static boolean forceFullGarbageCollection(long timeout)
timeout
- in millisecond if timeout is reached stop the GC forcing
public static String getClassShortName(Object object)
object
- the object
public static String getClassShortName(Class clazz)
clazz
- the class
public static String getClassShortName(String fullname)
fullname
- the full class name
public static Set<String> getClassFiles(String realPath, String fullname, boolean java)
realPath
- the Webapp realpath (i.e. C:/project/appserver/webapps/webapp-name)fullname
- the Class fullname (i.e. com.jalios.jcms.Category)java
- boolean true to include java file
public static String getClassNameFromFilename(String filename)
filename
- the filename of the class
null
if an error occurred.public static Class getFirstCommonClass(Class parent, Class child)
parent
- child
-
public static List getSuperclassList(Class clazz, Class ancestor, boolean addClass, boolean addAncestor)
clazz
- the class to extract the ancestorsancestor
- the greater ancestoraddClass
- if true, add the class in the listaddAncestor
- if true, add the ancestor in the list
public static String escapeHtml(String str)
str
- the string to escape
public static String escapeHtmlQuote(String str)
str
- the String to escape
public static String escapeInputQuote(String str)
str
- the string to escape, e.g. : 'Hello "World" !
'
Hello "World" !
'public static int indexOf(Object elem, Object[] array)
elem
- an object.array
- an array that may contain elem
Object.equals(Object)
@Deprecated public static String formatIso8601Date(Date date)
DateUtil.formatIso8601Date(Date)
instead
1999-01-01T14:07:00+0100
).
date
- the date to format.
DateUtil.parseIso8601Date(String)
@Deprecated public static Date parseIso8601Date(String source)
DateUtil.parseIso8601Date(String)
instead
1999-01-01T14:07:00+0100
).
source
- the string to be parsed
DateUtil.formatIso8601Date(Date)
@Deprecated public static String formatW3cDate(Date date)
DateUtil.formatW3cDate(Date)
instead
1999-01-01T14:07:00+01:00
).
date
- the date to format.
DateUtil.parseW3cDate(String)
@Deprecated public static Date parseW3cDate(String source)
DateUtil.parseW3cDate(String)
instead
1999-01-01T14:07:00+01:00
).
source
- the string to be parsed
DateUtil.formatW3cDate(Date)
@Deprecated public static String formatRfc822Date(Date date)
DateUtil.formatRfc822Date(Date)
instead
Fri, 1 Jan 1999 14:07:00 +0100
).
For more details, see http://www.w3.org/Protocols/rfc822/rfc822.txt section 5.1
date
- the date to format.
@Deprecated public static Date parseRfc822Date(String source)
DateUtil.parseRfc822Date(String)
instead
source
- the string to be parsed
@Deprecated public static String formatNoSpaceDate(Date date)
DateUtil.formatNoSpaceDate(Date)
instead
date
- the date to format.
@Deprecated public static Date parseNoSpaceDate(String source)
DateUtil.parseNoSpaceDate(String)
instead
source
- the string to be parsed
@Deprecated public static boolean isToday(Date date)
DateUtil.isToday(Date)
instead
date
- the date to check
@Deprecated public static boolean isYesterday(Date date)
DateUtil.isYesterday(Date)
instead
date
- the date to check
@Deprecated public static boolean isTomorrow(Date date)
DateUtil.isTomorrow(Date)
instead
date
- the date to check
@Deprecated public static boolean isSameDay(Date date1, Date date2)
DateUtil.isSameDay(Date,Date)
instead
date1
- the first date to checkdate2
- the second date to check
public static boolean hasAppenderDefined(org.apache.log4j.Logger logger)
Logger
has any appender defined.
logger
- the Logger to check
@Deprecated public static Date getNewDateWithoutMillis()
DateUtil.getNewDateWithoutMillis()
instead
public static boolean validateRegexp(String regexp)
regexp
- The pattern to validate
public static String reduceBlankLines(String text)
text
- the original text
public static String randomString(int length)
public static int exec(String... cmdarray) throws IOException, InterruptedException
cmdarray
- array containing the command to call and its arguments.
IOException
InterruptedException
public static int exec(String[] cmdarray, OutputStream stdout, OutputStream stderr) throws IOException, InterruptedException
cmdarray
- array containing the command to call and its arguments.stdout
- the OutputStream for stdout (ignored if null)stderr
- the OutputStream for stderr (ignored if null)
IOException
InterruptedException
public static int exec(String[] cmdarray, StringBuilder stdout, StringBuilder stderr) throws IOException, InterruptedException
cmdarray
- array containing the command to call and its arguments.stdout
- the result of the stdout (ignored if null)stderr
- the result of the stderr (ignored if null)
IOException
InterruptedException
public static Class<?> getCommonSuperClass(Class<?>... classes)
classes
- the classes for which superclass must be found, must not be null nor empty
public static byte[] getBytesUtf8(String string)
String
into a sequence of bytes using the given
UTF-8 charset, storing the result into a
new byte array.
This method is provided as convenient method and as a workaround for
performance bottleneck of Java native string.getBytes("UTF-8");
method.
See issue issue http://issues.jalios.com/browse/JCMS-2570 for more information.
string
- The string to be encoded
public static String getStringUtf8(byte[] bytes)
String
using the UTF-8 charset.
The length of the new String
is a function of the charset, and
hence may not be equal to the length of the byte array.
This method is provided as convenient method and as a workaround for
performance bottleneck of Java native new String(bytes, "UTF-8")
method.
See issue issue http://issues.jalios.com/browse/JCMS-2570 for more information.
bytes
- The bytes to be decoded into characters
public static <T> Set<Set<T>> getBatchSet(Collection<T> coll, int batchSize)
Example :
List<String> abcdeList = Arrays.asList(new String[] {"a", "b", "c", "d", "e"}); Set<Set<String>> batchSet = Util.getBatchSet(abcdeList, 2); assertEquals(3, batchSet.size()); Iterator<Set<String>> batchIterator = batchSet.iterator(); assertEquals("a,b", Util.join(batchIterator.next(), ",")); assertEquals("c,d", Util.join(batchIterator.next(), ",")); assertEquals("e", Util.join(batchIterator.next(), ""));
coll
- a collection of object, may be null (empty set returned)batchSize
- the size of subset to be create, must be a positive integer otherwise
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |