org.ow2.dragon.ui.utils
Class StringHelper

java.lang.Object
  extended by org.ow2.dragon.ui.utils.StringHelper

public final class StringHelper
extends java.lang.Object

An util class to process String Initial developer(s): Adrien LOUIS

Author:
alouis, ofabre, mcarpentier - EBM WebSourcing

Method Summary
static boolean equal(java.lang.String a, java.lang.String b)
          Test the equality of the specified strings. test is : ( (a==b==null) || a.equals(b) )
static boolean equalIgnoreCase(java.lang.String a, java.lang.String b)
          Same as equal, with ignoreCase
static java.lang.String extractValueForAttribute(java.lang.String string, java.lang.String attribute, java.lang.String separator)
          TODO use Tokenizer Extract in the given String the value corresponding to the given attribute: ".......
static java.lang.String HTMLEntityEncode(java.lang.String s)
          Encode a String in HTML format
static boolean isNotNullAndNotEmpty(java.lang.String s)
          Return true if the String is not null and its size is > 0.
static boolean isNullOrEmpty(java.lang.String s)
          Return true if the String is null or its size is 0.
static java.lang.String prettyPrint(org.w3c.dom.Document xmlDocument)
          parse the xml String and return it pretty-printed (with correct indentations, etc..)
static java.lang.String prettyPrint(java.lang.String xmlString)
          parse the xml String and return it pretty-printed (with correct indentations, etc..)
static java.util.List<java.lang.String> splitPathElements(java.lang.String path)
          Split the given String path into String path elements.
static java.util.List<java.lang.String> urlParameterToArray(java.lang.String parameter)
          An url parameter array is like this : [value1, value2, value3].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equal

public static boolean equal(java.lang.String a,
                            java.lang.String b)
Test the equality of the specified strings. test is : ( (a==b==null) || a.equals(b) )

Parameters:
a -
b -
Returns:

equalIgnoreCase

public static boolean equalIgnoreCase(java.lang.String a,
                                      java.lang.String b)
Same as equal, with ignoreCase

Parameters:
a -
b -
Returns:

extractValueForAttribute

public static java.lang.String extractValueForAttribute(java.lang.String string,
                                                        java.lang.String attribute,
                                                        java.lang.String separator)
TODO use Tokenizer Extract in the given String the value corresponding to the given attribute: ".......=VALUE......". - not case sensitive - return the first value for the first matching attribute - the separator between ATT and VALUE must be : "="

Parameters:
string - can be null or empty (return null)
attribute - can be null or empty (return null)
separator - (";"," ","&"...) can be null or empty. in this case, take the end of the String : "ATT="
Returns:
the found attribute value, null otherwise

HTMLEntityEncode

public static java.lang.String HTMLEntityEncode(java.lang.String s)
Encode a String in HTML format

Parameters:
s - the String to encode
Returns:
a html encoded string

isNotNullAndNotEmpty

public static boolean isNotNullAndNotEmpty(java.lang.String s)
Return true if the String is not null and its size is > 0.

Parameters:
s -
Returns:

isNullOrEmpty

public static boolean isNullOrEmpty(java.lang.String s)
Return true if the String is null or its size is 0.

Parameters:
s -
Returns:

prettyPrint

public static java.lang.String prettyPrint(org.w3c.dom.Document xmlDocument)
parse the xml String and return it pretty-printed (with correct indentations, etc..) If an error occurs during the process, the returned String will be the original XML string

Parameters:
xmlString - the xml String to pretty print

prettyPrint

public static java.lang.String prettyPrint(java.lang.String xmlString)
parse the xml String and return it pretty-printed (with correct indentations, etc..) If an error occurs during the process, the returned String will be the original XML string

Parameters:
xmlString - the xml String to pretty print
Returns:
pretty printed string if no error occurs. If an error occurs, return the original string

splitPathElements

public static java.util.List<java.lang.String> splitPathElements(java.lang.String path)
Split the given String path into String path elements. For example, the following path "/foo/bar" will be split into two parts "foo" and "bar", returned in List. If the given path includes empty path elements (Ex: "/foo//bar//"), the returned List doesn't contain these elements (for this exemple result will be "foo","bar").

Parameters:
path - the String path to split, can be null or empty (return an empty ArrayList)
Returns:
a List of String path elements, cannot be null, can be empty

urlParameterToArray

public static java.util.List<java.lang.String> urlParameterToArray(java.lang.String parameter)
An url parameter array is like this : [value1, value2, value3]. It will be splitted in a list of string containing : value1, value2, value3

Parameters:
parameter - the String parameter to split
Returns:
a List of String parameter elements, cannot be null, can be empty


Copyright © 2008-2010 eBMWebsourcing. All Rights Reserved.