ezvcard.util
Class StringUtils

java.lang.Object
  extended by ezvcard.util.StringUtils

public class StringUtils
extends Object

Helper class for dealing with vCard strings.

Author:
Michael Angstadt

Nested Class Summary
static interface StringUtils.JoinCallback<T>
          Callback interface used with various VCardStringUtils.join() methods.
static interface StringUtils.JoinMapCallback<K,V>
          Callback interface used with the join(Map, String, JoinMapCallback) method.
 
Field Summary
static String NEWLINE
          The local computer's newline character sequence.
 
Method Summary
static
<T> String
join(Collection<T> collection, String delimiter)
          Joins a collection of values into a delimited list.
static
<T> void
join(Collection<T> collection, String delimiter, StringBuilder sb)
          Joins a collection of values into a delimited list.
static
<T> void
join(Collection<T> collection, String delimiter, StringBuilder sb, StringUtils.JoinCallback<T> join)
          Joins a collection of values into a delimited list.
static
<T> String
join(Collection<T> collection, String delimiter, StringUtils.JoinCallback<T> join)
          Joins a collection of values into a delimited list.
static
<K,V> String
join(Map<K,V> map, String delimiter, StringUtils.JoinMapCallback<K,V> join)
          Joins a map into a delimited list.
static String ltrim(String string)
          Trims the whitespace off the left side of a string.
static String rtrim(String string)
          Trims the whitespace off the right side of a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NEWLINE

public static final String NEWLINE
The local computer's newline character sequence.

Method Detail

ltrim

public static String ltrim(String string)
Trims the whitespace off the left side of a string.

Parameters:
string - the string to trim
Returns:
the trimmed string

rtrim

public static String rtrim(String string)
Trims the whitespace off the right side of a string.

Parameters:
string - the string to trim
Returns:
the trimmed string

join

public static <T> String join(Collection<T> collection,
                              String delimiter)
Joins a collection of values into a delimited list.

Parameters:
collection - the collection of values
delimiter - the delimiter (e.g. ",")
Returns:
the final string

join

public static <T> void join(Collection<T> collection,
                            String delimiter,
                            StringBuilder sb)
Joins a collection of values into a delimited list.

Parameters:
collection - the collection of values
delimiter - the delimiter (e.g. ",")
sb - the string builder to append onto

join

public static <T> String join(Collection<T> collection,
                              String delimiter,
                              StringUtils.JoinCallback<T> join)
Joins a collection of values into a delimited list.

Parameters:
collection - the collection of values
delimiter - the delimiter (e.g. ",")
join - callback function to call on every element in the collection
Returns:
the final string

join

public static <T> void join(Collection<T> collection,
                            String delimiter,
                            StringBuilder sb,
                            StringUtils.JoinCallback<T> join)
Joins a collection of values into a delimited list.

Parameters:
collection - the collection of values
delimiter - the delimiter (e.g. ",")
sb - the string builder to append onto
join - callback function to call on every element in the collection

join

public static <K,V> String join(Map<K,V> map,
                                String delimiter,
                                StringUtils.JoinMapCallback<K,V> join)
Joins a map into a delimited list.

Parameters:
map - the map
delimiter - the delimiter (e.g. ",")
join - callback function to call on every element in the collection
Returns:
the final string


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.