public class TextUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String[] |
SINGLE_TAGS |
| Constructor and Description |
|---|
TextUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
closeTags(String str)
Search through a String for any tags that have been opened and append closing tags
for those that have not been closed.
|
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 |
noNull(String string) |
static String |
noNull(String string,
String defaultString)
Return
string, or defaultString if
string is null or "". |
static float |
parseFloat(String in)
Convert a String to a float.
|
static int |
parseInt(String in)
Convert a String to an int.
|
static boolean |
stringSet(String string)
Check whether
string has been set to
something other than "" or null. |
static String |
trimToEndingChar(String str,
int len)
Trim a String to the specified length.
|
public static final String[] SINGLE_TAGS
public static boolean stringSet(String string)
string has been set to
something other than "" or null.string - the String to checkpublic static 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 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, Collection pieces)
glue - Token to place between Strings.pieces - Collection of Strings to join.join(String, java.util.Iterator)public static int parseInt(String in)
in - String containing number to be parsed.public static float parseFloat(String in)
in - String containing number to be parsed.public static String trimToEndingChar(String str, int len)
str - - String to trim.len - - length to which string is to be trimmed.public static final String closeTags(String str)
str - A string possibly containing unclosed HTML tagspublic static final String htmlEncode(String s, boolean encodeSpecialChars)
s - the String to escape.encodeSpecialChars - if true high characters will be encode other wise not.Copyright © 2024 Atlassian. All rights reserved.