org.jpop.util
Class ArrayUtils

java.lang.Object
  extended byorg.jpop.util.ArrayUtils

public class ArrayUtils
extends java.lang.Object

Collection of static methods to manipulate arrays and lists

Version:
1.0
Author:
dsm

Constructor Summary
ArrayUtils()
           
 
Method Summary
static java.lang.String lineArrayToString(java.lang.String[] sa)
          parses a String array to form a String of all its items, one per line
static java.lang.String objectArrayToString(java.lang.Object[] sa)
          parses an Object array to form a String of all its items, one per line
static int present(java.lang.Object[] arr, java.lang.Object item)
          Checks if an item is present in an array
static int presentIgnoreCase(java.lang.String[] arr, java.lang.String item)
          Checks if a String is present in an array of Strings
static void qsort(java.util.List list)
          Sorts a String list using the quicksort algorithm
static java.lang.Object[] stringToLineArray(java.lang.String s)
          parses a String to form an array of all its lines
static java.util.LinkedList stringToListOfWords(java.lang.String s)
          Make a nested list of lines/words out of a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtils

public ArrayUtils()
Method Detail

qsort

public static void qsort(java.util.List list)
                  throws java.lang.ClassCastException
Sorts a String list using the quicksort algorithm

Parameters:
list - The string list to sort
Throws:
java.lang.ClassCastException - If its not possible to cast the object to a string

present

public static int present(java.lang.Object[] arr,
                          java.lang.Object item)
Checks if an item is present in an array

Parameters:
arr - the array
item - the item
Returns:
the index at which the item is or -1

presentIgnoreCase

public static int presentIgnoreCase(java.lang.String[] arr,
                                    java.lang.String item)
Checks if a String is present in an array of Strings

Parameters:
arr - the array
item - the item
Returns:
the index at which the item is or -1

stringToLineArray

public static java.lang.Object[] stringToLineArray(java.lang.String s)
parses a String to form an array of all its lines

Parameters:
s - The string to convert
Returns:
an array of all the lines of s

stringToListOfWords

public static java.util.LinkedList stringToListOfWords(java.lang.String s)
Make a nested list of lines/words out of a string. So that
line one
line two
line three
is provided as input, then the output would be:
[
  ["line", "one"],
  ["line", "two"],
  ["line", "three"]
]

Parameters:
s - The string to convert
Returns:
A list of lists of words

lineArrayToString

public static java.lang.String lineArrayToString(java.lang.String[] sa)
parses a String array to form a String of all its items, one per line

Parameters:
sa - The array to make into a string
Returns:
the string resulting from converting sa

objectArrayToString

public static java.lang.String objectArrayToString(java.lang.Object[] sa)
parses an Object array to form a String of all its items, one per line

Parameters:
sa - The array to make into a string
Returns:
the string resulting from converting sa