com.xmlmind.util
Class StringList

java.lang.Object
  extended by com.xmlmind.util.StringList

public final class StringList
extends java.lang.Object

A collection of utility functions (static methods) operating on lists of Strings.

What is called a list of Strings here is simply an array of Strings. Such array may not contain null elements.


Field Summary
static java.lang.String[] EMPTY_LIST
          A ready-to-use empty list of Strings.
 
Method Summary
static java.lang.String[] append(java.lang.String[] strings, java.lang.String string)
          Inserts a String as last item of a list of Strings.
static boolean contains(java.lang.String[] strings, java.lang.String string)
          Tests if list strings contains String string.
static boolean containsIgnoreCase(java.lang.String[] strings, java.lang.String string)
          Same as contains(java.lang.String[], java.lang.String) but string comparison is case-insensitive.
static int indexOf(java.lang.String[] strings, java.lang.String string)
          Searches String string within list strings.
static java.lang.String[] insertAt(java.lang.String[] strings, java.lang.String string, int index)
          Inserts a String inside a list of Strings.
static java.lang.String[] prepend(java.lang.String[] strings, java.lang.String string)
          Inserts a String as first item of a list of Strings.
static java.lang.String[] remove(java.lang.String[] strings, java.lang.String string)
          Removes a String from a list of Strings.
static java.lang.String[] removeAt(java.lang.String[] strings, int index)
          Removes an item specified by its position from a list of Strings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_LIST

public static final java.lang.String[] EMPTY_LIST
A ready-to-use empty list of Strings.

Method Detail

indexOf

public static int indexOf(java.lang.String[] strings,
                          java.lang.String string)
Searches String string within list strings.

Parameters:
strings - the list to be searched
string - the String to search for
Returns:
the index of the searched string within list or -1 if not found

contains

public static boolean contains(java.lang.String[] strings,
                               java.lang.String string)
Tests if list strings contains String string.

Parameters:
strings - the list to be searched
string - the String to search for
Returns:
true the string is found and false otherwise

containsIgnoreCase

public static boolean containsIgnoreCase(java.lang.String[] strings,
                                         java.lang.String string)
Same as contains(java.lang.String[], java.lang.String) but string comparison is case-insensitive.


insertAt

public static java.lang.String[] insertAt(java.lang.String[] strings,
                                          java.lang.String string,
                                          int index)
Inserts a String inside a list of Strings.

Parameters:
strings - the list where a String is to be inserted
string - the String to insert
index - the insertion index
Returns:
a list containing all the items of list strings plus String string inserted at position index

prepend

public static java.lang.String[] prepend(java.lang.String[] strings,
                                         java.lang.String string)
Inserts a String as first item of a list of Strings.

Parameters:
strings - the list where a String is to be inserted
string - the String to insert
Returns:
a list containing all the items of list strings plus String string inserted at its beginning

append

public static java.lang.String[] append(java.lang.String[] strings,
                                        java.lang.String string)
Inserts a String as last item of a list of Strings.

Parameters:
strings - the list where a String is to be inserted
string - the String to insert
Returns:
a list containing all the items of list strings plus String string inserted at its end

remove

public static java.lang.String[] remove(java.lang.String[] strings,
                                        java.lang.String string)
Removes a String from a list of Strings.

Parameters:
strings - the list where a String is to be removed
string - the String to remove
Returns:
a list containing all the items of list strings less String string if such String is contained in the list; the original list otherwise

removeAt

public static java.lang.String[] removeAt(java.lang.String[] strings,
                                          int index)
Removes an item specified by its position from a list of Strings.

Parameters:
strings - the list where an item is to be removed
index - the position of the item to remove
Returns:
a list containing all the items of list strings less the item at position index