Class ICULocaleService.LocaleKey

  • Enclosing class:
    ICULocaleService

    public static class ICULocaleService.LocaleKey
    extends ICUService.Key
    A subclass of Key that implements a locale fallback mechanism. The first locale to search for is the locale provided by the client, and the fallback locale to search for is the current default locale. If a prefix is present, the currentDescriptor includes it before the locale proper, separated by "/". This is the default key instantiated by ICULocaleService.

    Canonicalization adjusts the locale string so that the section before the first understore is in lower case, and the rest is in upper case, with no trailing underscores.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected LocaleKey​(java.lang.String primaryID, java.lang.String canonicalPrimaryID, java.lang.String canonicalFallbackID, int kind)
      PrimaryID is the user's requested locale string, canonicalPrimaryID is this string in canonical form, fallbackID is the current default locale's string in canonical form.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String canonicalID()
      Return the (canonical) original ID.
      ULocale canonicalLocale()
      Convenience method to return the locale corresponding to the (canonical) original ID.
      static ICULocaleService.LocaleKey createWithCanonical​(ULocale locale, java.lang.String canonicalFallbackID, int kind)
      Create a LocaleKey with canonical primary and fallback IDs.
      static ICULocaleService.LocaleKey createWithCanonicalFallback​(java.lang.String primaryID, java.lang.String canonicalFallbackID)
      Create a LocaleKey with canonical primary and fallback IDs.
      static ICULocaleService.LocaleKey createWithCanonicalFallback​(java.lang.String primaryID, java.lang.String canonicalFallbackID, int kind)
      Create a LocaleKey with canonical primary and fallback IDs.
      java.lang.String currentDescriptor()
      Return the (canonical) current descriptor, or null if no current id.
      java.lang.String currentID()
      Return the (canonical) current ID, or null if no current id.
      ULocale currentLocale()
      Convenience method to return the ulocale corresponding to the (canonical) currentID.
      boolean fallback()
      If the key has a fallback, modify the key and return true, otherwise return false.
      boolean isFallbackOf​(java.lang.String id)
      If a key created from id would eventually fallback to match the canonical ID of this key, return true.
      int kind()
      Return the kind code associated with this key.
      java.lang.String prefix()
      Return the prefix associated with the kind, or null if the kind is KIND_ANY.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • kind

        private int kind
      • varstart

        private int varstart
      • primaryID

        private java.lang.String primaryID
      • fallbackID

        private java.lang.String fallbackID
      • currentID

        private java.lang.String currentID
    • Constructor Detail

      • LocaleKey

        protected LocaleKey​(java.lang.String primaryID,
                            java.lang.String canonicalPrimaryID,
                            java.lang.String canonicalFallbackID,
                            int kind)
        PrimaryID is the user's requested locale string, canonicalPrimaryID is this string in canonical form, fallbackID is the current default locale's string in canonical form.
    • Method Detail

      • createWithCanonicalFallback

        public static ICULocaleService.LocaleKey createWithCanonicalFallback​(java.lang.String primaryID,
                                                                             java.lang.String canonicalFallbackID)
        Create a LocaleKey with canonical primary and fallback IDs.
      • createWithCanonicalFallback

        public static ICULocaleService.LocaleKey createWithCanonicalFallback​(java.lang.String primaryID,
                                                                             java.lang.String canonicalFallbackID,
                                                                             int kind)
        Create a LocaleKey with canonical primary and fallback IDs.
      • createWithCanonical

        public static ICULocaleService.LocaleKey createWithCanonical​(ULocale locale,
                                                                     java.lang.String canonicalFallbackID,
                                                                     int kind)
        Create a LocaleKey with canonical primary and fallback IDs.
      • prefix

        public java.lang.String prefix()
        Return the prefix associated with the kind, or null if the kind is KIND_ANY.
      • kind

        public int kind()
        Return the kind code associated with this key.
      • canonicalID

        public java.lang.String canonicalID()
        Return the (canonical) original ID.
        Overrides:
        canonicalID in class ICUService.Key
      • currentID

        public java.lang.String currentID()
        Return the (canonical) current ID, or null if no current id.
        Overrides:
        currentID in class ICUService.Key
      • currentDescriptor

        public java.lang.String currentDescriptor()
        Return the (canonical) current descriptor, or null if no current id. Includes the keywords, whereas the ID does not include keywords.
        Overrides:
        currentDescriptor in class ICUService.Key
      • canonicalLocale

        public ULocale canonicalLocale()
        Convenience method to return the locale corresponding to the (canonical) original ID.
      • currentLocale

        public ULocale currentLocale()
        Convenience method to return the ulocale corresponding to the (canonical) currentID.
      • fallback

        public boolean fallback()
        If the key has a fallback, modify the key and return true, otherwise return false.

        First falls back through the primary ID, then through the fallbackID. The final fallback is "" (root) unless the primary id was "" (root), in which case there is no fallback.

        Overrides:
        fallback in class ICUService.Key
      • isFallbackOf

        public boolean isFallbackOf​(java.lang.String id)
        If a key created from id would eventually fallback to match the canonical ID of this key, return true.
        Overrides:
        isFallbackOf in class ICUService.Key