info.javelot.functionalj.util
Class Strings

java.lang.Object
  extended byinfo.javelot.functionalj.util.Strings

public final class Strings
extends Object

Methods concerning Strings.

Author:
Copyright © 2006 Frederic Daoud

Field Summary
static Function1 length
          Function that returns the length of a String.
 
Method Summary
static String concat(Collection p_coll)
          Concatenates a Collection into a String, by concatenating together the String representations of each object in the collection.
static String concat(Object[] p_array)
          Version of concat(Collection) that accepts an array.
static List intersperse(String p_string, List p_list)
          Intersperses a String in between a List of Strings, to return a new List of Strings.
static List intersperse(String p_string, String[] p_strings)
          Version of intersperse(String, List) that accepts an array.
static int length(String p_string)
          Returns the size of a string, returning zero if the string is null.
static String toString(Object[] p_array)
          Returns a String representation of an array of objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

public static Function1 length
Function that returns the length of a String. If the string is null, the function returns 0.

Method Detail

intersperse

public static List intersperse(String p_string,
                               List p_list)
Intersperses a String in between a List of Strings, to return a new List of Strings. For example, intersperse(":", ["AB", "C", "DE", "F"]) returns ["AB", ":", "C", ":", "DE", ":", "F"].

Using concat(Collection) on that result will return "AB:C:DE:F".

Parameters:
p_string - the string to intersperse into the list of strings.
p_list - the list of strings.

intersperse

public static List intersperse(String p_string,
                               String[] p_strings)
Version of intersperse(String, List) that accepts an array.

See Also:
intersperse(String, List)

concat

public static String concat(Collection p_coll)
Concatenates a Collection into a String, by concatenating together the String representations of each object in the collection.

Parameters:
p_coll - the collection to be concatenated.
Returns:
a single String which consists of the String representations of the objects from the collection, concatenated together.

concat

public static String concat(Object[] p_array)
Version of concat(Collection) that accepts an array.


toString

public static String toString(Object[] p_array)
Returns a String representation of an array of objects.

Parameters:
p_array - the array for which to construct a String representation.
Returns:
a String of the form "[A, B, C, D]", with a String representation of each object in the array.

length

public static int length(String p_string)
Returns the size of a string, returning zero if the string is null.

Parameters:
p_string - the string for which to return the size.
Returns:
the size of the string, or 0 if the string is null.