Klasse NaturalOrderComparator
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic int
compareNatural
(String s, String t) Compares two strings using the current locale's rules and comparing contained numbers based on their numeric values.static int
compareNatural
(Collator collator, String s, String t) Compares two strings using the given collator and comparing contained numbers based on their numeric values.static int
compareNaturalAscii
(String s, 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
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 Comparator
<String> Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the current locale's order rules.static Comparator
<String> getNaturalComparator
(Collator collator) Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.static Comparator
<String> Returns a comparator that compares contained numbers based on their numeric values and compares other parts based on each character's Unicode value.static Comparator
<String> 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.
-
Methodendetails
-
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.
- Gibt zurück:
A string comparator that uses the current locale's order rules and handles embedded numbers correctly.
- Siehe auch:
-
getNaturalComparator
Returns a comparator that compares contained numbers based on their numeric values and compares other parts using the given collator.- Parameter:
collator
- used for locale specific comparison of text (non-number) subwords - must not be null- Gibt zurück:
A string comparator that uses the given Collator to compare subwords and handles embedded numbers correctly.
- Siehe auch:
-
getNaturalComparatorAscii
Returns a comparator that compares contained numbers based on their numeric values and compares other parts based on each character's Unicode value.- Gibt zurück:
a string comparator that does case sensitive comparisons on 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.- Siehe auch:
-
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.- Gibt zurück:
a string comparator that does case insensitive comparisons on ascii strings and handles embedded numbers correctly.
- Siehe auch:
-
compareNatural
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 tocompareNatural(Collator, String, String)
- Parameter:
s
- first stringt
- second string- Gibt zurück:
- zero iff
s
andt
are equal, a value less than zero iffs
lexicographically precedest
and a value larger than zero iffs
lexicographically followst
-
compareNatural
Compares two strings using the given collator and comparing contained numbers based on their numeric values.
- Parameter:
collator
- collators
- first stringt
- second string- Gibt zurück:
- zero iff
s
andt
are equal, a value less than zero iffs
lexicographically precedest
and a value larger than zero iffs
lexicographically followst
-
compareNaturalAscii
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.)
- Parameter:
s
- st
- t- Gibt zurück:
- zero iff
s
andt
are equal, a value less than zero iffs
lexicographically precedest
and a value larger than zero iffs
lexicographically followst
-
compareNaturalIgnoreCaseAscii
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.)
- Parameter:
s
- st
- t- Gibt zurück:
- zero iff
s
andt
are equal, a value less than zero iffs
lexicographically precedest
and a value larger than zero iffs
lexicographically followst
-