|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ijsberg.iglu.util.misc.StringSupport
public abstract class StringSupport
Helper class containing string manipulation functions.
| Constructor Summary | |
|---|---|
StringSupport()
|
|
| Method Summary | |
|---|---|
static String |
absorbInputStream(InputStream input)
keep reading until the InputStream is exhausted |
static String |
absorbInputStream(InputStream input,
String encoding)
keep reading until the InputStream is exhausted |
static String |
condenseWhitespace(String haystack)
|
static void |
condenseWhitespace(StringBuffer haystack)
|
static boolean |
containsCharacters(String in,
String chars)
tells whether one or more characters in a String are part of a given String |
static boolean |
containsOnlyCharacters(String in,
String chars)
tells whether all characters in a String are part of a given String |
static int |
count(String haystack,
String needle)
|
static char[] |
createCharArray(int size,
char defaultVal)
Creates a character array and initializes it with a default value. |
static String |
esc(String in)
Escapes quotes, double quotes, ecape characters and end-of-line characters in strings. |
static void |
esc(StringBuffer in)
Escapes quotes, double quotes, ecape characters and end-of-line characters in strings |
static Set |
extractStringsInbetweenTagsFromText(String input,
char startTag,
char endTag,
boolean sort)
reads all strings in a text that are in between certain tags such as '[' and ']' |
static String |
getStackTrace(Throwable t)
Retrieves stack trace from throwable |
static String |
getStackTrace(Throwable t,
int depth)
Retrieves stack trace from throwable. |
static String |
getStackTrace(Throwable t,
int depth,
String prefix)
Retrieves stack trace from throwable. |
static String |
insert(String haystack,
String needle,
int index)
replaces the first occurrence of needle in haystack with newNeedle |
static boolean |
isAlpha(String in)
tells whether all characters in a String are letters |
static boolean |
isAlphaNumeric(String in)
tells whether all characters in a String are digits or letters |
static boolean |
isAlphaNumericOrContainsOnlyCharacters(String in,
String chars)
tells whether all characters in a String are letters or digits or part of a given String |
static boolean |
isNumeric(String in)
tells whether all characters in a String are digits |
static void |
removeAll(StringBuffer haystack,
String needle)
removes all occurances of needle in haystack |
static String |
removeAll(String haystack,
String needle)
removes all occurances of needle in haystack |
static void |
replaceAll(StringBuffer haystack,
String needle,
String newNeedle)
replaces all occurances of needle in haystack with newNeedle the input itself is not modified |
static void |
replaceAll(StringBuffer haystack,
String needle,
String newNeedle,
int interval)
|
static String |
replaceAll(String haystack,
String[] needle,
String[] newNeedle)
Replaces a series of possible occurrences by a series of substitutes. |
static String |
replaceAll(String haystack,
String needle,
String newNeedle)
replaces all occurances of needle in haystack with newNeedle the input itself is not modified |
static String |
replaceAll(String haystack,
String needle,
String newNeedle,
int interval)
|
static void |
replaceFirst(StringBuffer haystack,
String needle,
String newNeedle)
replaces the first occurance of needle in haystack with newNeedle |
static String |
replaceFirst(String haystack,
String needle,
String newNeedle)
|
static void |
replaceLast(StringBuffer haystack,
String needle,
String newNeedle)
replaces the last occurance of needle in haystack with newNeedle |
static String |
replaceLast(String haystack,
String needle,
String newNeedle)
|
static List<String> |
split(String input)
reads all words in a text, words in this case are a series of characters seperated by SPACE, ',', '.' or ':' |
static List<String> |
split(String input,
String punctuationChars)
reads all words in a text, words in this case are a series of characters seperated by SPACE, ',', '.' or ':' |
static List<String> |
split(String input,
String punctuationChars,
boolean sort)
reads all words in a text and converts them to lower case |
static List<String> |
split(String input,
String punctuationChars,
boolean sort,
boolean convertToLowerCase)
reads all words in a text |
static List<String> |
split(String input,
String punctuationChars,
boolean sort,
boolean convertToLowerCase,
boolean distinct)
reads all words in a text |
static List<String> |
split(String input,
String punctuationChars,
String quoteChars)
reads all words in a text and converts them to lower case |
static List<String> |
split(String input,
String punctuationChars,
String quoteSymbols,
boolean sort,
boolean convertToLowerCase,
boolean distinct)
reads all words in a text |
static String |
trim(String input,
int maxNrofChars,
String end)
Trims strings that contain too many characters and adds trailing characters to indicate that the original string has been trimmed. |
static void |
writeToOutputStream(String s,
OutputStream output)
Writes the contents of a string to an output stream. |
static void |
writeToOutputStream(String s,
OutputStream output,
String encoding)
Writes the contents of a string to an output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringSupport()
| Method Detail |
|---|
public static String insert(String haystack,
String needle,
int index)
haystack - input stringneedle - string to placeindex - position to place
public static String replaceFirst(String haystack,
String needle,
String newNeedle)
public static void replaceFirst(StringBuffer haystack,
String needle,
String newNeedle)
haystack - input stringneedle - string to replacenewNeedle - replacement
public static String replaceLast(String haystack,
String needle,
String newNeedle)
public static void replaceLast(StringBuffer haystack,
String needle,
String newNeedle)
haystack - input stringneedle - string to replacenewNeedle - replacement
public static String replaceAll(String haystack,
String needle,
String newNeedle)
haystack - input stringneedle - string to replacenewNeedle - replacementuse StringBuffer input
to do a series of invocations in a row with minimal performance impact
public static String replaceAll(String haystack,
String needle,
String newNeedle,
int interval)
public static String replaceAll(String haystack,
String[] needle,
String[] newNeedle)
haystack - needle - newNeedle -
public static void replaceAll(StringBuffer haystack,
String needle,
String newNeedle)
haystack - input stringneedle - string to replacenewNeedle - replacement
public static void replaceAll(StringBuffer haystack,
String needle,
String newNeedle,
int interval)
public static int count(String haystack,
String needle)
public static String condenseWhitespace(String haystack)
public static void condenseWhitespace(StringBuffer haystack)
public static String removeAll(String haystack,
String needle)
haystack - input stringneedle - string to remove
public static void removeAll(StringBuffer haystack,
String needle)
haystack - input stringneedle - string to removepublic static String esc(String in)
in - input string
public static void esc(StringBuffer in)
in - input stringpublic static boolean isNumeric(String in)
in - String to evaluatepublic static boolean isAlpha(String in)
in - String to evaluatepublic static boolean isAlphaNumeric(String in)
in - String to evaluate
public static boolean isAlphaNumericOrContainsOnlyCharacters(String in,
String chars)
in - String to evaluatechars - characters which are allowed in the given String
public static boolean containsCharacters(String in,
String chars)
in - String to evaluatechars - characters which are to be tested in the given String
public static boolean containsOnlyCharacters(String in,
String chars)
in - String to evaluatechars - characters which are to be tested in the given String
public static String absorbInputStream(InputStream input)
throws IOException
input -
IOException
public static String absorbInputStream(InputStream input,
String encoding)
throws IOException
input -
IOException
public static void writeToOutputStream(String s,
OutputStream output)
throws IOException
s - output -
IOException
public static void writeToOutputStream(String s,
OutputStream output,
String encoding)
throws IOException
s - output - encoding -
IOExceptionpublic static List<String> split(String input)
input -
public static List<String> split(String input,
String punctuationChars)
input - punctuationChars -
public static List<String> split(String input,
String punctuationChars,
boolean sort)
input - punctuationChars - characters that can not belong to words and are therefore separatorssort - indicates if result must be sorted alphabetically
public static List<String> split(String input,
String punctuationChars,
String quoteChars)
input - punctuationChars - characters that can not belong to words and are therefore separators
public static List<String> split(String input,
String punctuationChars,
boolean sort,
boolean convertToLowerCase)
input - punctuationChars - characters that can not belong to words and are therefore separatorssort - whether to sort the result alphabeticallyconvertToLowerCase - whether to convert all found words to lowercase
public static List<String> split(String input,
String punctuationChars,
boolean sort,
boolean convertToLowerCase,
boolean distinct)
input - punctuationChars - characters that can not belong to words and are therefore separatorssort - whether to sort the result alphabetically. (If the result is sorted, setting the distinct flag to false has no effect)convertToLowerCase - whether to convert all found words to lowercasedistinct - true if a certain word may occur only once in the resulting collection
public static List<String> split(String input,
String punctuationChars,
String quoteSymbols,
boolean sort,
boolean convertToLowerCase,
boolean distinct)
input - punctuationChars - characters that can not belong to words and are therefore separatorsquoteSymbols - used as list of characters used to group stringssort - whether to sort the result alphabetically. (If the result is sorted, setting the distinct flag to false has no effect)convertToLowerCase - whether to convert all found words to lower casedistinct - true if a certain word may occur only once in the resulting collection
public static Set extractStringsInbetweenTagsFromText(String input,
char startTag,
char endTag,
boolean sort)
input - startTag - endTag - sort - whether to sort the result alphabetically
public static String getStackTrace(Throwable t)
t -
public static String getStackTrace(Throwable t,
int depth)
t - depth -
public static String getStackTrace(Throwable t,
int depth,
String prefix)
t - depth - prefix -
public static String trim(String input,
int maxNrofChars,
String end)
input - maxNrofChars - maximum allowed length of inputend - trailing characters when trimmed
public static char[] createCharArray(int size,
char defaultVal)
size - defaultVal -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||