com.flexive.shared
Class FxArrayUtils

java.lang.Object
  extended by com.flexive.shared.FxArrayUtils

public class FxArrayUtils
extends java.lang.Object

Utility functions for arrays.

Version:
$Rev: 629 $
Author:
Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Constructor Summary
FxArrayUtils()
           
 
Method Summary
static int[] addElement(int[] list, int element)
          Adds a element to the end of the array, if it is not already contained.
static long[] addElement(long[] list, long element)
          Adds a element to the end of the array, if it is not already contained.
static
<T> T[]
addElement(T[] list, T element, boolean unique)
          Adds a element to the end of the array.
static boolean containsElement(java.lang.String[] list, java.lang.String element, boolean ignoreCase)
          Return true if the list contains the given element.
static int indexOf(java.lang.String[] list, java.lang.String element, boolean ignoreCase)
          Returns the first occurence of the given element.
static int[] removeDuplicates(int[] list)
          Removes dupicated entries from the list.
static long[] removeDuplicates(long[] list)
          Removes dupicated entries from the list.
static int[] toIntArray(java.lang.String list, char separator)
          Converts a list with integer items separated by a specific delimeter to a array.
static long[] toLongArray(java.lang.String list, char separator)
          Converts a list with long items separated by a specific delimeter to a array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FxArrayUtils

public FxArrayUtils()
Method Detail

toIntArray

public static int[] toIntArray(java.lang.String list,
                               char separator)
                        throws FxInvalidParameterException
Converts a list with integer items separated by a specific delimeter to a array.

A empty array will be returned if the list is null or a empty string.

Parameters:
list - the list
separator - the separator character
Returns:
the array
Throws:
FxInvalidParameterException - if the list can not be converted, the exception's getParameterName() function will return the token that caused the exception

toLongArray

public static long[] toLongArray(java.lang.String list,
                                 char separator)
                          throws FxInvalidParameterException
Converts a list with long items separated by a specific delimeter to a array.

A empty array will be returned if the list is null or a empty string.

Parameters:
list - the list
separator - the separator character
Returns:
the array
Throws:
FxInvalidParameterException - if the list can not be converted, the exception's getParameterName() function will return the token that caused the exception

removeDuplicates

public static int[] removeDuplicates(int[] list)
Removes dupicated entries from the list.

Parameters:
list - the list
Returns:
the list without any duplicated entries

removeDuplicates

public static long[] removeDuplicates(long[] list)
Removes dupicated entries from the list.

Parameters:
list - the list
Returns:
the list without any duplicated entries

addElement

public static int[] addElement(int[] list,
                               int element)
Adds a element to the end of the array, if it is not already contained.

Parameters:
list - original list
element - the element to add
Returns:
the new list

addElement

public static long[] addElement(long[] list,
                                long element)
Adds a element to the end of the array, if it is not already contained.

Parameters:
list - original list
element - the element to add
Returns:
the new list

addElement

public static <T> T[] addElement(T[] list,
                                 T element,
                                 boolean unique)
Adds a element to the end of the array.

Parameters:
list - original list
element - the element to add
unique - true if the element should only be added if it is not already contained
Returns:
the new list

containsElement

public static boolean containsElement(java.lang.String[] list,
                                      java.lang.String element,
                                      boolean ignoreCase)
Return true if the list contains the given element.

Parameters:
list - the list
element - the element to look for
ignoreCase - if set to false the compare is done case sensitive
Returns:
true if the list contains the given element

indexOf

public static int indexOf(java.lang.String[] list,
                          java.lang.String element,
                          boolean ignoreCase)
Returns the first occurence of the given element.

Parameters:
list - the list
element - the element to look for
ignoreCase - if set to false the compare is done case sensitive
Returns:
true the first position, or -1 if the element was not found