Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.apache.maven.doxia.util.StringUtil
public class StringUtil
extends java.lang.Object
Field Summary | |
static String[] |
|
Method Summary | |
static String[] |
|
static String |
|
static boolean |
|
static String |
|
static int |
|
static String[] |
|
static String |
|
static String |
|
static void |
|
static String[] |
|
static String |
|
static String[] |
|
static String[] |
|
static String |
|
static String[] |
|
static String |
|
static String |
|
static String |
|
public static String[] append(String[] strings, String string)
Inserts a String as last item of a list of Strings.
- Parameters:
strings
- the list where a String is to be insertedstring
- the String to insert
- Returns:
- a list containing all the items of list
strings
plus Stringstring
inserted at its end
public static String capitalize(String string)
Returns the specified string with its first character converted to upper case.
- Parameters:
string
- the String to be processed
- Returns:
- the specified string with its first character converted to upper case
public static boolean contains(String[] strings, String string)
Tests if liststrings
contains Stringstring
.
- Parameters:
strings
- the list to be searchedstring
- the String to search for
- Returns:
true
the string is found andfalse
otherwise
public static String escape(String string)
Returns the specified string with all non-ASCII characters and non-printable ASCII characters replaced by the corresponding Java escape sequences (that is '\n', '\u00E9', etc).
- Parameters:
string
- the String to be escaped
- Returns:
- the specified string with all non-ASCII characters and non-printable ASCII characters replaced by the corresponding Java escape sequences
public static int indexOf(String[] strings, String string)
Searches Stringstring
within liststrings
.
- Parameters:
strings
- the list to be searchedstring
- the String to search for
- Returns:
- the index of the searched string within list or -1 if not found
public static String[] insertAt(String[] strings, String string, int index)
Inserts a String inside a list of Strings.
- Parameters:
strings
- the list where a String is to be insertedstring
- the String to insertindex
- the insertion index
- Returns:
- a list containing all the items of list
strings
plus Stringstring
inserted at positionindex
public static String join(String[] strings, String separator)
Joins the items of the specified list of Strings using specified separator String.
- Parameters:
strings
- the list where items are to be joinedseparator
- the String used to join items
- Returns:
- a string where all list items have been joined
public static String join(String[] strings, char separatorChar)
Joins the items of the specified list of Strings using specified separator char.
- Parameters:
strings
- the list where items are to be joinedseparatorChar
- the char used to join items
- Returns:
- a string where all list items have been joined
public static final void main(String[] args)
A simple test forescape(String)
andunescape(String)
.
public static String[] prepend(String[] strings, String string)
Inserts a String as first item of a list of Strings.
- Parameters:
strings
- the list where a String is to be insertedstring
- the String to insert
- Returns:
- a list containing all the items of list
strings
plus Stringstring
inserted at its beginning
public static String protect(String string)
Likeescape(String)
but puts a double quote character ('\"') around the escaped string.
public static String[] remove(String[] strings, String string)
Removes a String from a list of Strings.
- Parameters:
strings
- the list where a String is to be removedstring
- the String to remove
- Returns:
- a list containing all the items of list
strings
less Stringstring
if such String is contained in the list; the original list otherwise.
public static String[] removeAt(String[] strings, int index)
Removes an item specified by its position from a list of Strings.
- Parameters:
strings
- the list where an item is to be removedindex
- the position of the item to remove
- Returns:
- a list containing all the items of list
strings
less the item at positionindex
.
public static String replaceAll(String string, String oldSub, String newSub)
Replaces substringoldSub
by substringnewSub
inside Stringstring
.
- Parameters:
string
- the String where replacements are to be performedoldSub
- the substring to replacenewSub
- the replacement substring
- Returns:
- a string where all replacements have been performed
- See Also:
String.replace
public static String[] split(String string, char separatorChar)
Splits Stringstring
at occurences of charseparatorChar
.
- Parameters:
string
- the String to be splitseparatorChar
- the char where to split
- Returns:
- the list of substrings resulting from splitting String
string
at occurences of charseparatorChar
Note that each occurence ofseparatorChar
specifies the end of a substring. Therefore, the returned list may contain empty substrings if consecutiveseparatorChar
s are found in Stringstring
.
public static String uncapitalize(String string)
Returns the specified string with its first character converted to lower case.
- Parameters:
string
- the String to be processed
- Returns:
- the specified string with its first character converted to lower case
public static String unescape(String string)
Returns the specified string with Java escape sequences (that is '\n', '\u00E9', etc) replaced by the corresponding character.
- Parameters:
string
- the String to be unescaped
- Returns:
- the specified string with Java escape sequences replaced by the corresponding character
public static String unprotect(String string)
Likeunescape(String)
but removes the double quote characters ('\"'), if any, before unescaping the string.