org.glite.authz.common.util
Class Strings

java.lang.Object
  extended by org.glite.authz.common.util.Strings

public final class Strings
extends java.lang.Object

Helper class for working with Strings.


Method Summary
static boolean isEmpty(java.lang.String s)
          A "safe" null/empty check for strings.
static
<T> boolean
safeEquals(T s1, T s2)
          Compares two strings for equality, allowing for nulls.
static java.lang.String safeTrim(java.lang.String s)
          A safe string trim that handles nulls.
static java.lang.String safeTrimOrNullString(java.lang.String s)
          Removes preceding or proceeding whitespace from a string or return null if the string is null or of zero length after trimming (i.e.
static java.util.List<java.lang.String> toList(java.lang.String valuesStr, java.lang.String delimiter)
          Creates a list of strings from delimited string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEmpty

public static boolean isEmpty(java.lang.String s)
A "safe" null/empty check for strings.

Parameters:
s - The string to check
Returns:
true if the string is null or the trimmed string is length zero

safeEquals

public static <T> boolean safeEquals(T s1,
                                     T s2)
Compares two strings for equality, allowing for nulls.

Type Parameters:
T - type of object to compare
Parameters:
s1 - The first operand
s2 - The second operand
Returns:
true if both are null or both are non-null and the same string value

safeTrim

public static java.lang.String safeTrim(java.lang.String s)
A safe string trim that handles nulls.

Parameters:
s - the string to trim
Returns:
the trimmed string or null if the given string was null

safeTrimOrNullString

public static java.lang.String safeTrimOrNullString(java.lang.String s)
Removes preceding or proceeding whitespace from a string or return null if the string is null or of zero length after trimming (i.e. if the string only contained whitespace).

Parameters:
s - the string to trim
Returns:
the trimmed string or null

toList

public static java.util.List<java.lang.String> toList(java.lang.String valuesStr,
                                                      java.lang.String delimiter)
Creates a list of strings from delimited string.

Parameters:
valuesStr - the delimited string of values
delimiter - the delimiter, if null, then ',' (comma) will be used
Returns:
the list of values, without nulls, or null if the delimited value string is null or empty


Copyright © 2008-2012 EMI - European Middleware Initiative. All Rights Reserved.