Class LocaleDistance

java.lang.Object
org.graalvm.shadowed.com.ibm.icu.impl.locale.LocaleDistance

public class LocaleDistance extends Object
Offline-built data for LocaleMatcher. Mostly but not only the data for mapping locales to their maximized forms.
  • Field Details

    • END_OF_SUBTAG

      public static final int END_OF_SUBTAG
      Bit flag used on the last character of a subtag in the trie. Must be set consistently by the builder and the lookup code.
      See Also:
    • DISTANCE_SKIP_SCRIPT

      public static final int DISTANCE_SKIP_SCRIPT
      Distance value bit flag, set by the builder.
      See Also:
    • IX_DEF_LANG_DISTANCE

      public static final int IX_DEF_LANG_DISTANCE
      See Also:
    • IX_DEF_SCRIPT_DISTANCE

      public static final int IX_DEF_SCRIPT_DISTANCE
      See Also:
    • IX_DEF_REGION_DISTANCE

      public static final int IX_DEF_REGION_DISTANCE
      See Also:
    • IX_MIN_REGION_DISTANCE

      public static final int IX_MIN_REGION_DISTANCE
      See Also:
    • IX_LIMIT

      public static final int IX_LIMIT
      See Also:
    • INSTANCE

      public static final LocaleDistance INSTANCE
  • Method Details

    • shiftDistance

      public static final int shiftDistance(int distance)
    • getShiftedDistance

      public static final int getShiftedDistance(int indexAndDistance)
    • getDistanceDouble

      public static final double getDistanceDouble(int indexAndDistance)
    • getDistanceFloor

      public static final int getDistanceFloor(int indexAndDistance)
    • getIndex

      public static final int getIndex(int indexAndDistance)
    • testOnlyDistance

      public int testOnlyDistance(ULocale desired, ULocale supported, int threshold, LocaleMatcher.FavorSubtag favorSubtag)
    • getBestIndexAndDistance

      public int getBestIndexAndDistance(LSR desired, LSR[] supportedLSRs, int supportedLSRsLength, int shiftedThreshold, LocaleMatcher.FavorSubtag favorSubtag, LocaleMatcher.Direction direction)
      Finds the supported LSR with the smallest distance from the desired one. Equivalent LSR subtags must be normalized into a canonical form.

      Returns the index of the lowest-distance supported LSR in the high bits (negative if none has a distance below the threshold), and its distance (0..ABOVE_THRESHOLD) in the low bits.

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isParadigmLSR

      public boolean isParadigmLSR(LSR lsr)
    • getDefaultScriptDistance

      public int getDefaultScriptDistance()
    • getDefaultDemotionPerDesiredLocale

      public int getDefaultDemotionPerDesiredLocale()
    • testOnlyGetDistanceTable

      public Map<String,Integer> testOnlyGetDistanceTable()
    • testOnlyPrintDistanceTable

      public void testOnlyPrintDistanceTable()