|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.opensymphony.xwork2.util.TextUtils
public class TextUtils
Utilities for common String manipulations. This is a class contains static methods only and is not meant to be instantiated. It was brought in from oscore trunk revision 147, and trimmed to only contain methods used by XWork.
| Constructor Summary | |
|---|---|
TextUtils()
|
|
| Method Summary | |
|---|---|
static String |
htmlEncode(String s)
|
static String |
htmlEncode(String s,
boolean encodeSpecialChars)
Escape html entity characters and high characters (eg "curvy" Word quotes). |
static String |
join(String glue,
Collection pieces)
Join a Collection of Strings together. |
static String |
join(String glue,
Iterator pieces)
Join an Iteration of Strings together. |
static String |
join(String glue,
String[] pieces)
Join an array of Strings together. |
static String |
noNull(String string)
Return string, or "" if string
is null. |
static String |
noNull(String string,
String defaultString)
Return string, or defaultString if
string is null or "". |
static boolean |
stringSet(String string)
Check whether string has been set to
something other than "" or null. |
static boolean |
verifyUrl(String url)
Verify That the given String is in valid URL format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TextUtils()
| Method Detail |
|---|
public static final String htmlEncode(String s)
public static final String htmlEncode(String s,
boolean encodeSpecialChars)
s - the String to escape.encodeSpecialChars - if true high characters will be encode other wise not.
public static final String join(String glue,
Iterator pieces)
// get Iterator of Strings ("abc","def","123");
Iterator i = getIterator();
out.print( TextUtils.join(", ",i) );
// prints: "abc, def, 123"
glue - Token to place between Strings.pieces - Iteration of Strings to join.
public static final String join(String glue,
String[] pieces)
glue - Token to place between Strings.pieces - Array of Strings to join.
join(String, java.util.Iterator)
public static final String join(String glue,
Collection pieces)
glue - Token to place between Strings.pieces - Collection of Strings to join.
join(String, java.util.Iterator)
public static final String noNull(String string,
String defaultString)
string, or defaultString if
string is null or "".
Never returns null.
Examples:
// prints "hello" String s=null; System.out.println(TextUtils.noNull(s,"hello"); // prints "hello" s=""; System.out.println(TextUtils.noNull(s,"hello"); // prints "world" s="world"; System.out.println(TextUtils.noNull(s, "hello");
string - the String to check.defaultString - The default string to return if string is null or ""
string if string is non-empty, and defaultString otherwisestringSet(java.lang.String)public static final String noNull(String string)
string, or "" if string
is null. Never returns null.
Examples:
// prints 0 String s=null; System.out.println(TextUtils.noNull(s).length()); // prints 1 s="a"; System.out.println(TextUtils.noNull(s).length());
string - the String to check
public static final boolean stringSet(String string)
string has been set to
something other than "" or null.
string - the String to check
public static final boolean verifyUrl(String url)
url - The url string to verify.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||