isql.util
Class StringJoin

java.lang.Object
  extended by isql.util.StringJoin

public class StringJoin
extends java.lang.Object

Joins texts using a separator (comma...)

Author:
SHZ Jun 22, 2007

Field Summary
 boolean first
          If it is the first element, don't precede it with the separator
 char separator
          The separator (comma, semicolon...)
 
Constructor Summary
StringJoin(char separator)
          The constructor
 
Method Summary
<T> void
add(java.util.Collection<T> lstToAdd)
          adds a collection of values to the final text
<T> void
add(T toAdd)
          adds a value to the final text
<T> void
add(T[] arrToAdd)
          adds an array of values to the final text
static
<T> java.lang.String
join(java.util.Collection<T> lstToAdd, char separator)
          builds a text joining a collection of values with a separator
static
<T> java.lang.String
join(T[] arrToAdd, char separator)
          builds a text joining an array of values with a separator
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

separator

public char separator
The separator (comma, semicolon...)


first

public boolean first
If it is the first element, don't precede it with the separator

Constructor Detail

StringJoin

public StringJoin(char separator)
The constructor

Parameters:
separator - the separator (generally a comma or a semicolon)
Method Detail

add

public <T> void add(T toAdd)
adds a value to the final text

Type Parameters:
T - the type of the value to add
Parameters:
toAdd - the value to add to the join

add

public <T> void add(T[] arrToAdd)
adds an array of values to the final text

Type Parameters:
T - the type of the values to add
Parameters:
arrToAdd - the values to add to the join

add

public <T> void add(java.util.Collection<T> lstToAdd)
adds a collection of values to the final text

Type Parameters:
T - the type of the values to add
Parameters:
lstToAdd - the values to add to the join

join

public static <T> java.lang.String join(T[] arrToAdd,
                                        char separator)
builds a text joining an array of values with a separator

Type Parameters:
T - the type of the values to join
Parameters:
arrToAdd - the values to join
separator - the separator
Returns:
the final text

join

public static <T> java.lang.String join(java.util.Collection<T> lstToAdd,
                                        char separator)
builds a text joining a collection of values with a separator

Type Parameters:
T - the type of the values to join
Parameters:
lstToAdd - the values to join
separator - the separator
Returns:
the final text

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object