java.lang.Object
org.xbib.interlibrary.catalog.matching.string.NaturalOrderComparator

public final class NaturalOrderComparator extends Object
A natural order comparator.
  • Methodendetails

    • getNaturalComparator

      public static Comparator<String> 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

      public 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.
      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

      public static Comparator<String> 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

      public static Comparator<String> 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

      public static int compareNatural(String s, 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(Collator, String, String)

      Parameter:
      s - first string
      t - second string
      Gibt zurück:
      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(Collator collator, String s, String t)

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

      Parameter:
      collator - collator
      s - first string
      t - second string
      Gibt zurück:
      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(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.

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

      Parameter:
      s - s
      t - t
      Gibt zurück:
      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(String s, 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.)

      Parameter:
      s - s
      t - t
      Gibt zurück:
      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