org.objectweb.petals.tools.webadmin.util
Class StringHelper

java.lang.Object
  extended by org.objectweb.petals.tools.webadmin.util.StringHelper

public final class StringHelper
extends java.lang.Object

Initial developer(s): Adrien LOUIS

Author:
alouis, ofabre - 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(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.
 
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

isNullOrEmpty

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

Parameters:
s -
Returns:

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:

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

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

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


Copyright © 2005-2007 ObjectWeb Consortium. All Rights Reserved.