Package org.apache.ofbiz.base.util
Class UtilMisc
java.lang.Object
org.apache.ofbiz.base.util.UtilMisc
UtilMisc - Misc Utility Functions
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K> BigDecimal
addToBigDecimalInMap
(Map<K, Object> theMap, K mapKey, BigDecimal addNumber) Assuming theMap not null; if null will throw a NullPointerExceptionstatic <K> void
addToDoubleInMap
(Map<K, Object> theMap, K key, Double value) Adds value to the key entry in theMap, or creates a new one if not already therestatic <K,
V> void addToListInMap
(V element, Map<K, Object> theMap, K listKey) static <K,
V> void addToSetInMap
(V element, Map<K, Set<V>> theMap, K setKey) static <K,
V> void addToSortedSetInMap
(V element, Map<K, Set<V>> theMap, K setKey) Returns a List of available locales sorted by display namestatic <T> Set<T>
collectionToSet
(Collection<T> c) static String
collectionToString
(Collection<? extends Object> values, String delimiter) Generates a String from given values delimited by delimiter.static <T> int
compare
(Comparable<T> obj1, T obj2) static <E> int
static void
static Locale
ensureLocale
(Object localeObject) The input can be a String, Locale, or even null and a valid Locale will always be returned; if nothing else works, returns the default locale.List of domains or IP addresses to be checked to prevent Host Header Injection, no spaces after commas, no wildcard, can be extended of course...static <K,
V> List<V> getListFromMap
(Map<K, Object> outerMap, K key) Assuming outerMap not null; if null will throw a NullPointerExceptionstatic <K,
IK, V> Map<IK, V> getMapFromMap
(Map<K, Object> outerMap, K key) Assuming outerMap not null; if null will throw a NullPointerExceptionstatic int
getViewLastIndex
(int listSize, int viewSize) static <T extends Throwable>
Tstatic <V> void
makeArrayListSerializable
(ArrayList<Object> arrayList) This change an ArrayList to be Serializable by removing all entries that are not Serializable.static <T> List<T>
makeListWritable
(Collection<? extends T> col) static <V> void
makeMapSerializable
(Map<String, V> map) This change a Map to be Serializable by removing all entries with values that are not Serializable.static <K,
V> Map<K, V> makeMapWritable
(Map<K, ? extends V> map) static Locale
parseLocale
(String localeString) Parse a locale string Locale objectstatic <K,
V> String static <T> T
removeFirst
(List<T> lst) Sort a List of Maps by specified consistent keys.splitPhoneNumber
(String phoneNumber, Delegator delegator) static void
staticWait
(long timeout) Deprecated.use Thread.sleep()static double
Converts anObject
to adouble
.static Double
toDoubleObject
(Object obj) Converts anObject
to aDouble
.static int
Converts anObject
to anint
.static Integer
toIntegerObject
(Object obj) Converts anObject
to anInteger
.static <T> Iterator<T>
toIterator
(Collection<T> col) Get an iterator from a collection, returning null if collection is nullstatic <T> List<T>
toList
(T... data) Creates a list from passed objects.static <T> List<T>
toListArray
(T[] data) static long
Converts anObject
to along
.static Long
toLongObject
(Object obj) Converts anObject
to aLong
.static <K,
V> Map<K, V> Creates a pseudo-literal map corresponding to key-values.static <K,
V> Map<K, V> Creates a pseudo-literal map corresponding to key-values.static <T> Set<T>
toSet
(Collection<T> collection) static <T> Set<T>
toSet
(T... data) Create a set from the passed objects.static <T> Set<T>
toSetArray
(T[] data)
-
Method Details
-
initCause
-
compare
-
compare
-
toIterator
Get an iterator from a collection, returning null if collection is null- Parameters:
col
- The collection to be turned in to an iterator- Returns:
- The resulting Iterator
-
toMap
Creates a pseudo-literal map corresponding to key-values.- Parameters:
kvs
- the key-value pairs- Returns:
- the corresponding map.
- Throws:
IllegalArgumentException
- when the key-value list is not even.
-
toMap
Creates a pseudo-literal map corresponding to key-values.- Parameters:
constructor
- the constructor used to instantiate the mapkvs
- the key-value pairs- Returns:
- the corresponding map.
- Throws:
IllegalArgumentException
- when the key-value list is not even.
-
printMap
-
makeListWritable
-
makeMapWritable
-
makeMapSerializable
This change a Map to be Serializable by removing all entries with values that are not Serializable.- Type Parameters:
V
-- Parameters:
map
-
-
makeArrayListSerializable
This change an ArrayList to be Serializable by removing all entries that are not Serializable.- Parameters:
arrayList
-
-
sortMaps
public static List<Map<Object,Object>> sortMaps(List<Map<Object, Object>> listOfMaps, List<? extends String> sortKeys) Sort a List of Maps by specified consistent keys.- Parameters:
listOfMaps
- List of Map objects to sort.sortKeys
- List of Map keys to sort by.- Returns:
- a new List of sorted Maps.
-
getMapFromMap
Assuming outerMap not null; if null will throw a NullPointerException -
getListFromMap
Assuming outerMap not null; if null will throw a NullPointerException -
addToBigDecimalInMap
public static <K> BigDecimal addToBigDecimalInMap(Map<K, Object> theMap, K mapKey, BigDecimal addNumber) Assuming theMap not null; if null will throw a NullPointerException -
removeFirst
-
collectionToSet
-
collectionToString
Generates a String from given values delimited by delimiter.- Parameters:
values
-delimiter
-- Returns:
- String
-
toSet
Create a set from the passed objects.- Parameters:
data
-- Returns:
- theSet
-
toSet
-
toSetArray
-
toList
Creates a list from passed objects.- Parameters:
data
-- Returns:
- list
-
toListArray
-
addToListInMap
-
addToSetInMap
-
addToSortedSetInMap
-
toDouble
Converts anObject
to adouble
. Returns zero if conversion is not possible.- Parameters:
obj
- Object to convert- Returns:
- double value
-
toDoubleObject
Converts anObject
to aDouble
. Returnsnull
if conversion is not possible.- Parameters:
obj
- Object to convert- Returns:
- Double
-
toInteger
Converts anObject
to anint
. Returns zero if conversion is not possible.- Parameters:
obj
- Object to convert- Returns:
- int value
-
toIntegerObject
Converts anObject
to anInteger
. Returnsnull
if conversion is not possible.- Parameters:
obj
- Object to convert- Returns:
- Integer
-
toLong
Converts anObject
to along
. Returns zero if conversion is not possible.- Parameters:
obj
- Object to convert- Returns:
- long value
-
toLongObject
Converts anObject
to aLong
. Returnsnull
if conversion is not possible.- Parameters:
obj
- Object to convert- Returns:
- Long
-
addToDoubleInMap
Adds value to the key entry in theMap, or creates a new one if not already there- Parameters:
theMap
-key
-value
-
-
parseLocale
Parse a locale string Locale object- Parameters:
localeString
- The locale string (en_US)- Returns:
- Locale The new Locale object or null if no valid locale can be interpreted
-
ensureLocale
The input can be a String, Locale, or even null and a valid Locale will always be returned; if nothing else works, returns the default locale.- Parameters:
localeObject
- An Object representing the locale
-
availableLocales
Returns a List of available locales sorted by display name -
getHostHeadersAllowed
List of domains or IP addresses to be checked to prevent Host Header Injection, no spaces after commas, no wildcard, can be extended of course...- Returns:
- List of domains or IP addresses to be checked to prevent Host Header Injection,
-
staticWait
Deprecated.use Thread.sleep()- Throws:
InterruptedException
-
copyFile
- Throws:
IOException
-
getViewLastIndex
public static int getViewLastIndex(int listSize, int viewSize) -
splitPhoneNumber
-