|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jboss.util.Strings
A collection of String utilities.
| Nested Class Summary | |
static class |
Strings.Range
Represents a range between two integers. |
| Field Summary | |
static String |
EMPTY
An empty string constant |
| Constructor Summary | |
Strings()
|
|
| Method Summary | |
static String |
capitalize(String string)
Capitalize the first character of the given string. |
static boolean |
compare(String me,
String you)
Compare two strings. |
static int |
count(String string,
char c)
Count the number of instances of character within a string. |
static int |
count(String string,
String substring)
Count the number of instances of substring within a string. |
static String |
defaultToString(Object object)
The default toString implementation of an object |
static boolean |
isEjbQlIdentifier(String s)
Check whether the given String is an identifier according to the EJB-QL definition. |
static boolean |
isEmpty(String string)
Check if the given string is empty. |
static boolean |
isJavaKeyword(String s)
Check whether the given String is a reserved Java Keyword according to the Java Language Specifications. |
static boolean |
isValidJavaIdentifier(String s)
Check whether the given String is a valid identifier according to the Java Language specifications. |
static String |
join(byte[] array)
Convert and join an array of bytes into one string. |
static String |
join(Object[] array)
Convert and join an array of objects into one string. |
static String |
join(Object[] array,
String delim)
Join an array of strings into one delimited string. |
static String |
join(Object[] array,
String prefix,
String separator,
String suffix)
Return a string composed of the given array. |
static String |
join(StringBuffer buff,
Object[] array,
String delim)
Join an array of strings into one delimited string. |
static String |
join(StringBuffer buff,
Object[] array,
String prefix,
String separator,
String suffix)
Return a string composed of the given array. |
static int |
nthIndexOf(String string,
String token,
int index)
Return the nth index of the given token occurring in the given string. |
static String |
pad(Object obj,
int count)
Return a string padded with the given string value of an object for the given count. |
static String |
pad(StringBuffer buff,
String string,
int count)
Return a string padded with the given string for the given count. |
static String |
pad(String string,
int count)
Return a string padded with the given string for the given count. |
static Strings.Range |
rangeOf(String beginToken,
String endToken,
String string)
Return the range from a begining token to an ending token. |
static Strings.Range |
rangeOf(String beginToken,
String endToken,
String string,
int fromIndex)
Return the range from a begining token to an ending token. |
static String[] |
split(String string,
String delim)
Split up a string into multiple strings based on a delimiter. |
static String[] |
split(String string,
String delim,
int limit)
Split up a string into multiple strings based on a delimiter. |
static String |
subst(StringBuffer buff,
String string,
Map map,
String beginToken,
String endToken)
Substitute sub-strings in side of a string. |
static String |
subst(StringBuffer buff,
String string,
String[] replace,
char token)
Substitute index identifiers with the replacement value from the given array for the corresponding index. |
static String |
subst(StringBuffer buff,
String from,
String to,
String string)
Substitute sub-strings in side of a string. |
static String |
subst(String string,
Map map,
String beginToken,
String endToken)
Substitute sub-strings in side of a string. |
static String |
subst(String string,
String[] replace)
Substitute index identifiers (with % for the index token)
with the replacement value from the given array for the corresponding
index. |
static String |
subst(String string,
String[] replace,
char token)
Substitute index identifiers with the replacement value from the given array for the corresponding index. |
static String |
subst(String from,
String to,
String string)
Substitute sub-strings in side of a string. |
static URL |
toURL(String urlspec)
Make a URL from the given string. |
static URL |
toURL(String urlspec,
String relativePrefix)
Make a URL from the given string. |
static String[] |
trim(String[] strings)
Trim each string in the given string array. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String EMPTY
| Constructor Detail |
public Strings()
| Method Detail |
public static String subst(StringBuffer buff, String from, String to, String string)
buff - Stirng buffer to use for substitution (buffer is not reset)from - String to substitute fromto - String to substitute tostring - String to look for from in
public static String subst(String from, String to, String string)
from - String to substitute fromto - String to substitute tostring - String to look for from in
public static String subst(StringBuffer buff, String string, Map map, String beginToken, String endToken)
buff - String buffer to use for substitution (buffer is not reset)string - String to subst mappings inmap - Map of from->to stringsbeginToken - Beginning tokenendToken - Ending token
public static String subst(String string, Map map, String beginToken, String endToken)
string - String to subst mappings inmap - Map of from->to stringsbeginToken - Beginning tokenendToken - Ending token
public static String subst(StringBuffer buff, String string, String[] replace, char token)
buff - The string buffer used for the substitution
(buffer is not reset).string - String substitution format.replace - Array of strings whose values will be used as
replacements in the given string when a token with
their index is found.token - The character token to specify the start of an index
reference.
public static String subst(String string, String[] replace, char token)
string - String substitution format.replace - Array of strings whose values will be used as
replacements in the given string when a token with
their index is found.token - The character token to specify the start of an index
reference.
public static String subst(String string, String[] replace)
% for the index token)
with the replacement value from the given array for the corresponding
index.
string - String substitution format.replace - Array of strings whose values will be used as
replacements in the given string when a token with
their index is found.
public static Strings.Range rangeOf(String beginToken, String endToken, String string, int fromIndex)
beginToken - String to indicate begining of range.endToken - String to indicate ending of range.string - String to look for range in.fromIndex - Beginning index.
public static Strings.Range rangeOf(String beginToken, String endToken, String string)
beginToken - String to indicate begining of range.endToken - String to indicate ending of range.string - String to look for range in.
public static String[] split(String string, String delim, int limit)
string - String to split up.delim - Delimiter.limit - Limit the number of strings to split into
(-1 for no limit).
public static String[] split(String string, String delim)
string - String to split up.delim - Delimiter.
public static String join(StringBuffer buff, Object[] array, String delim)
buff - String buffered used for join (buffer is not reset).array - Array of objects to join as strings.delim - Delimiter to join strings with or null.
public static String join(Object[] array, String delim)
array - Array of objects to join as strings.delim - Delimiter to join strings with or null.
public static String join(Object[] array)
array - Array of objects to join as strings.
public static String join(byte[] array)
array - Array of objects to join as strings.
public static String join(StringBuffer buff, Object[] array, String prefix, String separator, String suffix)
buff - Buffer used to construct string value (not reset).array - Array of objects.prefix - String prefix.separator - Element sepearator.suffix - String suffix.
public static String join(Object[] array, String prefix, String separator, String suffix)
array - Array of objects.prefix - String prefix.separator - Element sepearator.suffix - String suffix.
public static int count(String string, String substring)
string - String to look for substring in.substring - Sub-string to look for.
public static int count(String string, char c)
string - String to look for substring in.c - Character to look for.
public static String pad(StringBuffer buff, String string, int count)
buff - String buffer used for padding (buffer is not reset).string - Pad element.count - Pad count.
public static String pad(String string, int count)
string - Pad element.count - Pad count.
public static String pad(Object obj, int count)
obj - Object to convert to a string.count - Pad count.
public static boolean compare(String me, String you)
Compare two strings.
Both or one of them may be null.
public static boolean isEmpty(String string)
string - String to check
public static int nthIndexOf(String string, String token, int index)
string - String to search.token - Token to match.index - Nth index.
public static String capitalize(String string)
string - String to capitalize.
IllegalArgumentException - String is public static String[] trim(String[] strings)
This modifies the string array.
strings - String array to trim.
public static URL toURL(String urlspec, String relativePrefix) throws MalformedURLException
If the string is a properly formatted file URL, then the file portion will be made canonical.
If the string is an invalid URL then it will be converted into a file URL.
urlspec - The string to construct a URL for.relativePrefix - The string to prepend to relative file
paths, or null to disable prepending.
MalformedURLException - Could not make a URL for the given string.public static URL toURL(String urlspec) throws MalformedURLException
urlspec - The string to construct a URL for.
MalformedURLException - Could not make a URL for the given string.toURL(String,String)public static final boolean isJavaKeyword(String s)
s - String to check
true if the given String is a reserved Java
keyword, false otherwise.public static final boolean isEjbQlIdentifier(String s)
s - String to check
true if the given String is a reserved
identifier in EJB-QL, false otherwise.public static final boolean isValidJavaIdentifier(String s)
s - String to check
true if the given String is a valid Java
identifier, false otherwise.public static final String defaultToString(Object object)
object - the object
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||