|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.pf.text.StringUtil
public class StringUtil
The sole instance of this class provides several convienience methods
for string manipulation such as substring replacement or character
repetition.
It also provides many convenience methods to split up strings and to
handle string arrays.
Get the instance by calling StringUtil.current().
| Field Summary | |
|---|---|
static char |
CH_CR
Constant for the carriage return character |
static char |
CH_NEWLINE
Constant for the new line character |
static char |
CH_SPACE
Constant for the space character |
static char |
CH_TAB
Constant for the tabulator character |
static java.lang.String |
EMPTY_STRING
An empty String to avoid multiple creation of such an object |
static java.lang.String[] |
EMPTY_STRING_ARRAY
An empty String array to avoid multiple creation of such an object |
static java.lang.String |
STR_CR
Constant for the String representation of the carriage return character |
static java.lang.String |
STR_INNER_CLASS_SEPARATOR
Constant that defines the separator for inner classes in full qualified class names ("$") |
static java.lang.String |
STR_NEWLINE
Constant for the String representation of the new line character |
static java.lang.String |
STR_PACKAGE_SEPARATOR
Constant that defines the separator for package elements and classes (".") |
static java.lang.String |
STR_SPACE
Constant for the String representation of the space character |
static java.lang.String |
STR_TAB
Constant for the String representation of the tabulator character |
| Method Summary | |
|---|---|
void |
addAll(java.util.Collection collection,
java.lang.String[] strings)
Adds all given strings to the specified collection. |
void |
addAllNew(java.util.Collection collection,
java.lang.String[] strings)
Adds all given strings to the specified collection, if they are not already in the collection. |
java.lang.String[] |
allParts(java.lang.String text,
java.lang.String separators)
Returns an array of substrings of the given text. |
java.lang.String[] |
allParts(java.lang.String text,
java.lang.String separators,
char quoteChar)
Returns an array of substrings of the given text. |
java.lang.String[] |
allParts(java.lang.String text,
java.lang.String separators,
char[] quoteChars)
Returns an array of substrings of the given text. |
java.lang.String[] |
allSubstrings(java.lang.String text,
java.lang.String separator)
Returns the given text split up into an array of strings, at the occurrences of the separator string. |
java.lang.String[] |
append(java.lang.String[] strings,
java.lang.String string)
Returns the given string array extended by one element that hold the specified string. |
java.lang.String[] |
append(java.lang.String[] strings,
java.lang.String[] appendStrings)
Returns an array of strings that contains all strings given by the first and second string array. |
java.lang.String[] |
appendIfNotThere(java.lang.String[] strings,
java.lang.String appendString)
Returns an array of strings that contains all strings given in the first plus the specified string to append, if it is not already in the given array. |
java.lang.String[] |
appendIfNotThere(java.lang.String[] strings,
java.lang.String[] appendStrings)
Returns an array of strings that contains all strings given in the first plus all strings of the second array that are not already in the first array. |
boolean |
areEqual(java.lang.String[] strings1,
java.lang.String[] strings2)
Returns true if all elements of the first given array are in the second given array and the length of both arrays are equal. |
boolean |
areEqualIgnoreCase(java.lang.String[] strings1,
java.lang.String[] strings2)
Returns true if all elements of the first given array are in the second given array and the length of both arrays are equal. |
java.util.Map |
asMap(java.lang.String str)
Returns a new map object that contains all key-value pairs of the specified string. |
java.util.Map |
asMap(java.lang.String str,
java.lang.String elementSeparator)
Returns a new map object that contains all key-value pairs of the specified string. |
java.util.Map |
asMap(java.lang.String str,
java.lang.String elementSeparator,
java.lang.String keyValueSeparator)
Returns a new map object that contains all key-value pairs of the specified string. |
java.util.Properties |
asProperties(java.lang.String str)
Adds all key-value pairs of the given string to a new properties object. |
java.lang.String |
asSortedString(java.lang.String[] strings)
Returns a string that contains all given strings sorted (in ascending order), concatenated and separated by the specified separator. |
java.lang.String |
asSortedString(java.lang.String[] strings,
java.lang.String separator)
Returns a string that contains all given strings sorted (in ascending order), concatenated and separated by the specified separator. |
java.lang.String |
asSortedString(java.lang.String[] strings,
java.lang.String separator,
boolean ascending)
Returns a string that contains all given strings sorted, concatenated and separated by the specified separator. |
java.lang.String |
asSortedString(java.lang.String[] strings,
java.lang.String separator,
java.util.Comparator comparator)
Returns a string that contains all given strings sorted, concatenated and separated by the specified separator. |
java.lang.String |
asString(char ch)
Returns a new string that contains only the given character. |
java.lang.String |
asString(java.util.Collection strings)
Returns a string that contains all strings from the given collection concatenated and separated by comma. |
java.lang.String |
asString(java.util.Collection strings,
java.lang.String separator)
Returns a string that contains all strings from the given collection concatenated and separated by the specified separator. |
java.lang.String |
asString(java.util.Map map)
Converts the given map to a string. |
java.lang.String |
asString(java.util.Map map,
java.lang.String elementSeparator)
Converts the given map to a string utilizing the given separator. |
java.lang.String |
asString(java.util.Map map,
java.lang.String elementSeparator,
java.lang.String keyValueSeparator)
Converts the given map to a string utilizing the given separators. |
java.lang.String |
asString(java.lang.String[] strings)
Returns a string that contains all given strings concatenated and separated by comma. |
java.lang.String |
asString(java.lang.String[] strings,
java.lang.String separator)
Returns a string that contains all given strings concatenated and separated by the specified separator. |
java.lang.String[] |
asStrings(java.util.Collection collection)
Returns a string array containing all elements of the given collection. |
java.lang.String |
center(java.lang.String str,
int len)
Returns the given string filled (on the right and right) up to the specified length with spaces. |
java.lang.String |
centerCh(java.lang.String str,
int len,
char ch)
Returns the given string filled equally left and right up to the specified length with the given character. |
boolean |
contains(java.lang.String[] strArray,
java.lang.String searchStr)
Returns whether or not the specified string can be found in the given string array. |
boolean |
contains(java.lang.String[] strArray,
java.lang.String searchStr,
boolean ignoreCase)
Returns whether or not the specified string can be found in the given string array. |
boolean |
contains(java.lang.String[] strArray,
StringPattern pattern)
Returns whether or not a string can be found in the given string array that matches the specified string pattern. |
boolean |
containsIgnoreCase(java.lang.String[] strArray,
java.lang.String searchStr)
Returns whether or not the specified string can be found in the given string array. |
java.util.Collection |
copy(java.util.Collection strings,
StringFilter filter)
Returns a new array that contains all strings of the given array that matched the specified filter. |
java.lang.String[] |
copy(java.lang.String[] strings)
Returns a copy (new array) that contains all the strings of the given array |
java.lang.String[] |
copy(java.lang.String[] strings,
StringFilter filter)
Returns a new array that contains all strings of the given array that matched the specified filter. |
java.lang.String[] |
copyFrom(java.lang.String[] from,
int start)
Returns all elements of string array from in a new array from index start up to the end. |
java.lang.String[] |
copyFrom(java.lang.String[] from,
int start,
int end)
Returns all elements of string array from in a new array from index start up to index end (inclusive). |
java.lang.String[] |
copyLowerCase(java.lang.String[] strings)
Returns a copy of the given string array where all elements are converted to lower case. |
java.lang.String[] |
copyUpperCase(java.lang.String[] strings)
Returns a copy of the given string array where all elements are converted to upper case. |
java.util.Collection |
copyWithout(java.util.Collection strings,
StringFilter filter)
Returns a new collection that contains all strings of the given collection that do NOT match the specified filter. |
java.lang.String[] |
copyWithout(java.lang.String[] strings,
StringFilter filter)
Returns a new array that contains all strings of the given array that do NOT match the specified filter. |
int |
count(java.lang.String sourceStr,
java.lang.String subStr)
Returns how often the given sub string occurs in the source String. |
static StringUtil |
current()
Returns the one and only instance of this class. |
java.lang.String |
cutHead(java.lang.String text,
java.lang.String separator)
Returns the portion of the given string that comes after the last occurrence of the specified separator. |
java.lang.String |
cutTail(java.lang.String text,
java.lang.String separator)
Returns the portion of the given string that comes before the last occurrence of the specified separator. |
java.lang.String |
getDelimitedSubstring(java.lang.String text,
IStringPair delimiter)
Returns the first substring that is enclosed by the specified delimiter pair. |
java.lang.String |
getDelimitedSubstring(java.lang.String text,
IStringPair[] delimiters)
Returns the first substring that is enclosed by one of the specified delimiter pairs. |
java.lang.String |
getDelimitedSubstring(java.lang.String text,
java.lang.String delimiter)
Returns the first substring that is enclosed by the specified delimiter. |
java.lang.String |
getDelimitedSubstring(java.lang.String text,
java.lang.String startDelimiter,
java.lang.String endDelimiter)
Returns the first substring that is enclosed by the specified delimiters. |
java.lang.String |
getPackageName(java.lang.String qualifiedClassName)
Returns the package name of the given full qualified class name. |
java.lang.String |
getUnqualifiedClassName(java.lang.String qualifiedClassName)
Returns the class name without the package name. |
int |
indexOf(char[] charArray,
char ch,
boolean ignoreCase)
Returns the index of the specified character in the given char array. |
int |
indexOf(java.lang.String[] strArray,
java.lang.String searchStr)
Returns the index of the specified string in the given string array. |
int |
indexOf(java.lang.String[] strArray,
StringPattern pattern)
Returns the index of the first string in the given string array that matches the specified string pattern. |
int |
indexOfIgnoreCase(java.lang.String[] strArray,
java.lang.String searchStr)
Returns the index of the specified string in the given string array. |
int |
indexOfString(java.lang.String[] strArray,
java.lang.String searchStr,
boolean ignoreCase)
Returns the index of the specified string in the given string array. |
boolean |
isNullOrBlank(java.lang.String str)
Returns true if the given string is null or empty or consists of whitespace characters only. |
boolean |
isNullOrEmpty(java.lang.String str)
Returns true if the given string is null or empty |
boolean |
isNullOrEmpty(java.lang.String[] strings)
Returns true if the given string array is null or empty |
java.lang.String |
leftPad(int value,
int len)
Returns the given integer as string filled (on the left) up to the specified length with zeroes. |
java.lang.String |
leftPad(long value,
int len)
Returns the given long as string filled (on the left) up to the specified length with zeroes. |
java.lang.String |
leftPad(java.lang.String str,
int len)
Returns the given string filled (on the left) up to the specified length with spaces. |
java.lang.String |
leftPadCh(int value,
int len,
char fillChar)
Returns the given integer as string filled (on the left) up to the specified length with the given fill character. |
java.lang.String |
leftPadCh(long value,
int len,
char fillChar)
Returns the given long as string filled (on the left) up to the specified length with the given fill character. |
void |
leftPadCh(java.lang.StringBuffer buffer,
long value,
int len,
char fillChar)
Returns the given long as string filled (on the left) up to the specified length with the given fill character. |
java.lang.String |
leftPadCh(java.lang.String str,
int len,
char ch)
Returns the given string filled (on the left) up to the specified length with the given character. |
java.lang.String[] |
parts(java.lang.String text,
java.lang.String separators)
Returns an array of substrings of the given text. |
java.lang.String[] |
parts(java.lang.String text,
java.lang.String separators,
char quoteChar)
Returns an array of substrings of the given text. |
java.lang.String[] |
parts(java.lang.String text,
java.lang.String separators,
char[] quoteChars)
Returns an array of substrings of the given text. |
java.lang.String |
prefix(java.lang.String str,
java.lang.String separator)
Returns the substring of the given string that comes before the first occurrence of the specified separator. |
java.lang.String[] |
remove(java.lang.String[] strings,
java.lang.String removeString)
Removes the given string from the specified string array. |
java.lang.String[] |
remove(java.lang.String[] strings,
java.lang.String[] removeStrings)
Removes all string of the second array from the first array. |
java.lang.String[] |
removeNull(java.lang.String[] strings)
Removes all null values from the given string array. |
java.lang.String |
repeat(char ch,
int count)
Returns a string with size of count and all characters initialized with ch. |
java.lang.String |
replaceAll(java.lang.String sourceStr,
java.lang.String oldSubStr,
java.lang.String newSubStr)
Returns the given string with all found oldSubStr replaced by newSubStr. |
java.lang.String |
replaceEach(java.lang.String sourceStr,
java.lang.String oldChars,
java.lang.String newChars)
Returns the given sourceString with all characters occurring in oldChars replaced by the characters at the corresponding index in newChars. |
java.lang.String |
reverse(java.lang.String str)
Returns a string that contains all characters of the given string in reverse order. |
java.lang.String |
rightPad(int value,
int len)
Returns the given integer as string filled (on the right) up to the specified length with spaces. |
java.lang.String |
rightPad(long value,
int len)
Returns the given integer as string filled (on the right) up to the specified length with spaces. |
java.lang.String |
rightPad(java.lang.String str,
int len)
Returns the given string filled (on the right) up to the specified length with spaces. |
java.lang.String |
rightPadCh(int value,
int len,
char fillChar)
Returns the given integer as string filled (on the right) up to the specified length with the given character. |
java.lang.String |
rightPadCh(long value,
int len,
char fillChar)
Returns the given long as string filled (on the right) up to the specified length with the given character. |
java.lang.String |
rightPadCh(java.lang.String str,
int len,
char ch)
Returns the given string filled (on the right) up to the specified length with the given character. |
java.lang.String |
setFileNameExtension(java.lang.String filename,
java.lang.String extension,
boolean replace)
Sets the given extension as filename extension to the given filename. |
java.lang.String[] |
splitNameValue(java.lang.String str,
java.lang.String separator)
Returns a string array with two elements where the first is the attribute name and the second is the attribute value. |
IStringPair |
splitStringPair(java.lang.String str,
java.lang.String separator)
Returns a string pair where the first is the string before the first occurrence of the defined separator and the second string is everything after that separator. |
java.lang.String |
stackTrace(java.lang.Throwable throwable)
Prints the stack trace of the specified throwable to a string and returns it. |
java.lang.String |
startingFrom(java.lang.String str,
java.lang.String separator)
Returns the substring of the given string that comes after the first occurrence of the specified separator. |
java.lang.String[] |
substrings(java.lang.String text,
java.lang.String separator)
Returns the given text split up into an array of strings, at the occurrences of the separator string. |
java.lang.String |
suffix(java.lang.String str,
java.lang.String separator)
Returns the substring of the given string that comes after the first occurrence of the specified separator. |
void |
toLowerCase(java.lang.String[] strings)
Modifies the strings in the given array to be all lower case. |
java.util.Map |
toMap(java.lang.String str,
java.util.Map map)
Adds all key-value pairs of the given string to the specified map. |
java.util.Map |
toMap(java.lang.String str,
java.lang.String elementSeparator,
java.util.Map map)
Returns the given map object with all key-value pairs of the specified string added to it. |
java.util.Map |
toMap(java.lang.String str,
java.lang.String elementSeparator,
java.lang.String keyValueSeparator,
java.util.Map map)
Returns the given map with new entries from the specified String. |
java.util.Properties |
toProperties(java.lang.String str,
java.util.Properties properties)
Adds all key-value pairs of the given string to the specified properties. |
void |
toUpperCase(java.lang.String[] strings)
Modifies the strings in the given array to be all upper case. |
java.lang.String[] |
trimmedParts(java.lang.String text,
java.lang.String separators)
Returns an array of substrings of the given text. |
java.lang.String |
upTo(java.lang.String str,
java.lang.String separator)
Returns the substring of the given string that comes before the first occurrence of the specified separator. |
java.lang.String[] |
words(java.lang.String text)
Returns an array of substrings of the given text. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char CH_SPACE
public static final char CH_NEWLINE
public static final char CH_CR
public static final char CH_TAB
public static final java.lang.String STR_SPACE
public static final java.lang.String STR_NEWLINE
public static final java.lang.String STR_CR
public static final java.lang.String STR_TAB
public static final java.lang.String STR_PACKAGE_SEPARATOR
public static final java.lang.String STR_INNER_CLASS_SEPARATOR
public static final java.lang.String EMPTY_STRING
public static final java.lang.String[] EMPTY_STRING_ARRAY
| Method Detail |
|---|
public static StringUtil current()
public void addAll(java.util.Collection collection,
java.lang.String[] strings)
collection - The collection to which the strings are addedstrings - The strings to add to the collection
public void addAllNew(java.util.Collection collection,
java.lang.String[] strings)
collection - The collection to which the strings are addedstrings - The strings to add to the collection
public java.lang.String replaceAll(java.lang.String sourceStr,
java.lang.String oldSubStr,
java.lang.String newSubStr)
sourceStr - The string that should be checked for occurrences of oldSubStroldSubStr - The string that is searched for in sourceStrnewSubStr - The new string that is placed everywhere the oldSubStr was found
public java.lang.String replaceEach(java.lang.String sourceStr,
java.lang.String oldChars,
java.lang.String newChars)
sourceStr - The string in which to replace the charactersoldChars - The characters that must be replaced in sourceStringnewChars - The characters that must be used instead of the old characters
public int count(java.lang.String sourceStr,
java.lang.String subStr)
sourceStr - The string that should be checked for occurrences of subStr (must not be null)subStr - The string that is searched for in sourceStr (must not be null)
public java.lang.String repeat(char ch,
int count)
ch - the character to be repeated in the result string.count - the number of times the given character should occur in the result string.
public java.lang.String[] words(java.lang.String text)
text - The string that should be split up into whitespace separated words
parts(String, String)
public java.lang.String[] trimmedParts(java.lang.String text,
java.lang.String separators)
text - The string that should be split up into substringsseparators - All characters that should be recognized as a separator of substrings
parts(String, String),
allParts(String, String),
substrings(String, String),
allSubstrings(String, String)
public java.lang.String[] parts(java.lang.String text,
java.lang.String separators)
text - The string that should be split up into substringsseparators - All characters that should be recognized as a separator of substrings
parts(String, String, char),
allParts(String, String),
substrings(String, String),
allSubstrings(String, String)
public java.lang.String[] parts(java.lang.String text,
java.lang.String separators,
char quoteChar)
Examples:
parts( "A,B,C", ",", '*' ) --> { "A", "B", "C" }
parts( "A,*B,C*", ",", '*' ) --> { "A", "B,C" }
parts( "%A,B;C%;D;E", ";,", '%' ) --> { "A,B;C", "D", "E" }
text - The string that should be split up into substringsseparators - All characters that should be recognized as a separator of substringsquoteChar - A character that is used to enclose string that might contain a separator
parts(String, String),
allParts(String, String),
substrings(String, String),
allSubstrings(String, String)
public java.lang.String[] parts(java.lang.String text,
java.lang.String separators,
char[] quoteChars)
The quote characters define that strings enclosed in a pair of such a quote character can contain separators and will not be split up.
text - The string that should be split up into substringsseparators - All characters that should be recognized as a separator of substringsquoteChars - All characters that can be used to enclose strings that might contain a separator
parts(String, String),
allParts(String, String),
substrings(String, String),
allSubstrings(String, String)
public java.lang.String[] allParts(java.lang.String text,
java.lang.String separators)
Examples:
allParts( "/A/B//", "/" ) --> { "A", "B", "" }
allParts( "/A,B/C;D", ",;/" ) --> { "A", "B", "C", "D" }
allParts( "A/B,C/D", "," ) --> { "A/B", "C/D" }
text - The string that should be split up into substringsseparators - All characters that should be recognized as a separator of substrings
parts(String, String),
substrings(String, String),
allSubstrings(String, String)
public java.lang.String[] allParts(java.lang.String text,
java.lang.String separators,
char quoteChar)
Examples:
allParts( "/A/B//'C/D'", "/", '\'' ) --> { "A", "B", "", "C/D" }
allParts( "/A,\"B/C\";,;D", ",;/", '"' ) --> { "A", "B/C", "", "", "D" }
text - The string that should be split up into substringsseparators - All characters that should be recognized as a separator of substringsquoteChar - A character that is used to enclose string that might contain a separator
parts(String, String),
substrings(String, String),
allSubstrings(String, String)
public java.lang.String[] allParts(java.lang.String text,
java.lang.String separators,
char[] quoteChars)
The quote character define the delimiters to be used to enclose sub-strings that contain separators but must not be split-up into different parts.
text - The string that should be split up into substringsseparators - All characters that should be recognized as a separator of substringsquoteChars - The characters that are used to enclose strings that might contain a separator
parts(String, String),
substrings(String, String),
allSubstrings(String, String)
public java.lang.String[] substrings(java.lang.String text,
java.lang.String separator)
text - The text to be split upseparator - The string that separates the substrings
allSubstrings(String, String),
parts(String, String),
allParts(String, String)
public java.lang.String[] allSubstrings(java.lang.String text,
java.lang.String separator)
text - The text to be split upseparator - The string that separates the substrings
substrings(String, String),
parts(String, String),
allParts(String, String)
public java.lang.String getDelimitedSubstring(java.lang.String text,
IStringPair[] delimiters)
text - The input string that contains the delimited part.delimiters - The start and end delimiters to be looked for.
public java.lang.String getDelimitedSubstring(java.lang.String text,
IStringPair delimiter)
text - The input string that contains the delimited part.delimiter - The start and end delimiter to be looked for.
public java.lang.String getDelimitedSubstring(java.lang.String text,
java.lang.String startDelimiter,
java.lang.String endDelimiter)
Example:
getDelimitedSubstring( "This {placeholder} belongs to me", "{", "}" )
--> returns "placeholder"
text - The input string that contains the delimited partstartDelimiter - The start delimiter of the substringendDelimiter - The end delimiter of the substring
public java.lang.String getDelimitedSubstring(java.lang.String text,
java.lang.String delimiter)
Example:
getDelimitedSubstring( "File 'text.txt' not found.", "'", "'" )
--> returns "text.txt"
text - The input string that contains the delimited partdelimiter - The start and end delimiter of the substring
public java.lang.String stackTrace(java.lang.Throwable throwable)
public java.lang.String leftPadCh(java.lang.String str,
int len,
char ch)
public java.lang.String leftPad(java.lang.String str,
int len)
str - The string that has to be filled up to the specified lengthlen - The length of the result string
public java.lang.String leftPadCh(int value,
int len,
char fillChar)
public java.lang.String leftPad(int value,
int len)
public java.lang.String leftPadCh(long value,
int len,
char fillChar)
public void leftPadCh(java.lang.StringBuffer buffer,
long value,
int len,
char fillChar)
buffer - The buffer to append the result to.value - The value to fill-up to the specified length.len - The length of the resulting string.fillChar - The character to use for filling up.
public java.lang.String leftPad(long value,
int len)
public java.lang.String rightPadCh(java.lang.String str,
int len,
char ch)
public java.lang.String rightPad(java.lang.String str,
int len)
public java.lang.String rightPadCh(int value,
int len,
char fillChar)
public java.lang.String rightPad(int value,
int len)
public java.lang.String rightPadCh(long value,
int len,
char fillChar)
public java.lang.String rightPad(long value,
int len)
public java.lang.String centerCh(java.lang.String str,
int len,
char ch)
public java.lang.String center(java.lang.String str,
int len)
public java.lang.String[] append(java.lang.String[] strings,
java.lang.String string)
public java.lang.String[] append(java.lang.String[] strings,
java.lang.String[] appendStrings)
strings - The array of string to which to appendappendStrings - The string to be appended to the first array
public java.lang.String[] appendIfNotThere(java.lang.String[] strings,
java.lang.String appendString)
public java.lang.String[] appendIfNotThere(java.lang.String[] strings,
java.lang.String[] appendStrings)
public java.lang.String[] remove(java.lang.String[] strings,
java.lang.String[] removeStrings)
strings - The array from which to remove the stringsremoveStrings - The strings to be removed
public java.lang.String[] remove(java.lang.String[] strings,
java.lang.String removeString)
strings - The array from which to remove the stringremoveString - The string to be removedpublic java.lang.String[] removeNull(java.lang.String[] strings)
strings - The array to be cleared of null valuespublic java.lang.String asString(java.lang.String[] strings)
strings - The array of strings that should be concatenated
public java.lang.String asString(java.lang.String[] strings,
java.lang.String separator)
strings - The array of strings that should be concatenatedseparator - The separator between the strings (if null the default is used)
public java.lang.String asString(java.util.Collection strings)
strings - The collection of strings that should be concatenated
public java.lang.String asString(java.util.Collection strings,
java.lang.String separator)
strings - The collection of strings that should be concatenatedseparator - The separator between the strings
public java.lang.String asSortedString(java.lang.String[] strings)
Example: asSortedString( new String[] {"Carmen","Rose","Anna","Rita"} )
returns "Anna,Carmen,Rita,Rose"
strings - The array of strings that should be concatenated
public java.lang.String asSortedString(java.lang.String[] strings,
java.lang.String separator)
Example: asSortedString( new String[] {"Mike","Ben","Gil"}, "/")
returns "Ben/Gil/Mike"
strings - The array of strings that should be concatenatedseparator - The separator between the strings (must not be null)
public java.lang.String asSortedString(java.lang.String[] strings,
java.lang.String separator,
boolean ascending)
Example: asSortedString( new String[] {"Fred","Sam","Joe"}, ";", false)
returns "Sam;Joe;Fred"
strings - The array of strings that should be concatenatedseparator - The separator between the strings (must not be null)ascending - If true the strings are sorted ascending otherwise descending
public java.lang.String asSortedString(java.lang.String[] strings,
java.lang.String separator,
java.util.Comparator comparator)
strings - The array of strings that should be concatenatedseparator - The separator between the strings (must not be null)comparator - A comparater that is used to compare the strings when sorting (must not be null)
public java.lang.String[] asStrings(java.util.Collection collection)
collection - A collection of strings
public java.lang.String asString(java.util.Map map,
java.lang.String elementSeparator,
java.lang.String keyValueSeparator)
map - The map that contains the key-value pairselementSeparator - The separator between the elements in the string representationkeyValueSeparator - The separator between the keys and values in the string representationtoMap(String, String, String, Map)
public java.lang.String asString(java.util.Map map,
java.lang.String elementSeparator)
map - The map that contains the key-value pairselementSeparator - The separator between the elements in the string representationasString(Map, String, String),
toMap(String, String, String, Map)public java.lang.String asString(java.util.Map map)
map - The map that contains the key-value pairsasString(Map, String, String),
toMap(String, String, String, Map)
public int indexOf(java.lang.String[] strArray,
StringPattern pattern)
strArray - An array of string (may contain null elements)pattern - The pattern the searched string must match
public int indexOf(java.lang.String[] strArray,
java.lang.String searchStr)
strArray - An array of string (may contain null elements)searchStr - The string to be looked up in the array (null allowed)
public int indexOfIgnoreCase(java.lang.String[] strArray,
java.lang.String searchStr)
strArray - An array of string (may contain null elements)searchStr - The string to be looked up in the array (null allowed)
public int indexOfString(java.lang.String[] strArray,
java.lang.String searchStr,
boolean ignoreCase)
strArray - An array of string (may contain null elements)searchStr - The string to be looked up in the array (null allowed)ignoreCase - If true, do case-insensitive comparison.
public int indexOf(char[] charArray,
char ch,
boolean ignoreCase)
charArray - An array of string (may contain null elements)ch - The string to be looked up in the array (null allowed)ignoreCase - If comparison should be case-insensitive
public boolean contains(java.lang.String[] strArray,
java.lang.String searchStr,
boolean ignoreCase)
strArray - An array of string (may contain null elements)searchStr - The string to be looked up in the array (null allowed)ignoreCase - Defines whether or not the comparison is case-sensitive.
public boolean contains(java.lang.String[] strArray,
StringPattern pattern)
strArray - An array of string (may contain null elements)pattern - The string pattern to match against in the array (null allowed)
public boolean contains(java.lang.String[] strArray,
java.lang.String searchStr)
strArray - An array of string (may contain null elements)searchStr - The string to be looked up in the array (null allowed)
public boolean containsIgnoreCase(java.lang.String[] strArray,
java.lang.String searchStr)
strArray - An array of string (may contain null elements)searchStr - The string to be looked up in the array (null allowed)
public java.lang.String[] copyFrom(java.lang.String[] from,
int start)
from - The string array the elements should be copied fromstart - Index of the first element to copy
public java.lang.String[] copyFrom(java.lang.String[] from,
int start,
int end)
from - The string array the elements should be copied fromstart - Index of the first element to copyend - Index of last element to be copied
public java.lang.String[] copy(java.lang.String[] strings,
StringFilter filter)
strings - The string array to copy from (must not be null)filter - The filter that determines which strings to copy (if null an empty array will be returned)public java.lang.String[] copy(java.lang.String[] strings)
public java.lang.String[] copyWithout(java.lang.String[] strings,
StringFilter filter)
strings - The string array to copy from (must not be null)filter - The filter that determines which strings to copy (if null an empty array will be returned)
public java.util.Collection copy(java.util.Collection strings,
StringFilter filter)
strings - A collection of strings to copy from (must not be null)filter - The filter that determines which strings to copy (if null an empty collection will be returned)
public java.util.Collection copyWithout(java.util.Collection strings,
StringFilter filter)
strings - A collection of strings to copy from (must not be null)filter - The filter that determines which strings to copy (if null an empty collection will be returned)
public java.lang.String cutTail(java.lang.String text,
java.lang.String separator)
Examples:
cutTail( "A/B/C", "/" ) ; // returns "A/B"
cutTail( "A/B/C", "," ) ; // returns "A/B/C"
text - The string from which to cut off the tailseparator - The separator from where to cut off
prefix( String, String ),
suffix( String, String ),
cutHead( String, String ),
startingFrom( String, String ),
upTo( String, String )
public java.lang.String cutHead(java.lang.String text,
java.lang.String separator)
Examples:
cutHead( "A/B/C", "/" ) ; // returns "C"
cutHead( "A/B/C", "," ) ; // returns "A/B/C"
text - The string from which to cut off the headseparator - The separator up to which to cut off
prefix( String, String ),
cutTail( String, String ),
suffix( String, String ),
startingFrom( String, String ),
upTo( String, String )
public java.lang.String[] splitNameValue(java.lang.String str,
java.lang.String separator)
str - The string that contains the name-value pairseparator - The separator between name and value
public IStringPair splitStringPair(java.lang.String str,
java.lang.String separator)
str - The string that contains the name-value pairseparator - The separator between name and value
public java.lang.String prefix(java.lang.String str,
java.lang.String separator)
Examples:
prefix( "A/B/C", "/" ) ; // returns "A"
prefix( "A/B/C", "," ) ; // returns null
str - The string of which the prefix is desiredseparator - Separates the prefix from the rest of the stringsuffix( String, String ),
cutTail( String, String ),
cutHead( String, String ),
startingFrom( String, String ),
upTo( String, String )
public java.lang.String suffix(java.lang.String str,
java.lang.String separator)
Examples:
suffix( "A/B/C", "/" ) ; // returns "B/C"
suffix( "A/B/C", "," ) ; // returns null
str - The string of which the suffix is desiredseparator - Separates the suffix from the rest of the string