|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jaxfront.core.util.StringUtils
public class StringUtils
Provides string utilities.
Field Summary | |
---|---|
static java.lang.String |
doubleQuote
|
static java.lang.String |
newLine
|
static java.lang.String |
newTab
|
static java.lang.String |
space
|
Constructor Summary | |
---|---|
StringUtils()
|
Method Summary | |
---|---|
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 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.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 |
indexOfIgnoreCase(java.lang.String string,
java.lang.String substring,
int fromIndex)
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 |
isInteger(java.lang.String myInput)
|
static boolean |
isNumeric(java.lang.String text)
Checks whether the given input string is numeric. |
static void |
main(java.lang.String[] args)
|
static int |
numberOfDigits(java.lang.String text)
Counts the number of digits in the specified text. |
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 |
replace(java.lang.String text,
java.lang.String oldCharacters,
java.lang.String newCharacters)
Replaces indicated characters with other characters. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String newLine
public static final java.lang.String newTab
public static final java.lang.String doubleQuote
public static final java.lang.String space
Constructor Detail |
---|
public StringUtils()
Method Detail |
---|
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 appendedpublic static java.lang.String replace(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 int numberOfDigits(java.lang.String text)
text
- string
public static int indexOfIgnoreCase(java.lang.String string, java.lang.String substring, int fromIndex)
isstring.startsWith(substring, <i>k</i>)
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 java.lang.String removeSpecialChars(java.lang.String result, boolean spaceIncluded)
public static java.lang.String removeSpecialChars(java.lang.String result)
public static java.lang.String removeSpaceChars(java.lang.String result)
public static boolean isNumeric(java.lang.String text)
text
- the text
public static boolean isInteger(java.lang.String myInput)
public static void main(java.lang.String[] args)
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 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 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 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 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 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 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |