|
APTCONVERT 1.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectfr.pixware.util.StringUtil
public class StringUtil
A collection of utility functions (static methods) operating on Strings and on lists of Strings. (What is called a list of Strings here is simply an array of Strings.)
| Field Summary | |
|---|---|
static java.lang.String[] |
EMPTY_LIST
The empty list of Strings. |
| Constructor Summary | |
|---|---|
StringUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.String[] |
append(java.lang.String[] strings,
java.lang.String string)
Inserts a String as last item of a list of Strings. |
static java.lang.String |
capitalize(java.lang.String string)
Returns the specified string with its first character converted to upper case. |
static boolean |
contains(java.lang.String[] strings,
java.lang.String string)
Tests if list strings contains String string. |
static java.lang.String |
escape(java.lang.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', '?', etc). |
static int |
indexOf(java.lang.String[] strings,
java.lang.String string)
Searches String string within list strings. |
static java.lang.String[] |
insertAt(java.lang.String[] strings,
java.lang.String string,
int index)
Inserts a String inside a list of Strings. |
static java.lang.String |
join(java.lang.String[] strings,
char separatorChar)
Joins the items of the specified list of Strings using specified separator char. |
static java.lang.String |
join(java.lang.String[] strings,
java.lang.String separator)
Joins the items of the specified list of Strings using specified separator String. |
static void |
main(java.lang.String[] args)
A simple test for escape(java.lang.String) and unescape(java.lang.String). |
static java.lang.String[] |
prepend(java.lang.String[] strings,
java.lang.String string)
Inserts a String as first item of a list of Strings. |
static java.lang.String |
protect(java.lang.String string)
Like escape(java.lang.String) but puts a double quote character ('\"')
around the escaped string. |
static java.lang.String[] |
remove(java.lang.String[] strings,
java.lang.String string)
Removes a String from a list of Strings. |
static java.lang.String[] |
removeAt(java.lang.String[] strings,
int index)
Removes an item specified by its position from a list of Strings. |
static java.lang.String |
replaceAll(java.lang.String string,
java.lang.String oldSub,
java.lang.String newSub)
Replaces substring oldSub by substring newSub
inside String string. |
static java.lang.String[] |
split(java.lang.String string,
char separatorChar)
Splits String string at occurences of char
separatorChar. |
static java.lang.String |
uncapitalize(java.lang.String string)
Returns the specified string with its first character converted to lower case. |
static java.lang.String |
unescape(java.lang.String string)
Returns the specified string with Java escape sequences (that is '\n', '?', etc) replaced by the corresponding character. |
static java.lang.String |
unprotect(java.lang.String string)
Like unescape(java.lang.String) but removes the double quote characters
('\"'), if any, before unescaping the string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String[] EMPTY_LIST
| Constructor Detail |
|---|
public StringUtil()
| Method Detail |
|---|
public static int indexOf(java.lang.String[] strings,
java.lang.String string)
string within list strings.
strings - the list to be searchedstring - the String to search for
public static boolean contains(java.lang.String[] strings,
java.lang.String string)
strings contains String string.
strings - the list to be searchedstring - the String to search for
true the string is found and false
otherwise
public static java.lang.String[] insertAt(java.lang.String[] strings,
java.lang.String string,
int index)
strings - the list where a String is to be insertedstring - the String to insertindex - the insertion index
strings
plus String string inserted at position index
public static java.lang.String[] prepend(java.lang.String[] strings,
java.lang.String string)
strings - the list where a String is to be insertedstring - the String to insert
strings
plus String string inserted at its beginning
public static java.lang.String[] append(java.lang.String[] strings,
java.lang.String string)
strings - the list where a String is to be insertedstring - the String to insert
strings
plus String string inserted at its end
public static java.lang.String[] remove(java.lang.String[] strings,
java.lang.String string)
strings - the list where a String is to be removedstring - the String to remove
strings
less String string if such String is contained in the
list; the original list otherwise.
public static java.lang.String[] removeAt(java.lang.String[] strings,
int index)
strings - the list where an item is to be removedindex - the position of the item to remove
strings
less the item at position index.public static java.lang.String protect(java.lang.String string)
escape(java.lang.String) but puts a double quote character ('\"')
around the escaped string.
public static java.lang.String escape(java.lang.String string)
string - the String to be escaped
public static java.lang.String unprotect(java.lang.String string)
unescape(java.lang.String) but removes the double quote characters
('\"'), if any, before unescaping the string.
public static java.lang.String unescape(java.lang.String string)
string - the String to be unescaped
public static final void main(java.lang.String[] args)
escape(java.lang.String) and unescape(java.lang.String).
public static java.lang.String capitalize(java.lang.String string)
string - the String to be processed
public static java.lang.String uncapitalize(java.lang.String string)
string - the String to be processed
public static java.lang.String[] split(java.lang.String string,
char separatorChar)
string at occurences of char
separatorChar.
string - the String to be splitseparatorChar - the char where to split
string at occurences of char separatorChar
Note that each occurence of separatorChar specifies the
end of a substring. Therefore, the returned list may contain empty
substrings if consecutive separatorChars are found in
String string.
public static java.lang.String join(java.lang.String[] strings,
char separatorChar)
strings - the list where items are to be joinedseparatorChar - the char used to join items
public static java.lang.String join(java.lang.String[] strings,
java.lang.String separator)
strings - the list where items are to be joinedseparator - the String used to join items
public static java.lang.String replaceAll(java.lang.String string,
java.lang.String oldSub,
java.lang.String newSub)
oldSub by substring newSub
inside String string.
string - the String where replacements are to be performedoldSub - the substring to replacenewSub - the replacement substring
String.replace(char, char)
|
APTCONVERT 1.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||