Package org.eclipse.ecf.core.util
Class StringUtils
java.lang.Object
org.eclipse.ecf.core.util.StringUtils
The StringUtils class provides static methods that helps make string manipulation easy. The primary functionality it is meant to provide is the ability to split a string into a string array based on a given delimiter. This functionality is meant to take the place of the split(String) and split(String, int) method that was introduced in J2SE-1.4. Please note, however, that the splitting performed by this class simply splits the string based on the delimiter and does not perform any regular expression matching like the split methods provided in J2SE-1.4.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returns whether the first parameter contains the second parameter.static String
replaceAll
(String string, String target, String replace) Returns the string resulting from replacing all occurrences of the target with the replace string.static String
replaceAllIgnoreCase
(String string, String target, String replace) Returns the string resulting from replacing all occurrences of the target with the replace string.static String
replaceFirst
(String string, String target, String replace) Returns the string resulting from replacing the first occurrences of the target with the replace string.static final String[]
static final String[]
static final String[]
static final String[]
splitOnSpace
(String string) static final String
splitSubstring
(String string, String delimiter, int pos) static final String
static final String
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
splitOnSpace
-
split
-
split
-
split
-
splitSubstring
-
xmlDecode
-
xmlEncode
-
contains
Returns whether the first parameter contains the second parameter.- Parameters:
string
- must not be.
target
- must not benull.
- Returns:
- true if the target is contained within the string.
-
replaceAll
Returns the string resulting from replacing all occurrences of the target with the replace string. Note that the target matches literally, and this is not the same behavior as the String.replaceAll, which uses regular expressions for doing the matching.- Parameters:
string
- the start string. Must not benull
.target
- the target to search for in the start string. Must not benull
.replace
- the replacement string to substitute when the target is found. Must not benull
.- Returns:
- String result. Will not be
null
. If target is not found in the given string, then the result will be the entire input string.
-
replaceAllIgnoreCase
Returns the string resulting from replacing all occurrences of the target with the replace string. Note that the target matches literally but ignoring the case, and this is not the same behavior as the String.replaceAll, which uses regular expressions for doing the matching.- Parameters:
string
- the start string. Must not benull
.target
- the target to search for in the start string. Must not benull
.replace
- the replacement string to substitute when the target is found. Must not benull
.- Returns:
- String result. Will not be
null
. If target is not found in the given string, then the result will be the entire input string. - Since:
- 2.1
- See Also:
-
replaceFirst
Returns the string resulting from replacing the first occurrences of the target with the replace string. Note that the target matches literally, and this is not the same behavior as the String.replaceAll, which uses regular expressions for doing the matching.- Parameters:
string
- the start string. Must not benull
.target
- the target to search for in the start string. Must not benull
.replace
- the replacement string to substitute when the target is found. Must not benull
.- Returns:
- String result. Will not be
null
. If target is not found in the given string, then the result will be the entire input string. - Since:
- 3.0
-