com.tomgibara.pronto.util
Class Strings

java.lang.Object
  extended by com.tomgibara.pronto.util.Strings

public final class Strings
extends java.lang.Object

A collection of static utility methods for processing strings.

Author:
Tom Gibara

Method Summary
static java.lang.String join(java.lang.Object[] array, java.lang.String delimiter)
          Joins the string representations of an array of objects into a single string, separating them with the supplied delimiter.
static java.util.Map<java.lang.String,java.lang.String> parseProperties(java.lang.String propsStr)
          Constructs a map of strings from a single string as follows: 1) The string is split at each semicolon.
static java.util.List<java.lang.String> splitCommas(java.lang.String str)
          Splits a single string into a list of strings as follows: 1) The string is split at each comma.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

splitCommas

public static java.util.List<java.lang.String> splitCommas(java.lang.String str)
Splits a single string into a list of strings as follows: 1) The string is split at each comma. 2) Each resulting substring is trimmed and added to the list Note that there is no way of escaping a comma within a value.

Parameters:
str - the string to be parsed
Returns:
a list of substrings

parseProperties

public static java.util.Map<java.lang.String,java.lang.String> parseProperties(java.lang.String propsStr)
Constructs a map of strings from a single string as follows: 1) The string is split at each semicolon. 2) Each component is split at a colon into a key and a value. 3) Each key-value pair is trimmed and added to the map This encoding should be superficially familiar to those familiar with CSS style properties. Note that there are no mechanisms for escaping colons and semicolons. Keys may not be duplicated.

Parameters:
propsStr - the string to be parsed
Returns:
a map of string properties

join

public static java.lang.String join(java.lang.Object[] array,
                                    java.lang.String delimiter)
Joins the string representations of an array of objects into a single string, separating them with the supplied delimiter. A zero length array results in an empty string.

Parameters:
array - the array of objects to be joined
delimiter - string to be inserted between array element
Returns:
all the elements of the array concatenated into a single string, never null


Copyright © 2006-2007 Tom Gibara. All Rights Reserved.