|
deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.deegree.commons.utils.StringUtils
public class StringUtils
This is a collection of some methods that work with strings, like split or replace. It is complementary to the ArrayTools.
Field Summary | |
---|---|
static int |
NO_TRIM_FIELDS
Do not trim whitespace on fields. |
static int |
REMOVE_DOUBLE_FIELDS
Remove all double ocurrences of a field. |
static int |
REMOVE_EMPTY_FIELDS
Remove empty fields. |
Constructor Summary | |
---|---|
StringUtils()
|
Method Summary | |
---|---|
static String |
concat(int size,
Object... objects)
Deprecated. highliy deprecated, use normal string concatenation ("foo" + "bar") |
static int |
count(String target,
String token)
Counts the occurrences of token in target. |
static List<String> |
extract(String target,
String start,
String end)
Extract all the strings that begin and end with the given tokens. |
static boolean |
isSet(String s)
|
static String |
replaceAll(String target,
String from,
String to)
Replaces the all substrings of this string that matches the given from string with the given replacement. |
static String |
replaceFirst(String target,
String from,
String to)
Replaces the first substring of this string that matches the given from string with the given replacement. |
static String[] |
split(String string,
String delimiter)
Splits a string on all occurrences of delimiter and returns a list with all parts. |
static String[] |
split(String string,
String delimiter,
int options)
Splits a string on all occurrences of delimiter and returns a list with all parts. |
static String |
trim(String string,
String mark)
Removes all occurrences of a string from the start and end. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int REMOVE_EMPTY_FIELDS
public static final int REMOVE_DOUBLE_FIELDS
public static final int NO_TRIM_FIELDS
Constructor Detail |
---|
public StringUtils()
Method Detail |
---|
@Deprecated public static String concat(int size, Object... objects)
size
- estimated size of the target stringobjects
- toString() will be called for each object to append it to the result string
StringBuffer
public static List<String> extract(String target, String start, String end)
target
- start
- start tokenend
- ent token
public static String replaceFirst(String target, String from, String to)
String.replaceFirst(String, String)
but doesn't use regular expressions. All occurences of special
chars will be escaped.
target
- is the original stringfrom
- is the string to be replacedto
- is the string which will used to replace
public static String replaceAll(String target, String from, String to)
String.replaceAll(String, String)
but doesn't use regular expressions. All occurences of special
chars will be escaped.
target
- is the original stringfrom
- is the string to be replacedto
- is the string which will used to replace
public static String[] split(String string, String delimiter)
split(String, String, int)
for further options. If you need regular
expressions, use String.split(String)
.
string
- the string to splitdelimiter
-
public static String[] split(String string, String delimiter, int options)
String.split(String)
.
This methods offers some options to modify the behaviour of the splitting. You can combine the options with |
(eg. StringTools.split(string, delimiter, REMOVE_EMPTY_FIELDS | REMOVE_DOUBLE_FIELDS)
REMOVE_DOUBLE_FIELDS
removes all double occurrences of a field.REMOVE_EMPTY_FIELDS
removes all empty fields.NO_TRIM_FIELDS
doesn't remove whitespace around each field
string
- delimiter
- options
- a combination (|) of options
public static String trim(String string, String mark)
String.trim()
.
string
- mark
- string to remove from begin and end of string
mark
has been removed from start and endpublic static int count(String target, String token)
target
- token
-
public static final boolean isSet(String s)
s
- the string to test.
null
and s not is the empty string "".
|
deegree-core-3.0-pre-nightly (2010/03/05 00:01) - official | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |