|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.teiid.core.util.StringUtil
public final class StringUtil
This is a common place to put String utility methods.
Nested Class Summary | |
---|---|
static interface |
StringUtil.Constants
|
Field Summary | |
---|---|
static java.util.Comparator |
CASE_INSENSITIVE_ORDER
|
static java.util.Comparator |
CASE_SENSITIVE_ORDER
|
static java.lang.String |
LINE_SEPARATOR
The String that should be used to separate lines; defaults to #NEW_LINE |
static java.lang.String |
LINE_SEPARATOR_PROPERTY_NAME
The name of the System property that specifies the string that should be used to separate lines. |
static java.lang.String |
SINGLE_QUOTE
The String "'" |
Method Summary | ||
---|---|---|
static java.lang.String |
collapseWhitespace(java.lang.String raw)
Removes extraneous whitespace from a string. |
|
static java.lang.String |
computeDisplayableForm(java.lang.String str)
Compute a displayable form of the specified string. |
|
static java.lang.String |
computeDisplayableForm(java.lang.String str,
java.lang.String defaultValue)
Compute a displayable form of the specified string. |
|
static java.lang.String |
computeDisplayableFormOfConstant(java.lang.String text)
|
|
static java.lang.String |
computeDisplayableFormOfConstant(java.lang.String text,
java.lang.String defaultValue)
|
|
static java.lang.String |
computePluralForm(java.lang.String str)
|
|
static java.lang.String |
computePluralForm(java.lang.String str,
java.lang.String defaultValue)
|
|
static java.lang.String |
createFileName(java.lang.String str)
Create a valid filename from the given String. |
|
static java.util.regex.Pattern |
createPattern(java.lang.String pattern,
boolean isCaseSensitive)
Creates a regular expression pattern from the pattern string (which is our old 'StringMatcher' format). |
|
static java.lang.String |
enclosedInSingleQuotes(java.lang.String aString)
Utility to return a string enclosed in ''. |
|
static boolean |
endsWithIgnoreCase(java.lang.String text,
java.lang.String suffix)
Tests if the string ends with the specified suffix. |
|
static java.lang.String |
firstLetterUppercase(java.lang.String str)
Make the first letter uppercase |
|
static java.lang.String |
getFirstToken(java.lang.String str,
java.lang.String delimiter)
Return the first token in the string. |
|
static java.lang.String |
getLastToken(java.lang.String str,
java.lang.String delimiter)
Return the last token in the string. |
|
static java.lang.String[] |
getLines(java.lang.String value)
|
|
static java.lang.String |
getLineSeparator()
|
|
static java.lang.String |
getStackTrace(java.lang.Throwable t)
|
|
static int |
getTokenCount(java.lang.String str,
java.lang.String delimiter)
Return the number of tokens in a string that are seperated by the delimiter. |
|
static java.util.List |
getTokens(java.lang.String str,
java.lang.String delimiter)
Return the tokens in a string in a list. |
|
static int |
indexOfIgnoreCase(java.lang.String text,
java.lang.String str)
Returns the index within this string of the first occurrence of the specified substring. |
|
static boolean |
isBoolean(java.lang.String text)
Returns whether the specified text represents a boolean value, i.e., whether it equals "true" or "false" (case-insensitive). |
|
static boolean |
isDigit(char c)
|
|
static boolean |
isDigits(java.lang.String str)
Determine if the string passed in has all digits as its contents |
|
static boolean |
isEmpty(java.lang.String text)
Returns whether the specified text is either empty or null. |
|
static boolean |
isLetter(char c)
|
|
static boolean |
isLetterOrDigit(char c)
|
|
static boolean |
isValid(java.lang.String str)
|
|
static java.lang.String |
join(java.util.List strings,
java.lang.String delimiter)
Join string pieces and separate with a delimiter. |
|
static int |
occurrences(java.lang.String input,
java.lang.String token)
Return the number of occurrences of token string that occurs in input string. |
|
static java.lang.String |
replace(java.lang.String source,
java.lang.String search,
java.lang.String replace)
|
|
static void |
replaceAll(java.lang.StringBuffer source,
java.lang.String search,
java.lang.String replace)
|
|
static java.lang.String |
replaceAll(java.lang.String source,
java.lang.String search,
java.lang.String replace)
|
|
static java.util.List |
split(java.lang.String str,
java.lang.String splitter)
Split a string into pieces based on delimiters. |
|
static java.util.List |
splitOnEntireString(java.lang.String target,
java.lang.String delimiter)
Break a string into pieces based on matching the full delimiter string in the text. |
|
static java.util.List |
splitPreservingQuotedSubstring(java.lang.String str,
java.lang.String splitter)
Split a string into pieces based on delimiters preserving spaces in quoted substring as on element in the returned list. |
|
static boolean |
startsWithIgnoreCase(java.lang.String text,
java.lang.String prefix)
Tests if the string starts with the specified prefix. |
|
static java.lang.String |
toFixedLength(java.lang.String input,
int desiredLength)
If input == null OR input.length() < desiredLength, pad to desiredLength with spaces. |
|
static java.lang.String |
toLowerCase(java.lang.String str)
|
|
static java.lang.String |
toString(java.lang.Object[] array)
Return a stringified version of the array, using a ',' as a delimiter |
|
static java.lang.String |
toString(java.lang.Object[] array,
java.lang.String delim)
Return a stringified version of the array. |
|
static java.lang.String |
toUpperCase(java.lang.String str)
|
|
static java.lang.String |
truncString(java.lang.String in,
int len)
Simple static method to tuncate Strings to given length. |
|
static
|
valueOf(java.lang.String value,
java.lang.Class type)
Convert the given value to specified type. |
|
static java.lang.String |
wrap(java.lang.String str,
int maxCharPerLine)
Simple utility method to wrap a string by inserting line separators creating multiple lines each with length no greater than the user specified maximum. |
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 SINGLE_QUOTE
public static final java.lang.String LINE_SEPARATOR_PROPERTY_NAME
public static final java.lang.String LINE_SEPARATOR
#NEW_LINE
public static final java.util.Comparator CASE_INSENSITIVE_ORDER
public static final java.util.Comparator CASE_SENSITIVE_ORDER
Method Detail |
---|
public static java.lang.String getLineSeparator()
public static java.lang.String enclosedInSingleQuotes(java.lang.String aString)
public static java.lang.String join(java.util.List strings, java.lang.String delimiter)
strings
- String pieces to joindelimiter
- Delimiter to put between string pieces
split(java.lang.String, java.lang.String)
public static java.lang.String toString(java.lang.Object[] array, java.lang.String delim)
array
- the arraydelim
- the delimiter to use between array components
public static java.lang.String toString(java.lang.Object[] array)
array
- the array
toString(Object[], String)
public static java.util.List split(java.lang.String str, java.lang.String splitter)
str
- Full stringsplitter
- Characters to split on
join(java.util.List, java.lang.String)
public static java.util.List splitOnEntireString(java.lang.String target, java.lang.String delimiter)
target
- The text to break up.delimiter
- The sub-string which is used to break the target.
public static java.util.List splitPreservingQuotedSubstring(java.lang.String str, java.lang.String splitter)
str
- Full stringsplitter
- Characters to split on
join(java.util.List, java.lang.String)
public static java.lang.String replace(java.lang.String source, java.lang.String search, java.lang.String replace)
public static java.lang.String replaceAll(java.lang.String source, java.lang.String search, java.lang.String replace)
public static void replaceAll(java.lang.StringBuffer source, java.lang.String search, java.lang.String replace)
public static java.lang.String truncString(java.lang.String in, int len)
in
- the string that may need tuncating.len
- the lenght that the string should be truncated to.
null
if input String is null
.public static java.lang.String wrap(java.lang.String str, int maxCharPerLine)
str
- the string that may need tuncating.maxCharPerLine
- the max number of characters per line
public static java.util.List getTokens(java.lang.String str, java.lang.String delimiter)
str
- String to be tokenizeddelimiter
- Characters which are delimit tokens
public static int getTokenCount(java.lang.String str, java.lang.String delimiter)
str
- String to be tokenizeddelimiter
- Characters which are delimit tokens
public static int occurrences(java.lang.String input, java.lang.String token)
input
- token
-
public static java.lang.String getLastToken(java.lang.String str, java.lang.String delimiter)
str
- String to be tokenizeddelimiter
- Characters which are delimit tokens
public static java.lang.String getFirstToken(java.lang.String str, java.lang.String delimiter)
str
- String to be tokenizeddelimiter
- Characters which are delimit tokens
public static java.lang.String computeDisplayableForm(java.lang.String str)
str
- String to be converted; may be null
str
, or an empty string if
str
is either null or zero-length; never nullpublic static java.lang.String computeDisplayableForm(java.lang.String str, java.lang.String defaultValue)
An exception is "MetaMatrix", which is always treated as a single word
str
- String to be converted; may be nulldefaultValue
- the default result if the input is either null or zero-length.
str
, or the default value if
str
is either null or zero-length.public static java.lang.String computeDisplayableFormOfConstant(java.lang.String text)
public static java.lang.String computeDisplayableFormOfConstant(java.lang.String text, java.lang.String defaultValue)
public static java.lang.String computePluralForm(java.lang.String str)
public static java.lang.String computePluralForm(java.lang.String str, java.lang.String defaultValue)
public static java.lang.String getStackTrace(java.lang.Throwable t)
public static boolean isBoolean(java.lang.String text)
public static boolean isEmpty(java.lang.String text)
Returns whether the specified text is either empty or null.
text
- The text to check; may be null;
public static int indexOfIgnoreCase(java.lang.String text, java.lang.String str)
isthis.startsWith(str, k)
true
.
text
- any string.str
- any string.
-1
is returned. If the text or
str argument is null or empty then -1
is returned.public static boolean startsWithIgnoreCase(java.lang.String text, java.lang.String prefix)
text
- the string to test.prefix
- the prefix.
true
if the character sequence represented by the
argument is a prefix of the character sequence represented by
this string; false
otherwise.
Note also that true
will be returned if the
prefix is an empty string or is equal to the text
String
object as determined by the
Object.equals(Object)
method. If the text or
prefix argument is null false
is returned.public static boolean endsWithIgnoreCase(java.lang.String text, java.lang.String suffix)
text
- the string to test.suffix
- the suffix.
true
if the character sequence represented by the
argument is a suffix of the character sequence represented by
this object; false
otherwise. Note that the
result will be true
if the suffix is the
empty string or is equal to this String
object
as determined by the Object.equals(Object)
method. If the text or
suffix argument is null false
is returned.public static boolean isDigits(java.lang.String str)
str
-
public static java.util.regex.Pattern createPattern(java.lang.String pattern, boolean isCaseSensitive)
pattern
- The search patternisCaseSensitive
- Set to true
to create a case insensitve pattern
public static java.lang.String collapseWhitespace(java.lang.String raw)
raw
-
public static java.lang.String toFixedLength(java.lang.String input, int desiredLength)
input
- Input textdesiredLength
- Desired length
public static boolean isLetter(char c)
public static boolean isDigit(char c)
public static boolean isLetterOrDigit(char c)
public static boolean isValid(java.lang.String str)
public static java.lang.String toUpperCase(java.lang.String str)
public static java.lang.String toLowerCase(java.lang.String str)
public static java.lang.String createFileName(java.lang.String str)
str
- The String to convert to a valid filename.defaultName
- The default name to use if only special characters exist.
public static java.lang.String firstLetterUppercase(java.lang.String str)
str
-
public static <T> T valueOf(java.lang.String value, java.lang.Class type)
value
- type
-
public static java.lang.String[] getLines(java.lang.String value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |