com.jaxfront.core.util
Class StringUtil

java.lang.Object
  extended by com.jaxfront.core.util.StringUtil

public class StringUtil
extends java.lang.Object


Field Summary
static java.lang.String AMP
           
static char carriageReturnChar
           
static char[] charCarriageReturnArr
           
static char[] charNewLineArr
           
static java.lang.String doubleQuote
           
static java.lang.String[] empty
           
static java.lang.String[] freeMarker_Escape
           
static char[] freeMarker_Unescape
           
static java.lang.String GREATER
           
static java.util.Comparator IGNORE_CASE_NATURAL_COMPARATOR_ASCII
           A string comparator that does case insensitive comparisons and handles embedded numbers correctly.
static char[] javaCharLiterals
           
static java.lang.String[] javaLiterals
           
static char[] jax_protokol_escape
           
static java.lang.String[] jax_protokol_unescape
           
static java.lang.String LESS
           
static java.util.Comparator NATURAL_COMPARATOR_ASCII
           A string comparator that does case sensitive comparisons and handles embedded numbers correctly.
static java.lang.String newLine
           
static char newLineChar
           
static java.lang.String newTab
           
static char NOT_AN_CHAR
           
static java.lang.String QUOT
           
static java.lang.String space
           
static char[] sqlCharLiterals
           
static java.lang.String[] sqlLiterals
           
static java.util.Comparator TO_STRING_COMPARATOR
           
static char[] URL_SPECIAL_ENC
           
static java.lang.String[] URL_SPECIAL_ENC_DEST
           
static java.lang.String XML_AMP
           
static java.lang.String XML_GREATER
           
static java.lang.String XML_LESS
           
static java.lang.String XML_QUOT
           
 
Constructor Summary
StringUtil()
           
 
Method Summary
static java.lang.String addIfNotEndWith(java.lang.String value, java.lang.String add)
           
static java.lang.String appendCount(java.lang.String source)
           
static java.lang.String appendNotNull(java.lang.String stra, java.lang.String strb, java.lang.String delim)
          Concatenate stra and strb using delim.
static boolean checkDistance(java.lang.String source, char[] aChar, int distance)
           
static boolean checkDistance(java.lang.String source, char aChar, int distance)
           
static int compareNatural(java.text.Collator collator, java.lang.String s, java.lang.String t)
           Compares two strings using the given collator and comparing contained numbers based on their numeric values.
static int compareNatural(java.lang.String s, java.lang.String t)
           Compares two strings using the current locale's rules and comparing contained numbers based on their numeric values.
static int compareNaturalAscii(java.lang.String s, java.lang.String t)
           Compares two strings using each character's Unicode value for non-digit characters and the numeric values off any contained numbers.
static int compareNaturalIgnoreCaseAscii(java.lang.String s, java.lang.String t)
           Compares two strings using each character's Unicode value - ignoring upper/lower case - for non-digit characters and the numeric values of any contained numbers.
static boolean containsAny(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string contains any of the given terms.
static boolean containsAnyIgnoreCase(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string contains any of the given terms.
static java.lang.String convertToCamelCase(java.lang.String cn, java.lang.String regex)
           
static int countTokens(java.lang.String value, char token, boolean retDelims)
          Calculates the number of times that this tokenizer's 5 Times faster as use of StringTokenizer.countTokens()
static java.lang.String cut(java.lang.String string, int length)
           
static java.lang.String cut(java.lang.String string, int length, java.lang.String cutTail)
           
static java.lang.String decodeJaxProtokolFromURL(java.lang.String data)
           
static java.lang.String encodeJaxProtokolToURL(java.lang.String data)
           
static boolean endsWithAny(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string ends with any of the given terms.
static boolean endsWithAnyIgnoreCase(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string ends with any of the given terms.
static boolean equals(java.lang.Object val1, java.lang.Object val2)
           
static boolean equals(java.lang.String val1, java.lang.String val2)
           
static boolean equalsAny(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string equals any of the given terms.
static boolean equalsAnyIgnoreCase(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string equals any of the given terms.
static java.lang.String escape(java.lang.String s, java.lang.String what, java.lang.String with)
           
static java.lang.String escapeHTML(java.lang.String s)
          Replaces characters that may be confused by a HTML parser with their equivalent character entity references.
static java.lang.String escapeJavaLiteral(java.lang.String s)
          Replaces characters that are not allowed in a Java style string literal with their escape characters.
static java.lang.String escapeJavaScript(java.lang.String value)
           
static java.lang.String escapeLiteral(java.lang.String s, char what, java.lang.String with)
           
static java.lang.String escapeRegularExpressionLiteral(java.lang.String s)
          Escapes characters that have special meaning to regular expressions
static java.lang.String escapeSQL(java.lang.String s)
          Replaces characters that may be confused by an SQL parser with their equivalent escape characters.
static java.lang.String[] escapeSQL(java.lang.String[] lookupValues)
           
static java.lang.String escapeSQLLiteral(java.lang.String s)
           
static java.lang.String escapeToURLEncoding(java.lang.String value)
           
static java.lang.String escapeXML(java.lang.String s)
           
static int extractInt(java.lang.String mixedString)
          Extract an int for the given mixed integer string like 1qwerts or qwer1ts oer qwertz1.
static java.lang.String extractIntAsString(java.lang.String mixedString)
          Extract an int for the given mixed integer string like 1qwerts or qwer1ts oer qwertz1.
static java.lang.String fillWith(int length, java.lang.String fillWith, java.lang.String source)
           
static java.lang.String format(boolean left, char fill, int size, java.lang.String text)
          Returns a formatted string.
static void format(boolean left, char fill, int size, java.lang.String text, java.lang.StringBuffer buffer)
          Formats a specified string and appends the formatted string to the buffer.
static java.util.List getAllBetween(java.lang.String text, java.lang.String from, java.lang.String to)
           
static java.util.List getAllBetween(java.lang.String text, java.lang.String from, java.lang.String to, java.lang.String breakChars)
           
static java.util.List getAllBetween(java.lang.String text, java.lang.String from, java.lang.String to, java.lang.String breakChars, char openBracket, char closeBracket)
           
static java.util.List getAllBetween(java.lang.String text, java.lang.String from, java.lang.String to, java.lang.String breakChars, char openBracket, char closeBracket, boolean returnIDXs, boolean recursive)
           
static java.util.List getAllVarsFrom(java.lang.String template)
           
static java.util.regex.Pattern getContainsAnyIgnoreCasePattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string contains any of the given terms.
static java.util.regex.Pattern getContainsAnyPattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string contains any of the given terms.
static double getDouble(java.lang.String value, double defaultValue)
          Creates an double for the given integer string.
static java.util.regex.Pattern getEndsWithAnyIgnoreCasePattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string ends with any of the given terms.
static java.util.regex.Pattern getEndsWithAnyPattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string ends with any of the given terms.
static java.util.regex.Pattern getEqualsAnyIgnoreCasePattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string equals any of the given terms.
static java.util.regex.Pattern getEqualsAnyPattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string equals any of the given terms.
static java.lang.String getFirstLine(java.lang.String messageText)
           
static int getFirstStartsWith(java.lang.String[] data, java.lang.String value)
           
static int getIdxOfNextNonDigit(java.lang.String text, int from)
          Replaces indicated characters with other characters.
static int getInt(java.lang.String integer)
          Creates an int for the given integer string.
static int getInt(java.lang.String integer, int defaultValue)
          Creates an int for the given integer string.
static int getLastStartsWith(java.lang.String[] data, java.lang.String value)
           
static long getLong(java.lang.String value, long defaultValue)
          Creates an long for the given long string.
static java.util.Comparator getNaturalComparator()
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the current locale's order rules.
static java.util.Comparator getNaturalComparator(java.text.Collator collator)
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.
static java.util.Comparator getNaturalComparatorAscii()
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts based on each character's Unicode value.
static java.util.Comparator getNaturalComparatorIgnoreCaseAscii()
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts based on each character's Unicode value while ignore upper/lower case differences.
static java.util.Comparator getNaturalTypeTreeLabelComparator()
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the current locale's order rules.
static java.util.Comparator getNaturalTypeTreeLabelComparator(java.text.Collator collator)
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.
static java.util.Comparator getNaturalTypeXPathComparator()
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the current locale's order rules.
static java.util.Comparator getNaturalTypeXPathComparator(java.text.Collator collator)
          Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.
static int[] getOptimalColWidth(java.util.HashMap colFormatters, int readAhead, int[] minVals, int maxVal, int filerColumn, java.lang.String[] visColNames, java.lang.String[][] values)
           
static java.lang.String getQuoted(java.lang.String str)
           
static int getSequenceChangePos(int[] cData, int offset)
           
static int getSequenceChangePos(java.util.List<java.lang.Object[]> data, int offset, int arrPos)
           
static int getSequenceChangePos(java.util.List data, int offset)
           
static int getSequenceChangePosLast(int[] cData, int offset)
           
static int getSequenceChangePosLast(java.util.List<java.lang.Object[]> data, int offset, int arrPos)
           
static int getSequenceChangePosLast(java.util.List data, int offset)
           
static short getShort(java.lang.String value, short defaultValue)
           
static java.lang.String getSQuoted(java.lang.String str)
           
static java.lang.String getStackTrace(java.lang.Exception e)
           
static java.util.regex.Pattern getStartsWithAnyIgnoreCasePattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string starts with any of the given terms.
static java.util.regex.Pattern getStartsWithAnyPattern(java.lang.String[] terms)
          Compile a pattern that can will match a string if the string starts with any of the given terms.
static int indexOfIgnoreCase(java.lang.String string, java.lang.String substring, int fromIndex)
           
static java.lang.String insert(java.lang.String into, int pos, char what)
           
static java.lang.String insert(java.lang.String into, int pos, java.lang.String what)
          Returns the index within the specified string of the first occurrence of the specified substring ignoring case considerations and starting at the specified index.
static boolean isAlpha(char v)
           
static boolean isAlpha(java.lang.String str)
           
static boolean isAlphaNumeric(char v)
           
static boolean isAlphaNumeric(java.lang.String str)
           
static boolean isDigit(char v)
           
static boolean isEmpty(java.lang.String str)
           
static boolean isFloatString(java.lang.String str)
           
static boolean isInteger(java.lang.String myInput)
           
static boolean isIntegerString(java.lang.String str)
           
static boolean isNumeric(java.lang.String text)
          Checks whether the given input string is numeric.
static boolean isTrue(java.lang.String val)
           
static void main(java.lang.String[] args)
           
static java.lang.String midpad(java.lang.String s, int length)
          Pad the beginning and end of the given String with spaces until the String is of the given length.
static java.lang.String midpad(java.lang.String s, int length, char c)
          Pad the beginning and end of the given String with the given character until the result is the desired length.
static java.lang.String nullToEmpty(java.lang.String text)
           
static int numberOfDigits(java.lang.String text)
          Counts the number of digits in the specified text.
static boolean parseBoolean(java.lang.String s, boolean defaultVal)
           
static java.lang.String postpad(java.lang.String s, int length)
          Pad the end of the given String with spaces until the String is of the given length.
static java.lang.String postpad(java.lang.String s, int length, char c)
          Append the given character to the String until the result is the desired length.
static java.lang.String prepad(java.lang.String s, int length)
          Pad the beginning of the given String with spaces until the String is of the given length.
static java.lang.String prepad(java.lang.String s, int length, char c)
          Pre-pend the given character to the String until the result is the desired length.
static java.lang.StringBuilder printQuoted(java.lang.StringBuilder str)
           
static java.util.List readLines(java.io.InputStream inStream, boolean skipEmpty)
           
 void recursionMemTestfor(int value)
           
 void recursionMemTestRec(int value)
           
static java.lang.String removeAllBetween(java.lang.String text, java.lang.String startQuali, java.lang.String endQuali)
           
static java.lang.String removeAllBetween(java.lang.String text, java.lang.String startQuali, java.lang.String endQuali, boolean onlyNumeric)
           
static java.lang.String[][] removeDuplicates(int startCol, java.lang.String[][] data)
           
static java.util.List removeDuplicates(java.util.List strArrData)
           
static java.util.List removeDuplicates(java.lang.String[] data)
           
static java.lang.String removeIfFirst(java.lang.String value, java.lang.String first)
           
static java.lang.String removeIfFirstLast(java.lang.String string, java.lang.String first, java.lang.String last)
           
static java.lang.String removeIfLast(java.lang.String value, java.lang.String last)
           
static java.lang.String removeIfLast(java.lang.String value, java.lang.String last, boolean trimRight)
           
static java.lang.String removeSpaceChars(java.lang.String result)
           
static java.lang.String removeSpecialChars(java.lang.String result)
           
static java.lang.String removeSpecialChars(java.lang.String result, boolean spaceIncluded)
           
static java.lang.String repeat(int times, java.lang.String what)
           
static java.lang.StringBuffer replace(java.lang.StringBuffer source, char[] from, java.lang.String[] to)
          Replace every string occurence defined in from array with the corresponding char
static java.lang.String replace(java.lang.String source, char[] from, char to)
           
static java.lang.String replace(java.lang.String source, char[] from, java.lang.String[] to)
          Replace every string occurence defined in from array with the corresponding char
static java.lang.String replace(java.lang.String text, char varIdentifier, java.lang.String[] values)
           
static java.lang.String replace(java.lang.String source, java.lang.String[] from, char[] to)
          Replace every string occurence defined in from array with the corresponding char
static java.lang.String replace(java.lang.String text, java.lang.String oldCharacters, java.lang.String newCharacters)
           
static java.lang.String replaceAllBetween(java.lang.String text, java.lang.String startQuali, java.lang.String endQuali, java.lang.String replace)
          Replace all text between startQuali,endQuali with replace String including qualifier
static java.lang.String replaceIgnoreCase(java.lang.String text, java.lang.String oldCharacters, java.lang.String newCharacters)
          Replaces indicated characters with other characters.
static java.lang.String replaceLetters(java.lang.String result, java.lang.String replacement)
           
static java.lang.String replaceNumberTail(java.lang.String source, long replacement)
           
static java.lang.String shredder(java.lang.String text, int length, int startAt)
           
static java.lang.String[] split(java.lang.String s, java.lang.String delimiter)
          Split the given String into tokens.
static java.util.List split(java.lang.String s, java.lang.String token, java.lang.String reserved)
           
static java.lang.String[] splitString(java.lang.String s, java.lang.String token, java.lang.String reserved)
           
static boolean startsWithAny(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string starts with any of the given terms.
static boolean startsWithAnyIgnoreCase(java.lang.String s, java.lang.String[] terms)
          Tests to see if the given string starts with any of the given terms.
static boolean startsWithIgnoreCase(java.lang.String str, java.lang.String prefix, int offset)
           Check if a String starts with a specified prefix (optionally case insensitive).
static java.lang.String substring(java.lang.String value, java.lang.String startId, java.lang.String endId)
           
static java.lang.String substringAfter(java.lang.String value, java.lang.String what)
           
static java.lang.String substringBefore(java.lang.String value, java.lang.String what)
           
static java.lang.String[] toLines(java.lang.String logoText)
           
static java.lang.String[] trim(java.lang.String[] columnNames)
           
static java.lang.String trim(java.lang.String s, java.lang.String c)
          Trim any of the characters contained in the second string from the beginning and end of the first.
static java.lang.String trimLeft(java.lang.String content)
           
static java.lang.String trimRight(java.lang.String content)
           
static java.lang.String unEscapeFreemarker(java.lang.String value)
           
static java.lang.String unescapeHTML(java.lang.String s)
          Turn any HTML escape entities in the string into characters and return the resulting string.
static java.lang.String[] unescapeHTML(java.lang.String[] values)
           
static java.lang.String unEscapeJavaLiteral(java.lang.String s)
           
static java.lang.String unEscapeLiteral(java.lang.String s, java.lang.String lit, java.lang.String with)
           
static java.lang.String unEscapeSQLLiteral(java.lang.String s)
           
static java.lang.String unEscapeToURLEncoding(java.lang.String value)
           
static java.lang.String[] unEscapeToURLEncoding(java.lang.String[] values)
           
static java.lang.String unEscapeXML(java.lang.String str)
           
static java.lang.String verticalize(java.lang.String text)
           
static void writeln(java.io.BufferedWriter bw, java.lang.String s)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AMP

public static final java.lang.String AMP
See Also:
Constant Field Values

carriageReturnChar

public static final char carriageReturnChar
See Also:
Constant Field Values

charCarriageReturnArr

public static final char[] charCarriageReturnArr

charNewLineArr

public static final char[] charNewLineArr

doubleQuote

public static final java.lang.String doubleQuote
See Also:
Constant Field Values

empty

public static final java.lang.String[] empty

freeMarker_Escape

public static final java.lang.String[] freeMarker_Escape

freeMarker_Unescape

public static final char[] freeMarker_Unescape

GREATER

public static final java.lang.String GREATER
See Also:
Constant Field Values

IGNORE_CASE_NATURAL_COMPARATOR_ASCII

public static final java.util.Comparator IGNORE_CASE_NATURAL_COMPARATOR_ASCII

A string comparator that does case insensitive comparisons and handles embedded numbers correctly.

Do not use if your app might ever run on any locale that uses more than 7-bit ascii characters.


javaCharLiterals

public static final char[] javaCharLiterals

javaLiterals

public static final java.lang.String[] javaLiterals

jax_protokol_escape

public static final char[] jax_protokol_escape

jax_protokol_unescape

public static final java.lang.String[] jax_protokol_unescape

LESS

public static final java.lang.String LESS
See Also:
Constant Field Values

NATURAL_COMPARATOR_ASCII

public static final java.util.Comparator NATURAL_COMPARATOR_ASCII

A string comparator that does case sensitive comparisons and handles embedded numbers correctly.

Do not use if your app might ever run on any locale that uses more than 7-bit ascii characters.


newLine

public static final java.lang.String newLine

newLineChar

public static final char newLineChar
See Also:
Constant Field Values

newTab

public static final java.lang.String newTab

NOT_AN_CHAR

public static final char NOT_AN_CHAR
See Also:
Constant Field Values

QUOT

public static final java.lang.String QUOT
See Also:
Constant Field Values

space

public static final java.lang.String space
See Also:
Constant Field Values

sqlCharLiterals

public static final char[] sqlCharLiterals

sqlLiterals

public static final java.lang.String[] sqlLiterals

TO_STRING_COMPARATOR

public static final java.util.Comparator TO_STRING_COMPARATOR

URL_SPECIAL_ENC

public static final char[] URL_SPECIAL_ENC

URL_SPECIAL_ENC_DEST

public static final java.lang.String[] URL_SPECIAL_ENC_DEST

XML_AMP

public static final java.lang.String XML_AMP
See Also:
Constant Field Values

XML_GREATER

public static final java.lang.String XML_GREATER
See Also:
Constant Field Values

XML_LESS

public static final java.lang.String XML_LESS
See Also:
Constant Field Values

XML_QUOT

public static final java.lang.String XML_QUOT
See Also:
Constant Field Values
Constructor Detail

StringUtil

public StringUtil()
Method Detail

addIfNotEndWith

public static java.lang.String addIfNotEndWith(java.lang.String value,
                                               java.lang.String add)

appendCount

public static java.lang.String appendCount(java.lang.String source)

appendNotNull

public static java.lang.String appendNotNull(java.lang.String stra,
                                             java.lang.String strb,
                                             java.lang.String delim)
Concatenate stra and strb using delim. If stra (strb) is null or zero size they will be skipped appendNotNull("a", "b", ",") -> a,b appendNotNull("a", null, ",") -> a , appendNotNull( null, "b",",") -> b

Parameters:
stra -
strb -
delim -
Returns:

checkDistance

public static boolean checkDistance(java.lang.String source,
                                    char[] aChar,
                                    int distance)

checkDistance

public static boolean checkDistance(java.lang.String source,
                                    char aChar,
                                    int distance)

compareNatural

public static int compareNatural(java.text.Collator collator,
                                 java.lang.String s,
                                 java.lang.String t)

Compares two strings using the given collator and comparing contained numbers based on their numeric values.

Parameters:
s - first string
t - second string
Returns:
zero iff s and t are equal, a value less than zero iff s lexicographically precedes t and a value larger than zero iff s lexicographically follows t

compareNatural

public static int compareNatural(java.lang.String s,
                                 java.lang.String t)

Compares two strings using the current locale's rules and comparing contained numbers based on their numeric values.

This is probably the best default comparison to use.

If you know that the texts to be compared are in a certain language that differs from the default locale's langage, then get a collator for the desired locale ( Collator.getInstance(java.util.Locale)) and pass it to compareNatural(java.text.Collator, String, String)

Parameters:
s - first string
t - second string
Returns:
zero iff s and t are equal, a value less than zero iff s lexicographically precedes t and a value larger than zero iff s lexicographically follows t

compareNaturalAscii

public static int compareNaturalAscii(java.lang.String s,
                                      java.lang.String t)

Compares two strings using each character's Unicode value for non-digit characters and the numeric values off any contained numbers.

(This will probably make sense only for strings containing 7-bit ascii characters only.)

Returns:
zero iff s and t are equal, a value less than zero iff s lexicographically precedes t and a value larger than zero iff s lexicographically follows t

compareNaturalIgnoreCaseAscii

public static int compareNaturalIgnoreCaseAscii(java.lang.String s,
                                                java.lang.String t)

Compares two strings using each character's Unicode value - ignoring upper/lower case - for non-digit characters and the numeric values of any contained numbers.

(This will probably make sense only for strings containing 7-bit ascii characters only.)

Returns:
zero iff s and t are equal, a value less than zero iff s lexicographically precedes t and a value larger than zero iff s lexicographically follows t

containsAny

public static boolean containsAny(java.lang.String s,
                                  java.lang.String[] terms)
Tests to see if the given string contains any of the given terms.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may contain any of the given terms.
terms - list of substrings that may be contained in the given string.
Returns:
true iff one of the terms is a substring of the given string.
See Also:
getContainsAnyPattern(String[])

containsAnyIgnoreCase

public static boolean containsAnyIgnoreCase(java.lang.String s,
                                            java.lang.String[] terms)
Tests to see if the given string contains any of the given terms.

Case is ignored when matching using Unicode case rules.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may contain any of the given terms.
terms - list of substrings that may be contained in the given string.
Returns:
true iff one of the terms is a substring of the given string.
See Also:
getContainsAnyIgnoreCasePattern(String[])

convertToCamelCase

public static java.lang.String convertToCamelCase(java.lang.String cn,
                                                  java.lang.String regex)

countTokens

public static int countTokens(java.lang.String value,
                              char token,
                              boolean retDelims)
Calculates the number of times that this tokenizer's 5 Times faster as use of StringTokenizer.countTokens()

Returns:
the number of tokens remaining in the string using the current delimiter set.

cut

public static java.lang.String cut(java.lang.String string,
                                   int length)
Parameters:
aQuery -
i -
Returns:

cut

public static java.lang.String cut(java.lang.String string,
                                   int length,
                                   java.lang.String cutTail)

decodeJaxProtokolFromURL

public static java.lang.String decodeJaxProtokolFromURL(java.lang.String data)

encodeJaxProtokolToURL

public static java.lang.String encodeJaxProtokolToURL(java.lang.String data)

endsWithAny

public static boolean endsWithAny(java.lang.String s,
                                  java.lang.String[] terms)
Tests to see if the given string ends with any of the given terms.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may end with any of the given terms.
terms - list of strings that may end with the given string.
Returns:
true iff the given string ends with one of the given terms.
See Also:
getEndsWithAnyPattern(String[])

endsWithAnyIgnoreCase

public static boolean endsWithAnyIgnoreCase(java.lang.String s,
                                            java.lang.String[] terms)
Tests to see if the given string ends with any of the given terms.

Case is ignored when matching using Unicode case rules.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may end with any of the given terms.
terms - list of strings that may end with the given string.
Returns:
true iff the given string ends with one of the given terms.
See Also:
getEndsWithAnyIgnoreCasePattern(String[])

equals

public static boolean equals(java.lang.Object val1,
                             java.lang.Object val2)

equals

public static boolean equals(java.lang.String val1,
                             java.lang.String val2)

equalsAny

public static boolean equalsAny(java.lang.String s,
                                java.lang.String[] terms)
Tests to see if the given string equals any of the given terms.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may equal any of the given terms.
terms - list of strings that may equal the given string.
Returns:
true iff one of the terms is equal to the given string.
See Also:
getEqualsAnyPattern(String[])

equalsAnyIgnoreCase

public static boolean equalsAnyIgnoreCase(java.lang.String s,
                                          java.lang.String[] terms)
Tests to see if the given string equals any of the given terms.

Case is ignored when matching using Unicode case rules.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may equal any of the given terms.
terms - list of strings that may equal the given string.
Returns:
true iff one of the terms is equal to the given string.
See Also:
getEqualsAnyIgnoreCasePattern(String[])

escape

public static java.lang.String escape(java.lang.String s,
                                      java.lang.String what,
                                      java.lang.String with)

escapeHTML

public static java.lang.String escapeHTML(java.lang.String s)
Replaces characters that may be confused by a HTML parser with their equivalent character entity references.

Any data that will appear as text on a web page should be be escaped. This is especially important for data that comes from untrusted sources such as Internet users. A common mistake in CGI programming is to ask a user for data and then put that data on a web page. For example:

    Server: What is your name?
    User: <b>Joe<b>
    Server: Hello <b>Joe</b>, Welcome
 
If the name is put on the page without checking that it doesn't contain HTML code or without sanitizing that HTML code, the user could reformat the page, insert scripts, and control the the content on your web server.

This method will replace HTML characters such as > with their HTML entity reference (&gt;) so that the html parser will be sure to interpret them as plain text rather than HTML or script.

This method should be used for both data to be displayed in text in the html document, and data put in form elements. For example:
<html><body>This in not a &lt;tag&gt; in HTML</body></html>
and
<form><input type="hidden" name="date" value="This data could be &quot;malicious&quot;"></form>
In the second example, the form data would be properly be resubmitted to your cgi script in the URLEncoded format:
This data could be %22malicious%22

Parameters:
s - String to be escaped
Returns:
escaped String
Throws:
java.lang.NullPointerException - if s is null.

escapeJavaLiteral

public static java.lang.String escapeJavaLiteral(java.lang.String s)
Replaces characters that are not allowed in a Java style string literal with their escape characters. Specifically quote ("), single quote ('), new line (\n), carriage return (\r), and backslash (\), and tab (\t) are escaped.

Parameters:
s - String to be escaped
Returns:
escaped String
Throws:
java.lang.NullPointerException - if s is null.

escapeJavaScript

public static java.lang.String escapeJavaScript(java.lang.String value)

escapeLiteral

public static java.lang.String escapeLiteral(java.lang.String s,
                                             char what,
                                             java.lang.String with)

escapeRegularExpressionLiteral

public static java.lang.String escapeRegularExpressionLiteral(java.lang.String s)
Escapes characters that have special meaning to regular expressions

Parameters:
s - String to be escaped
Returns:
escaped String
Throws:
java.lang.NullPointerException - if s is null.

escapeSQL

public static java.lang.String escapeSQL(java.lang.String s)
Replaces characters that may be confused by an SQL parser with their equivalent escape characters.

Any data that will be put in an SQL query should be be escaped. This is especially important for data that comes from untrusted sources such as Internet users.

For example if you had the following SQL query:
"SELECT * FROM addresses WHERE name='" + name + "' AND private='N'"
Without this function a user could give " OR 1=1 OR ''='" as their name causing the query to be:
"SELECT * FROM addresses WHERE name='' OR 1=1 OR ''='' AND private='N'"
which will give all addresses, including private ones.
Correct usage would be:
"SELECT * FROM addresses WHERE name='" + StringHelper.escapeSQL(name) + "' AND private='N'"

Another way to avoid this problem is to use a PreparedStatement with appropriate placeholders.

Parameters:
s - String to be escaped
Returns:
escaped String
Throws:
java.lang.NullPointerException - if s is null.

escapeSQL

public static java.lang.String[] escapeSQL(java.lang.String[] lookupValues)

escapeSQLLiteral

public static java.lang.String escapeSQLLiteral(java.lang.String s)

escapeToURLEncoding

public static java.lang.String escapeToURLEncoding(java.lang.String value)

escapeXML

public static java.lang.String escapeXML(java.lang.String s)

extractInt

public static int extractInt(java.lang.String mixedString)
Extract an int for the given mixed integer string like 1qwerts or qwer1ts oer qwertz1. If integer string is null or not a int funtction returns 0.

Parameters:
String - returns 0 for non integer values
Returns:

extractIntAsString

public static java.lang.String extractIntAsString(java.lang.String mixedString)
Extract an int for the given mixed integer string like 1qwerts or qwer1ts oer qwertz1. If integer string is null or not a int funtction returns 0.

Parameters:
String - returns 0 for non integer values
Returns:

fillWith

public static java.lang.String fillWith(int length,
                                        java.lang.String fillWith,
                                        java.lang.String source)

format

public static java.lang.String format(boolean left,
                                      char fill,
                                      int size,
                                      java.lang.String text)
Returns a formatted string.

Parameters:
left - true means left alignment otherwise rigth alignment
fill - filling character if the specified text is smaller than the resulting size
size - size of the formatted string
text - string which should be formated
Returns:
formatted string

format

public static void format(boolean left,
                          char fill,
                          int size,
                          java.lang.String text,
                          java.lang.StringBuffer buffer)
Formats a specified string and appends the formatted string to the buffer.

Parameters:
left - true means left alignment otherwise rigth alignment
fill - filling character if the specified text is smaller than the resulting size
size - size of the formatted string
text - string which should be formated
buffer - buffer where the formatted string will be appended

getAllBetween

public static java.util.List getAllBetween(java.lang.String text,
                                           java.lang.String from,
                                           java.lang.String to)

getAllBetween

public static java.util.List getAllBetween(java.lang.String text,
                                           java.lang.String from,
                                           java.lang.String to,
                                           java.lang.String breakChars)

getAllBetween

public static java.util.List getAllBetween(java.lang.String text,
                                           java.lang.String from,
                                           java.lang.String to,
                                           java.lang.String breakChars,
                                           char openBracket,
                                           char closeBracket)

getAllBetween

public static java.util.List getAllBetween(java.lang.String text,
                                           java.lang.String from,
                                           java.lang.String to,
                                           java.lang.String breakChars,
                                           char openBracket,
                                           char closeBracket,
                                           boolean returnIDXs,
                                           boolean recursive)

getAllVarsFrom

public static java.util.List getAllVarsFrom(java.lang.String template)

getContainsAnyIgnoreCasePattern

public static java.util.regex.Pattern getContainsAnyIgnoreCasePattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string contains any of the given terms.

Case is ignored when matching using Unicode case rules.

Usage:
boolean b = getContainsAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it contains any of the terms.

getContainsAnyPattern

public static java.util.regex.Pattern getContainsAnyPattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string contains any of the given terms.

Usage:
boolean b = getContainsAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it contains any of the terms.

getDouble

public static double getDouble(java.lang.String value,
                               double defaultValue)
Creates an double for the given integer string. If integer string is null or not a double function returns 0.

Parameters:
double - returns defaultValue for non double values
Returns:

getEndsWithAnyIgnoreCasePattern

public static java.util.regex.Pattern getEndsWithAnyIgnoreCasePattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string ends with any of the given terms.

Case is ignored when matching using Unicode case rules.

Usage:
boolean b = getEndsWithAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it ends with any of the terms.

getEndsWithAnyPattern

public static java.util.regex.Pattern getEndsWithAnyPattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string ends with any of the given terms.

Usage:
boolean b = getEndsWithAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it ends with any of the terms.

getEqualsAnyIgnoreCasePattern

public static java.util.regex.Pattern getEqualsAnyIgnoreCasePattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string equals any of the given terms.

Case is ignored when matching using Unicode case rules.

Usage:
boolean b = getEqualsAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it equals any of the terms.

getEqualsAnyPattern

public static java.util.regex.Pattern getEqualsAnyPattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string equals any of the given terms.

Usage:
boolean b = getEqualsAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it equals any of the terms.

getFirstLine

public static java.lang.String getFirstLine(java.lang.String messageText)

getFirstStartsWith

public static int getFirstStartsWith(java.lang.String[] data,
                                     java.lang.String value)

getIdxOfNextNonDigit

public static int getIdxOfNextNonDigit(java.lang.String text,
                                       int from)
Replaces indicated characters with other characters.

Parameters:
text - string where characters should be replaced
oldCharacters - the character to be replaced by newCharacters.
newCharacters - the character replacing oldCharacters.
Returns:
replaced string.

getInt

public static int getInt(java.lang.String integer)
Creates an int for the given integer string. If integer string is null or not a int funtction returns 0.

Parameters:
integer - returns 0 for non integer values
Returns:

getInt

public static int getInt(java.lang.String integer,
                         int defaultValue)
Creates an int for the given integer string. If integer string is null or not a int funtction returns default.

Parameters:
integer - returns 0 for non integer values
Returns:

getLastStartsWith

public static int getLastStartsWith(java.lang.String[] data,
                                    java.lang.String value)

getLong

public static long getLong(java.lang.String value,
                           long defaultValue)
Creates an long for the given long string. If integer string is null or not a long function returns 0.

Parameters:
long - returns defaultValue for non long values
Returns:

getNaturalComparator

public static java.util.Comparator getNaturalComparator()
Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the current locale's order rules.

For example in German locale this will be a comparator that handles umlauts correctly and ignores upper/lower case differences.

Returns:

A string comparator that uses the current locale's order rules and handles embedded numbers correctly.

See Also:
getNaturalComparator(java.text.Collator)

getNaturalComparator

public static java.util.Comparator getNaturalComparator(java.text.Collator collator)
Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.

Parameters:
collator - used for locale specific comparison of text (non-number) subwords - must not be null
Returns:

A string comparator that uses the given Collator to compare subwords and handles embedded numbers correctly.

See Also:
getNaturalComparator()

getNaturalComparatorAscii

public static java.util.Comparator getNaturalComparatorAscii()
Returns a comparator that compares contained numbers based on their numeric values and compares other parts based on each character's Unicode value.

Returns:

a string comparator that does case sensitive comparisons on pure ascii strings and handles embedded numbers correctly.

Do not use if your app might ever run on any locale that uses more than 7-bit ascii characters.
See Also:
getNaturalComparator(), getNaturalComparator(java.text.Collator)

getNaturalComparatorIgnoreCaseAscii

public static java.util.Comparator getNaturalComparatorIgnoreCaseAscii()
Returns a comparator that compares contained numbers based on their numeric values and compares other parts based on each character's Unicode value while ignore upper/lower case differences. Do not use if your app might ever run on any locale that uses more than 7-bit ascii characters.

Returns:

a string comparator that does case insensitive comparisons on pure ascii strings and handles embedded numbers correctly.

See Also:
getNaturalComparator(), getNaturalComparator(java.text.Collator)

getNaturalTypeTreeLabelComparator

public static java.util.Comparator getNaturalTypeTreeLabelComparator()
Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the current locale's order rules.

For example in German locale this will be a comparator that handles umlauts correctly and ignores upper/lower case differences.

Returns:

A string comparator that uses the current locale's order rules and handles embedded numbers correctly.

See Also:
getNaturalComparator(java.text.Collator)

getNaturalTypeTreeLabelComparator

public static java.util.Comparator getNaturalTypeTreeLabelComparator(java.text.Collator collator)
Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.

Parameters:
collator - used for locale specific comparison of text (non-number) subwords - must not be null
Returns:

A string comparator that uses the given Collator to compare subwords and handles embedded numbers correctly.

See Also:
getNaturalComparator()

getNaturalTypeXPathComparator

public static java.util.Comparator getNaturalTypeXPathComparator()
Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the current locale's order rules.

For example in German locale this will be a comparator that handles umlauts correctly and ignores upper/lower case differences.

Returns:

A string comparator that uses the current locale's order rules and handles embedded numbers correctly.

See Also:
getNaturalComparator(java.text.Collator)

getNaturalTypeXPathComparator

public static java.util.Comparator getNaturalTypeXPathComparator(java.text.Collator collator)
Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.

Parameters:
collator - used for locale specific comparison of text (non-number) subwords - must not be null
Returns:

A string comparator that uses the given Collator to compare subwords and handles embedded numbers correctly.

See Also:
getNaturalComparator()

getOptimalColWidth

public static int[] getOptimalColWidth(java.util.HashMap colFormatters,
                                       int readAhead,
                                       int[] minVals,
                                       int maxVal,
                                       int filerColumn,
                                       java.lang.String[] visColNames,
                                       java.lang.String[][] values)

getQuoted

public static java.lang.String getQuoted(java.lang.String str)

getSequenceChangePos

public static int getSequenceChangePos(int[] cData,
                                       int offset)

getSequenceChangePos

public static int getSequenceChangePos(java.util.List<java.lang.Object[]> data,
                                       int offset,
                                       int arrPos)

getSequenceChangePos

public static int getSequenceChangePos(java.util.List data,
                                       int offset)

getSequenceChangePosLast

public static int getSequenceChangePosLast(int[] cData,
                                           int offset)

getSequenceChangePosLast

public static int getSequenceChangePosLast(java.util.List<java.lang.Object[]> data,
                                           int offset,
                                           int arrPos)

getSequenceChangePosLast

public static int getSequenceChangePosLast(java.util.List data,
                                           int offset)

getShort

public static short getShort(java.lang.String value,
                             short defaultValue)

getSQuoted

public static java.lang.String getSQuoted(java.lang.String str)

getStackTrace

public static java.lang.String getStackTrace(java.lang.Exception e)

getStartsWithAnyIgnoreCasePattern

public static java.util.regex.Pattern getStartsWithAnyIgnoreCasePattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string starts with any of the given terms.

Case is ignored when matching using Unicode case rules.

Usage:
boolean b = getStartsWithAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it starts with any of the terms.

getStartsWithAnyPattern

public static java.util.regex.Pattern getStartsWithAnyPattern(java.lang.String[] terms)
Compile a pattern that can will match a string if the string starts with any of the given terms.

Usage:
boolean b = getStartsWithAnyPattern(terms).matcher(s).matches();

If multiple strings are matched against the same set of terms, it is more efficient to reuse the pattern returned by this function.

Parameters:
terms - Array of search strings.
Returns:
Compiled pattern that can be used to match a string to see if it starts with any of the terms.

indexOfIgnoreCase

public static int indexOfIgnoreCase(java.lang.String string,
                                    java.lang.String substring,
                                    int fromIndex)

insert

public static java.lang.String insert(java.lang.String into,
                                      int pos,
                                      char what)

insert

public static java.lang.String insert(java.lang.String into,
                                      int pos,
                                      java.lang.String what)
Returns the index within the specified string of the first occurrence of the specified substring ignoring case considerations and starting at the specified index. The integer returned is the smallest value k such that:
    string.startsWith(substring, <i>k</i>)
 
is true.

Parameters:
string - any string.
substring - any string.
fromIndex - the index from which to start the search.
Returns:
if the second string argument occurs as a substring within the first string argument, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.
Throws:
java.lang.NullPointerException - if string or substring is null.

isAlpha

public static boolean isAlpha(char v)

isAlpha

public static boolean isAlpha(java.lang.String str)

isAlphaNumeric

public static boolean isAlphaNumeric(char v)

isAlphaNumeric

public static boolean isAlphaNumeric(java.lang.String str)

isDigit

public static boolean isDigit(char v)

isEmpty

public static boolean isEmpty(java.lang.String str)

isFloatString

public static boolean isFloatString(java.lang.String str)

isInteger

public static boolean isInteger(java.lang.String myInput)

isIntegerString

public static boolean isIntegerString(java.lang.String str)

isNumeric

public static boolean isNumeric(java.lang.String text)
Checks whether the given input string is numeric.

Parameters:
text - the text
Returns:
true when the given text represents an integer or double value

isTrue

public static boolean isTrue(java.lang.String val)

main

public static void main(java.lang.String[] args)

midpad

public static java.lang.String midpad(java.lang.String s,
                                      int length)
Pad the beginning and end of the given String with spaces until the String is of the given length. The result is that the original String is centered in the middle of the new string.

If the number of characters to pad is even, then the padding will be split evenly between the beginning and end, otherwise, the extra character will be added to the end.

If a String is longer than the desired length, it will not be truncated, however no padding will be added.

Parameters:
s - String to be padded.
length - desired length of result.
Returns:
padded String.
Throws:
java.lang.NullPointerException - if s is null.

midpad

public static java.lang.String midpad(java.lang.String s,
                                      int length,
                                      char c)
Pad the beginning and end of the given String with the given character until the result is the desired length. The result is that the original String is centered in the middle of the new string.

If the number of characters to pad is even, then the padding will be split evenly between the beginning and end, otherwise, the extra character will be added to the end.

If a String is longer than the desired length, it will not be truncated, however no padding will be added.

Parameters:
s - String to be padded.
length - desired length of result.
c - padding character.
Returns:
padded String.
Throws:
java.lang.NullPointerException - if s is null.

nullToEmpty

public static java.lang.String nullToEmpty(java.lang.String text)

numberOfDigits

public static int numberOfDigits(java.lang.String text)
Counts the number of digits in the specified text.

Parameters:
text - string
Returns:
number of digits in the specified text.

parseBoolean

public static boolean parseBoolean(java.lang.String s,
                                   boolean defaultVal)

postpad

public static java.lang.String postpad(java.lang.String s,
                                       int length)
Pad the end of the given String with spaces until the String is of the given length.

If a String is longer than the desired length, it will not be truncated, however no padding will be added.

Parameters:
s - String to be padded.
length - desired length of result.
Returns:
padded String.
Throws:
java.lang.NullPointerException - if s is null.

postpad

public static java.lang.String postpad(java.lang.String s,
                                       int length,
                                       char c)
Append the given character to the String until the result is the desired length.

If a String is longer than the desired length, it will not be truncated, however no padding will be added.

Parameters:
s - String to be padded.
length - desired length of result.
c - padding character.
Returns:
padded String.
Throws:
java.lang.NullPointerException - if s is null.

prepad

public static java.lang.String prepad(java.lang.String s,
                                      int length)
Pad the beginning of the given String with spaces until the String is of the given length.

If a String is longer than the desired length, it will not be truncated, however no padding will be added.

Parameters:
s - String to be padded.
length - desired length of result.
Returns:
padded String.
Throws:
java.lang.NullPointerException - if s is null.

prepad

public static java.lang.String prepad(java.lang.String s,
                                      int length,
                                      char c)
Pre-pend the given character to the String until the result is the desired length.

If a String is longer than the desired length, it will not be truncated, however no padding will be added.

Parameters:
s - String to be padded.
length - desired length of result.
c - padding character.
Returns:
padded String.
Throws:
java.lang.NullPointerException - if s is null.

printQuoted

public static java.lang.StringBuilder printQuoted(java.lang.StringBuilder str)

readLines

public static java.util.List readLines(java.io.InputStream inStream,
                                       boolean skipEmpty)
                                throws java.io.IOException
Throws:
java.io.IOException

recursionMemTestfor

public void recursionMemTestfor(int value)

recursionMemTestRec

public void recursionMemTestRec(int value)

removeAllBetween

public static java.lang.String removeAllBetween(java.lang.String text,
                                                java.lang.String startQuali,
                                                java.lang.String endQuali)

removeAllBetween

public static java.lang.String removeAllBetween(java.lang.String text,
                                                java.lang.String startQuali,
                                                java.lang.String endQuali,
                                                boolean onlyNumeric)

removeDuplicates

public static java.lang.String[][] removeDuplicates(int startCol,
                                                    java.lang.String[][] data)

removeDuplicates

public static java.util.List removeDuplicates(java.util.List strArrData)

removeDuplicates

public static java.util.List removeDuplicates(java.lang.String[] data)

removeIfFirst

public static java.lang.String removeIfFirst(java.lang.String value,
                                             java.lang.String first)

removeIfFirstLast

public static java.lang.String removeIfFirstLast(java.lang.String string,
                                                 java.lang.String first,
                                                 java.lang.String last)

removeIfLast

public static java.lang.String removeIfLast(java.lang.String value,
                                            java.lang.String last)

removeIfLast

public static java.lang.String removeIfLast(java.lang.String value,
                                            java.lang.String last,
                                            boolean trimRight)

removeSpaceChars

public static java.lang.String removeSpaceChars(java.lang.String result)

removeSpecialChars

public static java.lang.String removeSpecialChars(java.lang.String result)

removeSpecialChars

public static java.lang.String removeSpecialChars(java.lang.String result,
                                                  boolean spaceIncluded)

repeat

public static java.lang.String repeat(int times,
                                      java.lang.String what)

replace

public static java.lang.StringBuffer replace(java.lang.StringBuffer source,
                                             char[] from,
                                             java.lang.String[] to)
Replace every string occurence defined in from array with the corresponding char

Parameters:
source - source String
from - String array with to be replaced values
to - char array with the replacement
Returns:

replace

public static java.lang.String replace(java.lang.String source,
                                       char[] from,
                                       char to)

replace

public static java.lang.String replace(java.lang.String source,
                                       char[] from,
                                       java.lang.String[] to)
Replace every string occurence defined in from array with the corresponding char

Parameters:
source - source String
from - String array with to be replaced values
to - char array with the replacement
Returns:

replace

public static java.lang.String replace(java.lang.String text,
                                       char varIdentifier,
                                       java.lang.String[] values)

replace

public static java.lang.String replace(java.lang.String source,
                                       java.lang.String[] from,
                                       char[] to)
Replace every string occurence defined in from array with the corresponding char

Parameters:
source - source String
from - String array with to be replaced values
to - char array with the replacement
Returns:

replace

public static java.lang.String replace(java.lang.String text,
                                       java.lang.String oldCharacters,
                                       java.lang.String newCharacters)

replaceAllBetween

public static java.lang.String replaceAllBetween(java.lang.String text,
                                                 java.lang.String startQuali,
                                                 java.lang.String endQuali,
                                                 java.lang.String replace)
Replace all text between startQuali,endQuali with replace String including qualifier

Parameters:
text -
startQuali -
endQuali -
replace -
Returns:

replaceIgnoreCase

public static java.lang.String replaceIgnoreCase(java.lang.String text,
                                                 java.lang.String oldCharacters,
                                                 java.lang.String newCharacters)
Replaces indicated characters with other characters.

Parameters:
text - string where characters should be replaced
oldCharacters - the character to be replaced by newCharacters.
newCharacters - the character replacing oldCharacters.
Returns:
replaced string.

replaceLetters

public static java.lang.String replaceLetters(java.lang.String result,
                                              java.lang.String replacement)

replaceNumberTail

public static java.lang.String replaceNumberTail(java.lang.String source,
                                                 long replacement)

shredder

public static java.lang.String shredder(java.lang.String text,
                                        int length,
                                        int startAt)

split

public static java.lang.String[] split(java.lang.String s,
                                       java.lang.String delimiter)
Split the given String into tokens.

This method is meant to be similar to the split function in other programming languages but it does not use regular expressions. Rather the String is split on a single String literal.

Unlike java.util.StringTokenizer which accepts multiple character tokens as delimiters, the delimiter here is a single String literal.

Each null token is returned as an empty String. Delimiters are never returned as tokens.

If there is no delimiter because it is either empty or null, the only element in the result is the original String.

StringHelper.split("1-2-3", "-");
result: {"1", "2", "3"}
StringHelper.split("-1--2-", "-");
result: {"", "1", ,"", "2", ""}
StringHelper.split("123", "");
result: {"123"}
StringHelper.split("1-2---3----4", "--");
result: {"1-2", "-3", "", "4"}

Parameters:
s - String to be split.
delimiter - String literal on which to split.
Returns:
an array of tokens.
Throws:
java.lang.NullPointerException - if s is null.

split

public static java.util.List split(java.lang.String s,
                                   java.lang.String token,
                                   java.lang.String reserved)

splitString

public static java.lang.String[] splitString(java.lang.String s,
                                             java.lang.String token,
                                             java.lang.String reserved)

startsWithAny

public static boolean startsWithAny(java.lang.String s,
                                    java.lang.String[] terms)
Tests to see if the given string starts with any of the given terms.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may start with any of the given terms.
terms - list of strings that may start with the given string.
Returns:
true iff the given string starts with one of the given terms.
See Also:
getStartsWithAnyPattern(String[])

startsWithAnyIgnoreCase

public static boolean startsWithAnyIgnoreCase(java.lang.String s,
                                              java.lang.String[] terms)
Tests to see if the given string starts with any of the given terms.

Case is ignored when matching using Unicode case rules.

This implementation is more efficient than the brute force approach of testing the string against each of the terms. It instead compiles a single regular expression that can test all the terms at once, and uses that expression against the string.

This is a convenience method. If multiple strings are tested against the same set of terms, it is more efficient not to compile the regular expression multiple times.

Parameters:
s - String that may start with any of the given terms.
terms - list of strings that may start with the given string.
Returns:
true iff the given string starts with one of the given terms.
See Also:
getStartsWithAnyIgnoreCasePattern(String[])

startsWithIgnoreCase

public static boolean startsWithIgnoreCase(java.lang.String str,
                                           java.lang.String prefix,
                                           int offset)

Check if a String starts with a specified prefix (optionally case insensitive).

Parameters:
str - the String to check, may be null
prefix - the prefix to find, may be null
offset -
Returns:
true if the String starts with the prefix or both null
See Also:
String.startsWith(String)

substring

public static java.lang.String substring(java.lang.String value,
                                         java.lang.String startId,
                                         java.lang.String endId)

substringAfter

public static java.lang.String substringAfter(java.lang.String value,
                                              java.lang.String what)

substringBefore

public static java.lang.String substringBefore(java.lang.String value,
                                               java.lang.String what)

toLines

public static java.lang.String[] toLines(java.lang.String logoText)

trim

public static java.lang.String[] trim(java.lang.String[] columnNames)

trim

public static java.lang.String trim(java.lang.String s,
                                    java.lang.String c)
Trim any of the characters contained in the second string from the beginning and end of the first.

Parameters:
s - String to be trimmed.
c - list of characters to trim from s.
Returns:
trimmed String.
Throws:
java.lang.NullPointerException - if s is null.

trimLeft

public static java.lang.String trimLeft(java.lang.String content)

trimRight

public static java.lang.String trimRight(java.lang.String content)

unEscapeFreemarker

public static java.lang.String unEscapeFreemarker(java.lang.String value)

unescapeHTML

public static java.lang.String unescapeHTML(java.lang.String s)
Turn any HTML escape entities in the string into characters and return the resulting string.

Parameters:
s - String to be unescaped.
Returns:
unescaped String.
Throws:
java.lang.NullPointerException - if s is null.

unescapeHTML

public static java.lang.String[] unescapeHTML(java.lang.String[] values)

unEscapeJavaLiteral

public static java.lang.String unEscapeJavaLiteral(java.lang.String s)

unEscapeLiteral

public static java.lang.String unEscapeLiteral(java.lang.String s,
                                               java.lang.String lit,
                                               java.lang.String with)

unEscapeSQLLiteral

public static java.lang.String unEscapeSQLLiteral(java.lang.String s)

unEscapeToURLEncoding

public static java.lang.String unEscapeToURLEncoding(java.lang.String value)

unEscapeToURLEncoding

public static java.lang.String[] unEscapeToURLEncoding(java.lang.String[] values)

unEscapeXML

public static java.lang.String unEscapeXML(java.lang.String str)

verticalize

public static java.lang.String verticalize(java.lang.String text)

writeln

public static void writeln(java.io.BufferedWriter bw,
                           java.lang.String s)
                    throws java.io.IOException
Throws:
java.io.IOException