|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.jaxfront.core.util.StringUtil
public class StringUtil
| 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 |
|---|
public static final java.lang.String AMP
public static final char carriageReturnChar
public static final char[] charCarriageReturnArr
public static final char[] charNewLineArr
public static final java.lang.String doubleQuote
public static final java.lang.String[] empty
public static final java.lang.String[] freeMarker_Escape
public static final char[] freeMarker_Unescape
public static final java.lang.String GREATER
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.
public static final char[] javaCharLiterals
public static final java.lang.String[] javaLiterals
public static final char[] jax_protokol_escape
public static final java.lang.String[] jax_protokol_unescape
public static final java.lang.String LESS
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.
public static final java.lang.String newLine
public static final char newLineChar
public static final java.lang.String newTab
public static final char NOT_AN_CHAR
public static final java.lang.String QUOT
public static final java.lang.String space
public static final char[] sqlCharLiterals
public static final java.lang.String[] sqlLiterals
public static final java.util.Comparator TO_STRING_COMPARATOR
public static final char[] URL_SPECIAL_ENC
public static final java.lang.String[] URL_SPECIAL_ENC_DEST
public static final java.lang.String XML_AMP
public static final java.lang.String XML_GREATER
public static final java.lang.String XML_LESS
public static final java.lang.String XML_QUOT
| Constructor Detail |
|---|
public StringUtil()
| Method Detail |
|---|
public static java.lang.String addIfNotEndWith(java.lang.String value,
java.lang.String add)
public static java.lang.String appendCount(java.lang.String source)
public static java.lang.String appendNotNull(java.lang.String stra,
java.lang.String strb,
java.lang.String delim)
stra - strb - delim -
public static boolean checkDistance(java.lang.String source,
char[] aChar,
int distance)
public static boolean checkDistance(java.lang.String source,
char aChar,
int distance)
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.
s - first stringt - second string
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
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)
s - first stringt - second string
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
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.)
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
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.)
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
public static boolean containsAny(java.lang.String s,
java.lang.String[] 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.
s - String that may contain any of the given terms.terms - list of substrings that may be contained in the given string.
getContainsAnyPattern(String[])
public static boolean containsAnyIgnoreCase(java.lang.String s,
java.lang.String[] 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.
s - String that may contain any of the given terms.terms - list of substrings that may be contained in the given string.
getContainsAnyIgnoreCasePattern(String[])
public static java.lang.String convertToCamelCase(java.lang.String cn,
java.lang.String regex)
public static int countTokens(java.lang.String value,
char token,
boolean retDelims)
public static java.lang.String cut(java.lang.String string,
int length)
aQuery - i -
public static java.lang.String cut(java.lang.String string,
int length,
java.lang.String cutTail)
public static java.lang.String decodeJaxProtokolFromURL(java.lang.String data)
public static java.lang.String encodeJaxProtokolToURL(java.lang.String data)
public static boolean endsWithAny(java.lang.String s,
java.lang.String[] 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.
s - String that may end with any of the given terms.terms - list of strings that may end with the given string.
getEndsWithAnyPattern(String[])
public static boolean endsWithAnyIgnoreCase(java.lang.String s,
java.lang.String[] 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.
s - String that may end with any of the given terms.terms - list of strings that may end with the given string.
getEndsWithAnyIgnoreCasePattern(String[])
public static boolean equals(java.lang.Object val1,
java.lang.Object val2)
public static boolean equals(java.lang.String val1,
java.lang.String val2)
public static boolean equalsAny(java.lang.String s,
java.lang.String[] 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.
s - String that may equal any of the given terms.terms - list of strings that may equal the given string.
getEqualsAnyPattern(String[])
public static boolean equalsAnyIgnoreCase(java.lang.String s,
java.lang.String[] 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.
s - String that may equal any of the given terms.terms - list of strings that may equal the given string.
getEqualsAnyIgnoreCasePattern(String[])
public static java.lang.String escape(java.lang.String s,
java.lang.String what,
java.lang.String with)
public static java.lang.String escapeHTML(java.lang.String s)
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 (>) 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 <tag>
in HTML</body></html>
and
<form><input type="hidden" name="date" value="This data could
be "malicious""></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
s - String to be escaped
java.lang.NullPointerException - if s is null.public static java.lang.String escapeJavaLiteral(java.lang.String s)
s - String to be escaped
java.lang.NullPointerException - if s is null.public static java.lang.String escapeJavaScript(java.lang.String value)
public static java.lang.String escapeLiteral(java.lang.String s,
char what,
java.lang.String with)
public static java.lang.String escapeRegularExpressionLiteral(java.lang.String s)
s - String to be escaped
java.lang.NullPointerException - if s is null.public static java.lang.String escapeSQL(java.lang.String s)
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.
s - String to be escaped
java.lang.NullPointerException - if s is null.public static java.lang.String[] escapeSQL(java.lang.String[] lookupValues)
public static java.lang.String escapeSQLLiteral(java.lang.String s)
public static java.lang.String escapeToURLEncoding(java.lang.String value)
public static java.lang.String escapeXML(java.lang.String s)
public static int extractInt(java.lang.String mixedString)
String - returns 0 for non integer values
public static java.lang.String extractIntAsString(java.lang.String mixedString)
String - returns 0 for non integer values
public static java.lang.String fillWith(int length,
java.lang.String fillWith,
java.lang.String source)
public static java.lang.String format(boolean left,
char fill,
int size,
java.lang.String text)
left - true means left alignment otherwise rigth alignmentfill - filling character if the specified text is smaller than the resulting sizesize - size of the formatted stringtext - string which should be formated
public static void format(boolean left,
char fill,
int size,
java.lang.String text,
java.lang.StringBuffer buffer)
left - true means left alignment otherwise rigth alignmentfill - filling character if the specified text is smaller than the resulting sizesize - size of the formatted stringtext - string which should be formatedbuffer - buffer where the formatted string will be appended
public static java.util.List getAllBetween(java.lang.String text,
java.lang.String from,
java.lang.String to)
public static java.util.List getAllBetween(java.lang.String text,
java.lang.String from,
java.lang.String to,
java.lang.String breakChars)
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)
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)
public static java.util.List getAllVarsFrom(java.lang.String template)
public static java.util.regex.Pattern getContainsAnyIgnoreCasePattern(java.lang.String[] 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.
terms - Array of search strings.
public static java.util.regex.Pattern getContainsAnyPattern(java.lang.String[] 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.
terms - Array of search strings.
public static double getDouble(java.lang.String value,
double defaultValue)
double - returns defaultValue for non double values
public static java.util.regex.Pattern getEndsWithAnyIgnoreCasePattern(java.lang.String[] 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.
terms - Array of search strings.
public static java.util.regex.Pattern getEndsWithAnyPattern(java.lang.String[] 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.
terms - Array of search strings.
public static java.util.regex.Pattern getEqualsAnyIgnoreCasePattern(java.lang.String[] 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.
terms - Array of search strings.
public static java.util.regex.Pattern getEqualsAnyPattern(java.lang.String[] 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.
terms - Array of search strings.
public static java.lang.String getFirstLine(java.lang.String messageText)
public static int getFirstStartsWith(java.lang.String[] data,
java.lang.String value)
public static int getIdxOfNextNonDigit(java.lang.String text,
int from)
text - string where characters should be replacedoldCharacters - the character to be replaced by newCharacters.newCharacters - the character replacing oldCharacters.
public static int getInt(java.lang.String integer)
integer - returns 0 for non integer values
public static int getInt(java.lang.String integer,
int defaultValue)
integer - returns 0 for non integer values
public static int getLastStartsWith(java.lang.String[] data,
java.lang.String value)
public static long getLong(java.lang.String value,
long defaultValue)
long - returns defaultValue for non long values
public static java.util.Comparator getNaturalComparator()
For example in German locale this will be a comparator that handles umlauts correctly and ignores upper/lower case differences.
A string comparator that uses the current locale's order rules and handles embedded numbers correctly.
getNaturalComparator(java.text.Collator)public static java.util.Comparator getNaturalComparator(java.text.Collator collator)
collator - used for locale specific comparison of text (non-number) subwords - must not be null
A string comparator that uses the given Collator to compare subwords and handles embedded numbers correctly.
getNaturalComparator()public static java.util.Comparator getNaturalComparatorAscii()
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.getNaturalComparator(),
getNaturalComparator(java.text.Collator)public static java.util.Comparator getNaturalComparatorIgnoreCaseAscii()
a string comparator that does case insensitive comparisons on pure ascii strings and handles embedded numbers correctly.
getNaturalComparator(),
getNaturalComparator(java.text.Collator)public static java.util.Comparator getNaturalTypeTreeLabelComparator()
For example in German locale this will be a comparator that handles umlauts correctly and ignores upper/lower case differences.
A string comparator that uses the current locale's order rules and handles embedded numbers correctly.
getNaturalComparator(java.text.Collator)public static java.util.Comparator getNaturalTypeTreeLabelComparator(java.text.Collator collator)
collator - used for locale specific comparison of text (non-number) subwords - must not be null
A string comparator that uses the given Collator to compare subwords and handles embedded numbers correctly.
getNaturalComparator()public static java.util.Comparator getNaturalTypeXPathComparator()
For example in German locale this will be a comparator that handles umlauts correctly and ignores upper/lower case differences.
A string comparator that uses the current locale's order rules and handles embedded numbers correctly.
getNaturalComparator(java.text.Collator)public static java.util.Comparator getNaturalTypeXPathComparator(java.text.Collator collator)
collator - used for locale specific comparison of text (non-number) subwords - must not be null
A string comparator that uses the given Collator to compare subwords and handles embedded numbers correctly.
getNaturalComparator()
public static int[] getOptimalColWidth(java.util.HashMap colFormatters,
int readAhead,
int[] minVals,
int maxVal,
int filerColumn,
java.lang.String[] visColNames,
java.lang.String[][] values)
public static java.lang.String getQuoted(java.lang.String str)
public static int getSequenceChangePos(int[] cData,
int offset)
public static int getSequenceChangePos(java.util.List<java.lang.Object[]> data,
int offset,
int arrPos)
public static int getSequenceChangePos(java.util.List data,
int offset)
public static int getSequenceChangePosLast(int[] cData,
int offset)
public static int getSequenceChangePosLast(java.util.List<java.lang.Object[]> data,
int offset,
int arrPos)
public static int getSequenceChangePosLast(java.util.List data,
int offset)
public static short getShort(java.lang.String value,
short defaultValue)
public static java.lang.String getSQuoted(java.lang.String str)
public static java.lang.String getStackTrace(java.lang.Exception e)
public static java.util.regex.Pattern getStartsWithAnyIgnoreCasePattern(java.lang.String[] 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.
terms - Array of search strings.
public static java.util.regex.Pattern getStartsWithAnyPattern(java.lang.String[] 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.
terms - Array of search strings.
public static int indexOfIgnoreCase(java.lang.String string,
java.lang.String substring,
int fromIndex)
public static java.lang.String insert(java.lang.String into,
int pos,
char what)
public static java.lang.String insert(java.lang.String into,
int pos,
java.lang.String what)
string.startsWith(substring, <i>k</i>)
is true.
string - any string.substring - any string.fromIndex - the index from which to start the search.
-1 is returned.
java.lang.NullPointerException - if string or substring is null.public static boolean isAlpha(char v)
public static boolean isAlpha(java.lang.String str)
public static boolean isAlphaNumeric(char v)
public static boolean isAlphaNumeric(java.lang.String str)
public static boolean isDigit(char v)
public static boolean isEmpty(java.lang.String str)
public static boolean isFloatString(java.lang.String str)
public static boolean isInteger(java.lang.String myInput)
public static boolean isIntegerString(java.lang.String str)
public static boolean isNumeric(java.lang.String text)
text - the text
public static boolean isTrue(java.lang.String val)
public static void main(java.lang.String[] args)
public static java.lang.String midpad(java.lang.String s,
int length)
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.
s - String to be padded.length - desired length of result.
java.lang.NullPointerException - if s is null.
public static java.lang.String midpad(java.lang.String s,
int length,
char c)
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.
s - String to be padded.length - desired length of result.c - padding character.
java.lang.NullPointerException - if s is null.public static java.lang.String nullToEmpty(java.lang.String text)
public static int numberOfDigits(java.lang.String text)
text - string
public static boolean parseBoolean(java.lang.String s,
boolean defaultVal)
public static java.lang.String postpad(java.lang.String s,
int length)
If a String is longer than the desired length, it will not be truncated, however no padding will be added.
s - String to be padded.length - desired length of result.
java.lang.NullPointerException - if s is null.
public static java.lang.String postpad(java.lang.String s,
int length,
char c)
If a String is longer than the desired length, it will not be truncated, however no padding will be added.
s - String to be padded.length - desired length of result.c - padding character.
java.lang.NullPointerException - if s is null.
public static java.lang.String prepad(java.lang.String s,
int length)
If a String is longer than the desired length, it will not be truncated, however no padding will be added.
s - String to be padded.length - desired length of result.
java.lang.NullPointerException - if s is null.
public static java.lang.String prepad(java.lang.String s,
int length,
char c)
If a String is longer than the desired length, it will not be truncated, however no padding will be added.
s - String to be padded.length - desired length of result.c - padding character.
java.lang.NullPointerException - if s is null.public static java.lang.StringBuilder printQuoted(java.lang.StringBuilder str)
public static java.util.List readLines(java.io.InputStream inStream,
boolean skipEmpty)
throws java.io.IOException
java.io.IOExceptionpublic void recursionMemTestfor(int value)
public void recursionMemTestRec(int value)
public static java.lang.String removeAllBetween(java.lang.String text,
java.lang.String startQuali,
java.lang.String endQuali)
public static java.lang.String removeAllBetween(java.lang.String text,
java.lang.String startQuali,
java.lang.String endQuali,
boolean onlyNumeric)
public static java.lang.String[][] removeDuplicates(int startCol,
java.lang.String[][] data)
public static java.util.List removeDuplicates(java.util.List strArrData)
public static java.util.List removeDuplicates(java.lang.String[] data)
public static java.lang.String removeIfFirst(java.lang.String value,
java.lang.String first)
public static java.lang.String removeIfFirstLast(java.lang.String string,
java.lang.String first,
java.lang.String last)
public static java.lang.String removeIfLast(java.lang.String value,
java.lang.String last)
public static java.lang.String removeIfLast(java.lang.String value,
java.lang.String last,
boolean trimRight)
public static java.lang.String removeSpaceChars(java.lang.String result)
public static java.lang.String removeSpecialChars(java.lang.String result)
public static java.lang.String removeSpecialChars(java.lang.String result,
boolean spaceIncluded)
public static java.lang.String repeat(int times,
java.lang.String what)
public static java.lang.StringBuffer replace(java.lang.StringBuffer source,
char[] from,
java.lang.String[] to)
source - source Stringfrom - String array with to be replaced valuesto - char array with the replacement
public static java.lang.String replace(java.lang.String source,
char[] from,
char to)
public static java.lang.String replace(java.lang.String source,
char[] from,
java.lang.String[] to)
source - source Stringfrom - String array with to be replaced valuesto - char array with the replacement
public static java.lang.String replace(java.lang.String text,
char varIdentifier,
java.lang.String[] values)
public static java.lang.String replace(java.lang.String source,
java.lang.String[] from,
char[] to)
source - source Stringfrom - String array with to be replaced valuesto - char array with the replacement
public static java.lang.String replace(java.lang.String text,
java.lang.String oldCharacters,
java.lang.String newCharacters)
public static java.lang.String replaceAllBetween(java.lang.String text,
java.lang.String startQuali,
java.lang.String endQuali,
java.lang.String replace)
text - startQuali - endQuali - replace -
public static java.lang.String replaceIgnoreCase(java.lang.String text,
java.lang.String oldCharacters,
java.lang.String newCharacters)
text - string where characters should be replacedoldCharacters - the character to be replaced by newCharacters.newCharacters - the character replacing oldCharacters.
public static java.lang.String replaceLetters(java.lang.String result,
java.lang.String replacement)
public static java.lang.String replaceNumberTail(java.lang.String source,
long replacement)
public static java.lang.String shredder(java.lang.String text,
int length,
int startAt)
public static java.lang.String[] split(java.lang.String s,
java.lang.String delimiter)
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"}
s - String to be split.delimiter - String literal on which to split.
java.lang.NullPointerException - if s is null.
public static java.util.List split(java.lang.String s,
java.lang.String token,
java.lang.String reserved)
public static java.lang.String[] splitString(java.lang.String s,
java.lang.String token,
java.lang.String reserved)
public static boolean startsWithAny(java.lang.String s,
java.lang.String[] 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.
s - String that may start with any of the given terms.terms - list of strings that may start with the given string.
getStartsWithAnyPattern(String[])
public static boolean startsWithAnyIgnoreCase(java.lang.String s,
java.lang.String[] 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.
s - String that may start with any of the given terms.terms - list of strings that may start with the given string.
getStartsWithAnyIgnoreCasePattern(String[])
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).
str - the String to check, may be nullprefix - the prefix to find, may be nulloffset -
true if the String starts with the prefix or both nullString.startsWith(String)
public static java.lang.String substring(java.lang.String value,
java.lang.String startId,
java.lang.String endId)
public static java.lang.String substringAfter(java.lang.String value,
java.lang.String what)
public static java.lang.String substringBefore(java.lang.String value,
java.lang.String what)
public static java.lang.String[] toLines(java.lang.String logoText)
public static java.lang.String[] trim(java.lang.String[] columnNames)
public static java.lang.String trim(java.lang.String s,
java.lang.String c)
s - String to be trimmed.c - list of characters to trim from s.
java.lang.NullPointerException - if s is null.public static java.lang.String trimLeft(java.lang.String content)
public static java.lang.String trimRight(java.lang.String content)
public static java.lang.String unEscapeFreemarker(java.lang.String value)
public static java.lang.String unescapeHTML(java.lang.String s)
s - String to be unescaped.
java.lang.NullPointerException - if s is null.public static java.lang.String[] unescapeHTML(java.lang.String[] values)
public static java.lang.String unEscapeJavaLiteral(java.lang.String s)
public static java.lang.String unEscapeLiteral(java.lang.String s,
java.lang.String lit,
java.lang.String with)
public static java.lang.String unEscapeSQLLiteral(java.lang.String s)
public static java.lang.String unEscapeToURLEncoding(java.lang.String value)
public static java.lang.String[] unEscapeToURLEncoding(java.lang.String[] values)
public static java.lang.String unEscapeXML(java.lang.String str)
public static java.lang.String verticalize(java.lang.String text)
public static void writeln(java.io.BufferedWriter bw,
java.lang.String s)
throws java.io.IOException
java.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||