org.omnifaces.el.functions
Class Converters

java.lang.Object
  extended by org.omnifaces.el.functions.Converters

public final class Converters
extends java.lang.Object

Collection of EL functions for data conversion.

Author:
Bauke Scholtz

Method Summary
static java.lang.String joinArray(java.lang.Object array, java.lang.String separator)
          Joins all elements of the given array to a single string, separated by the given separator.
static
<E> java.lang.String
joinCollection(java.util.Collection<E> collection, java.lang.String separator)
          Joins all elements of the given collection to a single string, separated by the given separator.
static
<K,V> java.lang.String
joinMap(java.util.Map<K,V> map, java.lang.String pairSeparator, java.lang.String entrySeparator)
          Joins all elements of the given map to a single string, separated by the given key-value pair separator and entry separator.
static
<K,V> java.util.List<java.util.Map.Entry<K,V>>
mapToList(java.util.Map<K,V> map)
          Converts a Map<K, V> to a List<Map.Entry<K, V>>.
static java.lang.String printStackTrace(java.lang.Throwable exception)
          Print the stack trace of the given exception.
static
<E> java.util.List<E>
setToList(java.util.Set<E> set)
          Converts a Set<E> to a List<E>.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setToList

public static <E> java.util.List<E> setToList(java.util.Set<E> set)
Converts a Set<E> to a List<E>. Useful when you want to iterate over a Set in for example <ui:repeat>.

Parameters:
set - The set to be converted to list of its entries.
Returns:
The converted list.

mapToList

public static <K,V> java.util.List<java.util.Map.Entry<K,V>> mapToList(java.util.Map<K,V> map)
Converts a Map<K, V> to a List<Map.Entry<K, V>>. Useful when you want to iterate over a Map in for example <ui:repeat>. Each of the entries has the usual getKey() and getValue() methods.

Parameters:
map - The map to be converted to list of its entries.
Returns:
The converted list.

joinArray

public static java.lang.String joinArray(java.lang.Object array,
                                         java.lang.String separator)
Joins all elements of the given array to a single string, separated by the given separator.

Parameters:
array - The array to be joined.
separator - The separator to be used. If null, then it defaults to empty string.
Returns:
All elements of the given array as a single string, separated by the given separator.
Throws:
java.lang.IllegalArgumentException - When the given array is not an array at all.
Since:
1.3

joinCollection

public static <E> java.lang.String joinCollection(java.util.Collection<E> collection,
                                                  java.lang.String separator)
Joins all elements of the given collection to a single string, separated by the given separator.

Parameters:
collection - The collection to be joined.
separator - The separator to be used. If null, then it defaults to empty string.
Returns:
All elements of the given collection as a single string, separated by the given separator.
Since:
1.3

joinMap

public static <K,V> java.lang.String joinMap(java.util.Map<K,V> map,
                                             java.lang.String pairSeparator,
                                             java.lang.String entrySeparator)
Joins all elements of the given map to a single string, separated by the given key-value pair separator and entry separator.

Parameters:
map - The map to be joined.
pairSeparator - The key-value pair separator to be used. If null, then it defaults to empty string.
entrySeparator - The entry separator to be used. If null, then it defaults to empty string.
Returns:
All elements of the given map as a single string, separated by the given separators.
Since:
1.3

printStackTrace

public static java.lang.String printStackTrace(java.lang.Throwable exception)
Print the stack trace of the given exception.

Parameters:
exception - The exception to print the stack trace for.
Returns:
The printed stack trace.