|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bowstreet.util.StringUtil
public class StringUtil
The StringUtil class can be used as a simplified mechanism for concatenating an arbitrary number of string objects.
Field Summary | |
---|---|
static java.lang.String |
newline
|
Constructor Summary | |
---|---|
StringUtil()
|
Method Summary | |
---|---|
static java.lang.String |
buildDelimitedString(java.util.List items,
char delimiter)
Builds a delimited String from the specified list of objects. |
static java.lang.String |
cleanIdentifier(java.lang.String id)
Convert arbitrary Unicode string into one consisting of only ASCII letters, numbers and underscore. |
static boolean |
contains(java.lang.String[] array,
java.lang.String test)
Test if a string array contains a certain string. |
static boolean |
equals(java.lang.String string1,
java.lang.String string2)
Compares two string for equality. |
static java.lang.String |
fixUpFilename(java.lang.String filename,
java.lang.String ext)
|
static java.lang.String |
getCompleteExceptionText(java.lang.Throwable ex)
Make an error string from an exception, including the stack trace |
static java.lang.String |
getSafeXMLName(java.lang.String oldValue)
Create a name that's safe to be used as the name of an XML element. |
static java.lang.String |
getSafeXMLName(java.lang.String oldValue,
boolean allowDot)
Create a name that's safe to be used as the name of an XML element. |
static java.lang.String |
getStackTraceAsString(java.lang.Throwable ex)
Get the stack trace from an exception |
static boolean |
isEmpty(java.lang.String str)
Test given string argument to see if it represents an empty string. |
static boolean |
isJavaIdentifier(java.lang.String s)
|
static java.lang.String |
lcFirstChar(java.lang.String s)
Returns the passed in String as a new String with the first char converted to lower case. |
static void |
main(java.lang.String[] args)
|
static java.lang.String |
ncrDecode(java.lang.String s)
Decode all numeric character references (NCR) in a string. |
static java.lang.String |
ncrEncode(java.lang.String s,
int lowerInclusive,
int upperInclusive)
Encode out-of-range characters in a string as numeric character references (NCR). |
static java.lang.String |
normalize(java.lang.String value)
Normalize a string to be null if it only contains whitespace or is an empty string. |
static java.util.List |
parseDelimitedList(java.lang.String delimitedList)
This method parses a comma delimited list into List object. |
static java.lang.String |
printf(java.lang.String formatString,
java.lang.Object value)
A shortcut for using the MessageFormat class, where all the arguments are strings |
static java.lang.String |
printf(java.lang.String formatString,
java.lang.Object value0,
java.lang.Object value1)
A shortcut for using the MessageFormat class, where all the arguments are strings |
static java.lang.String |
printf(java.lang.String formatString,
java.lang.Object value0,
java.lang.Object value1,
java.lang.Object value2)
A shortcut for using the MessageFormat class, where all the arguments are strings |
static java.lang.String |
printf(java.lang.String formatString,
java.lang.Object value0,
java.lang.Object value1,
java.lang.Object value2,
java.lang.Object value3)
A shortcut for using the MessageFormat class, where all the arguments are strings |
static java.lang.String |
replace(java.lang.String source,
java.lang.String target,
java.lang.String replacement)
Routine to effect n-ary substitution of one string for another |
static int |
safeParseInt(java.lang.String str,
int defaultVal)
Safely parse a string containing an integer. |
static int |
safeParseInt(java.lang.String str,
int radix,
int defaultVal)
Safely parse a string containing an integer represented in an arbitrary radix. |
static java.lang.String |
safeTrim(java.lang.String str)
|
static java.lang.String |
strBreak(java.lang.String longstring,
int preferredWidth)
Crude way to insert newline chars at least every N chars apart in a long string. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three)
Concatinates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four,
java.lang.String five)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four,
java.lang.String five,
java.lang.String six)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four,
java.lang.String five,
java.lang.String six,
java.lang.String seven)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four,
java.lang.String five,
java.lang.String six,
java.lang.String seven,
java.lang.String eight)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four,
java.lang.String five,
java.lang.String six,
java.lang.String seven,
java.lang.String eight,
java.lang.String nine)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four,
java.lang.String five,
java.lang.String six,
java.lang.String seven,
java.lang.String eight,
java.lang.String nine,
java.lang.String ten)
Concatenates two strings together. |
static java.lang.String |
strcat(java.lang.String one,
java.lang.String two,
java.lang.String three,
java.lang.String four,
java.lang.String five,
java.lang.String six,
java.lang.String seven,
java.lang.String eight,
java.lang.String nine,
java.lang.String ten,
java.lang.String eleven,
java.lang.String twelve,
java.lang.String thirteen,
java.lang.String fourteen,
java.lang.String fifteen)
Concatenates up to 15 strings together. |
static java.lang.String |
substringAfter(java.lang.String str,
char separator)
Returns the substring of str following the separator. |
static java.lang.String |
substringAfter(java.lang.String str,
java.lang.String separator)
Returns the substring of str following the separator. |
static java.lang.String |
substringAfterLast(java.lang.String str,
char separator)
Returns the substring of str following the last occurrence of separator. |
static java.lang.String |
substringAfterLast(java.lang.String str,
java.lang.String separator)
Returns the substring of str following the last occurrence of separator. |
static java.lang.String |
substringBefore(java.lang.String str,
char separator)
Returns the substring of str before the separator. |
static java.lang.String |
substringBefore(java.lang.String str,
java.lang.String separator)
Returns the substring of str before the separator. |
static java.lang.String |
substringBeforeLast(java.lang.String str,
char separator)
Returns the substring of str before the last occurrence of separator. |
static java.lang.String |
substringBeforeLast(java.lang.String str,
java.lang.String separator)
Returns the substring of str before the separator. |
static java.lang.String |
switchFirstChar(java.lang.String s,
java.lang.String sub)
Returns the passed in String as a new String with the first char replaced with the substitute String. |
static java.lang.String[] |
tokenize(java.lang.String source,
java.lang.String delims,
boolean returnDelims)
tokenizes a String and returns the array of tokens. |
static java.util.List |
tokenizeToList(java.lang.String source,
java.lang.String delims,
boolean returnDelims)
tokenizes a String and returns a List of tokens. |
static java.util.Set |
tokenizeToSet(java.lang.String source,
java.lang.String delims,
boolean returnDelims)
tokenizes a String and returns a Set of tokens. |
static java.lang.String |
ucFirstChar(java.lang.String s)
Returns the passed in String as a new String with the first char converted to upper case. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String newline
Constructor Detail |
---|
public StringUtil()
Method Detail |
---|
public static java.lang.String buildDelimitedString(java.util.List items, char delimiter)
items
- The list of items to build the string from.delimiter
- The delimiter used to the list items
public static java.lang.String cleanIdentifier(java.lang.String id)
id
- String
public static boolean contains(java.lang.String[] array, java.lang.String test)
array
- test
- public static boolean equals(java.lang.String string1, java.lang.String string2)
string1
- String to comparestring2
- String to compare
public static java.lang.String fixUpFilename(java.lang.String filename, java.lang.String ext)
filename
- ext
- public static java.lang.String getCompleteExceptionText(java.lang.Throwable ex)
ex
- Exception
public static java.lang.String getSafeXMLName(java.lang.String oldValue)
oldValue
- The value to be used as the basis of the safe XML element name.
public static java.lang.String getSafeXMLName(java.lang.String oldValue, boolean allowDot)
oldValue
- The value to be used as the basis of the safe XML element name.allowDot
- if true, then the dot character is also considered to be a safe character
public static java.lang.String getStackTraceAsString(java.lang.Throwable ex)
ex
- Exception
public static boolean isEmpty(java.lang.String str)
str
- string to test
true
if given argument is an empty string or false
otherwise.public static boolean isJavaIdentifier(java.lang.String s)
public static java.lang.String lcFirstChar(java.lang.String s)
s
- the String to be modified
public static void main(java.lang.String[] args)
public static java.lang.String ncrDecode(java.lang.String s) throws java.lang.NumberFormatException
s
- String to be decoded.
java.lang.NumberFormatException
- when there is an NCR in the string that cannot be successfully
convertred into a plain old Java character.public static java.lang.String ncrEncode(java.lang.String s, int lowerInclusive, int upperInclusive)
s
- String to be encoded.lowerInclusive
- The lowest character that will not be encoded.upperInclusive
- The highest character that will not not be encoded.
java.lang.IllegalArgumentException
- when upperInclusive
is less than
lowerInclusive
.public static java.lang.String normalize(java.lang.String value)
value
- The string to be normalized.
null
if the parameter is null or only contains whitespace.
Otherwise a trimmed version of the parameter is returned.public static java.util.List parseDelimitedList(java.lang.String delimitedList)
delimitedList
- The comma delimited list to parse.public static java.lang.String printf(java.lang.String formatString, java.lang.Object value)
formatString
- MessageFormat formatter string, where replacement points look like {#}value
- replaces {0} in format string
public static java.lang.String printf(java.lang.String formatString, java.lang.Object value0, java.lang.Object value1)
formatString
- MessageFormat formatter string, where replacement points look like {#}value0
- replaces {0} in format stringvalue1
- replaces {1} in format string
public static java.lang.String printf(java.lang.String formatString, java.lang.Object value0, java.lang.Object value1, java.lang.Object value2)
formatString
- MessageFormat formatter string, where replacement points look like {#}value0
- replaces {0} in format stringvalue1
- replaces {1} in format stringvalue2
- replaces {2} in format string
public static java.lang.String printf(java.lang.String formatString, java.lang.Object value0, java.lang.Object value1, java.lang.Object value2, java.lang.Object value3)
formatString
- MessageFormat formatter string, where replacement points look like {#}value0
- replaces {0} in format stringvalue1
- replaces {1} in format stringvalue2
- replaces {2} in format stringvalue3
- replaces {3} in format string
public static java.lang.String replace(java.lang.String source, java.lang.String target, java.lang.String replacement)
public static int safeParseInt(java.lang.String str, int defaultVal)
str
- The string to parse.defaultVal
- Default value to return if the string cannot be parsed as an integer.
public static int safeParseInt(java.lang.String str, int radix, int defaultVal)
str
- The string to parse.radix
- The radix of the used to represent the integer.defaultVal
- Default value to return if the string cannot be parsed as an integer.
Integer.parseInt(String, int)
public static java.lang.String safeTrim(java.lang.String str)
public static java.lang.String strBreak(java.lang.String longstring, int preferredWidth)
longstring
- the long string to be broken uppreferredWidth
- the minimum desired newline separation
public static java.lang.String strcat(java.lang.String one, java.lang.String two)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four, java.lang.String five)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.five
- The fifth part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four, java.lang.String five, java.lang.String six)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.five
- The fifth part of the resulting string. May be null.six
- The sixth part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four, java.lang.String five, java.lang.String six, java.lang.String seven)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.five
- The fifth part of the resulting string. May be null.six
- The sixth part of the resulting string. May be null.seven
- The seventh part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four, java.lang.String five, java.lang.String six, java.lang.String seven, java.lang.String eight)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.five
- The fifth part of the resulting string. May be null.six
- The sixth part of the resulting string. May be null.seven
- The seventh part of the resulting string. May be null.eight
- The eighth part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four, java.lang.String five, java.lang.String six, java.lang.String seven, java.lang.String eight, java.lang.String nine)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.five
- The fifth part of the resulting string. May be null.six
- The sixth part of the resulting string. May be null.seven
- The seventh part of the resulting string. May be null.eight
- The eighth part of the resulting string. May be null.nine
- The ninth part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four, java.lang.String five, java.lang.String six, java.lang.String seven, java.lang.String eight, java.lang.String nine, java.lang.String ten)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.five
- The fifth part of the resulting string. May be null.six
- The sixth part of the resulting string. May be null.seven
- The seventh part of the resulting string. May be null.eight
- The eighth part of the resulting string. May be null.nine
- The ninth part of the resulting string. May be null.ten
- The tenth part of the resulting string. May be null.
public static java.lang.String strcat(java.lang.String one, java.lang.String two, java.lang.String three, java.lang.String four, java.lang.String five, java.lang.String six, java.lang.String seven, java.lang.String eight, java.lang.String nine, java.lang.String ten, java.lang.String eleven, java.lang.String twelve, java.lang.String thirteen, java.lang.String fourteen, java.lang.String fifteen)
one
- The first part of the resulting string. May be null.two
- The second part of the resulting string. May be null.three
- The third part of the resulting string. May be null.four
- The fourth part of the resulting string. May be null.five
- The fifth part of the resulting string. May be null.six
- The sixth part of the resulting string. May be null.seven
- The seventh part of the resulting string. May be null.eight
- The eighth part of the resulting string. May be null.nine
- The ninth part of the resulting string. May be null.ten
- The tenth part of the resulting string. May be null.
...
public static java.lang.String substringAfter(java.lang.String str, char separator)
str
- the stringseparator
- the separator
public static java.lang.String substringAfter(java.lang.String str, java.lang.String separator)
str
- the stringseparator
- the separator
public static java.lang.String substringAfterLast(java.lang.String str, char separator)
str
- the stringseparator
- the separator
public static java.lang.String substringAfterLast(java.lang.String str, java.lang.String separator)
str
- the stringseparator
- the separator
public static java.lang.String substringBefore(java.lang.String str, char separator)
str
- the stringseparator
- the separator
public static java.lang.String substringBefore(java.lang.String str, java.lang.String separator)
str
- the stringseparator
- the separator
public static java.lang.String substringBeforeLast(java.lang.String str, char separator)
str
- the stringseparator
- the separator
public static java.lang.String substringBeforeLast(java.lang.String str, java.lang.String separator)
str
- the stringseparator
- the separator
public static java.lang.String switchFirstChar(java.lang.String s, java.lang.String sub)
s
- the String to be modifiedsub
- the String to put in place of the first char of s
public static java.lang.String[] tokenize(java.lang.String source, java.lang.String delims, boolean returnDelims)
source
- The string to split updelims
- identical to the similar argument in java.util.StringTokenizer constructorreturnDelims
- identical to the similar argument in java.util.StringTokenizer constructor
StringTokenizer
public static java.util.List tokenizeToList(java.lang.String source, java.lang.String delims, boolean returnDelims)
source
- The string to split updelims
- identical to the similar argument in java.util.StringTokenizer constructorreturnDelims
- identical to the similar argument in java.util.StringTokenizer constructor
StringTokenizer
public static java.util.Set tokenizeToSet(java.lang.String source, java.lang.String delims, boolean returnDelims)
source
- The string to split updelims
- identical to the similar argument in java.util.StringTokenizer constructorreturnDelims
- identical to the similar argument in java.util.StringTokenizer constructor
StringTokenizer
public static java.lang.String ucFirstChar(java.lang.String s)
s
- the String to be modified
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |