Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.axis.utils.StringUtils
public class StringUtils
extends java.lang.Object
Field Summary | |
static String[] |
|
Method Summary | |
static String |
|
static void |
|
static boolean |
|
static String[] |
|
static boolean |
|
static String |
|
static String |
|
static String |
|
static String |
|
static String |
|
static void |
|
public static String escapeNumericChar(String str)
write the escaped version of a given string
- Parameters:
str
- string to be encoded
- Returns:
- a new escaped
String
,null
if null string input
public static void escapeNumericChar(Writer out, String str) throws IOException
write the escaped version of a given string
- Parameters:
out
- writer to write this string tostr
- string to be encoded
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = falseNOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().
- Parameters:
str
- the String to check, may be null
- Returns:
true
if the String is empty or null
public static String[] split(String str, char separatorChar)
Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer. The separator is not included in the returned String array. Adjacent separators are treated as one separator. Anull
input String returnsnull
.StringUtils.split(null, *) = null StringUtils.split("", *) = [] StringUtils.split("a.b.c", '.') = ["a", "b", "c"] StringUtils.split("a..b.c", '.') = ["a", "b", "c"] StringUtils.split("a:b:c", '.') = ["a:b:c"] StringUtils.split("a\tb\nc", null) = ["a", "b", "c"] StringUtils.split("a b c", ' ') = ["a", "b", "c"]
- Parameters:
str
- the String to parse, may be nullseparatorChar
- the character used as the delimiter,null
splits on whitespace
- Returns:
- an array of parsed Strings,
null
if null String input
public static boolean startsWithIgnoreWhitespaces(String prefix, String string)
Tests if this string starts with the specified prefix (Ignoring whitespaces)
- Parameters:
prefix
-string
-
- Returns:
- boolean
public static String strip(String str)
Strips whitespace from the start and end of a String. This removes whitespace. Whitespace is defined byCharacter.isWhitespace(char)
. Anull
input String returnsnull
.StringUtils.strip(null) = null StringUtils.strip("") = "" StringUtils.strip(" ") = "" StringUtils.strip("abc") = "abc" StringUtils.strip(" abc") = "abc" StringUtils.strip("abc ") = "abc" StringUtils.strip(" abc ") = "abc" StringUtils.strip(" ab c ") = "ab c"
- Parameters:
str
- the String to remove whitespace from, may be null
- Returns:
- the stripped String,
null
if null String input
public static String strip(String str, String stripChars)
Strips any of a set of characters from the start and end of a String. This is similar toString.trim()
but allows the characters to be stripped to be controlled. Anull
input String returnsnull
. An empty string ("") input returns the empty string. If the stripChars String isnull
, whitespace is stripped as defined byCharacter.isWhitespace(char)
. Alternatively usestrip(String)
.StringUtils.strip(null, *) = null StringUtils.strip("", *) = "" StringUtils.strip("abc", null) = "abc" StringUtils.strip(" abc", null) = "abc" StringUtils.strip("abc ", null) = "abc" StringUtils.strip(" abc ", null) = "abc" StringUtils.strip(" abcyx", "xyz") = " abc"
- Parameters:
str
- the String to remove characters from, may be nullstripChars
- the characters to remove, null treated as whitespace
- Returns:
- the stripped String,
null
if null String input
public static String stripEnd(String str, String stripChars)
Strips any of a set of characters from the end of a String. Anull
input String returnsnull
. An empty string ("") input returns the empty string. If the stripChars String isnull
, whitespace is stripped as defined byCharacter.isWhitespace(char)
.StringUtils.stripEnd(null, *) = null StringUtils.stripEnd("", *) = "" StringUtils.stripEnd("abc", "") = "abc" StringUtils.stripEnd("abc", null) = "abc" StringUtils.stripEnd(" abc", null) = " abc" StringUtils.stripEnd("abc ", null) = "abc" StringUtils.stripEnd(" abc ", null) = " abc" StringUtils.stripEnd(" abcyx", "xyz") = " abc"
- Parameters:
str
- the String to remove characters from, may be nullstripChars
- the characters to remove, null treated as whitespace
- Returns:
- the stripped String,
null
if null String input
public static String stripStart(String str, String stripChars)
Strips any of a set of characters from the start of a String. Anull
input String returnsnull
. An empty string ("") input returns the empty string. If the stripChars String isnull
, whitespace is stripped as defined byCharacter.isWhitespace(char)
.StringUtils.stripStart(null, *) = null StringUtils.stripStart("", *) = "" StringUtils.stripStart("abc", "") = "abc" StringUtils.stripStart("abc", null) = "abc" StringUtils.stripStart(" abc", null) = "abc" StringUtils.stripStart("abc ", null) = "abc " StringUtils.stripStart(" abc ", null) = "abc " StringUtils.stripStart("yxabc ", "xyz") = "abc "
- Parameters:
str
- the String to remove characters from, may be nullstripChars
- the characters to remove, null treated as whitespace
- Returns:
- the stripped String,
null
if null String input
public static String unescapeNumericChar(String str)
Unescapes numeric character referencs found in theString
. For example, it will return a unicode string which means the specified numeric character references looks like "ようこそ".
- Parameters:
str
- theString
to unescape, may be null
- Returns:
- a new unescaped
String
,null
if null string input
public static void unescapeNumericChar(Writer out, String str) throws IOException
Unescapes numeric character references found in theString
to aWriter
. For example, it will return a unicode string which means the specified numeric character references looks like "ようこそ". Anull
string input has no effect.
- Parameters:
out
- theWriter
used to output unescaped charactersstr
- theString
to unescape, may be null