com.funambol.syncclient.common
Class StringTools

java.lang.Object
  extended by com.funambol.syncclient.common.StringTools

public class StringTools
extends java.lang.Object

Utility class that groups string manipulation functions.

Version:
$Id: StringTools.java,v 1.3 2007-12-22 18:09:17 nichele Exp $

Constructor Summary
StringTools()
           
 
Method Summary
static java.lang.String escapeXml(java.lang.String str)
          Escapes the characters in a String using XML entities.
static boolean isEmpty(java.lang.String s)
          Returns true if the given string is null or zero-length, false otherwise.
static java.lang.String join(java.lang.String[] array)
          Joins the given Strin[] in a comma separated String
static java.lang.String replaceSpecial(java.lang.String s)
          Replaces special characters from the given string with an underscore ('_').
static java.lang.String[] split(java.lang.String s)
          Splits a comma separated values string into an array of strings.
static java.lang.String unescapeXml(java.lang.String str)
          Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTools

public StringTools()
Method Detail

split

public static java.lang.String[] split(java.lang.String s)
Splits a comma separated values string into an array of strings.

Parameters:
s - the comma separated values list - NOT NULL
Returns:
the elements in the list as an array

join

public static java.lang.String join(java.lang.String[] array)
Joins the given Strin[] in a comma separated String

Parameters:
array - the String[] to join - NOT NULL
Returns:
a comma separated list as a single string

isEmpty

public static boolean isEmpty(java.lang.String s)
Returns true if the given string is null or zero-length, false otherwise.

Parameters:
s - the string to check
Returns:
true if the given string is null or zero-length, false otherwise.

replaceSpecial

public static java.lang.String replaceSpecial(java.lang.String s)
Replaces special characters from the given string with an underscore ('_').

Parameters:
s - the string to replace.
Returns:
the replaced string.

escapeXml

public static java.lang.String escapeXml(java.lang.String str)

Escapes the characters in a String using XML entities.

Supports only the four basic XML entities (gt, lt, quot, amp). Does not support DTDs or external entities.

Parameters:
str - the String to escape, may be null
Returns:
a new escaped String, null if null string input
See Also:
unescapeXml(java.lang.String)

unescapeXml

public static java.lang.String unescapeXml(java.lang.String str)

Unescapes a string containing XML entity escapes to a string containing the actual Unicode characters corresponding to the escapes.

Supports only the four basic XML entities (gt, lt, quot, amp). Does not support DTDs or external entities.

Parameters:
str - the String to unescape, may be null
Returns:
a new unescaped String, null if null string input
See Also:
escapeXml(String)


Copyright © 2010 Funambol. All Rights Reserved.