Class ICUService.Key

java.lang.Object
com.ibm.icu.impl.ICUService.Key
Direct Known Subclasses:
ICULocaleService.LocaleKey
Enclosing class:
ICUService

public static class ICUService.Key extends Object
Keys are used to communicate with factories to generate an instance of the service. Keys define how ids are canonicalized, provide both a current id and a current descriptor to use in querying the cache and factories, and determine the fallback strategy.

Keys provide both a currentDescriptor and a currentID. The descriptor contains an optional prefix, followed by '/' and the currentID. Factories that handle complex keys, for example number format factories that generate multiple kinds of formatters for the same locale, use the descriptor to provide a fully unique identifier for the service object, while using the currentID (in this case, the locale string), as the visible IDs that can be localized.

The default implementation of Key has no fallbacks and has no custom descriptors.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Key(String id)
    Construct a key from an id.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the canonical version of the original ID.
    Return the current descriptor.
    Return the (canonical) current ID.
    boolean
    If the key has a fallback, modify the key and return true, otherwise return false.
    final String
    id()
    Return the original ID used to construct this key.
    boolean
    isFallbackOf(String idToCheck)
    If a key created from id would eventually fallback to match the canonical ID of this key, return true.

    Methods inherited from class java.lang.Object

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

    • id

      private final String id
  • Constructor Details

    • Key

      public Key(String id)
      Construct a key from an id.
  • Method Details

    • id

      public final String id()
      Return the original ID used to construct this key.
    • canonicalID

      public String canonicalID()
      Return the canonical version of the original ID. This implementation returns the original ID unchanged.
    • currentID

      public String currentID()
      Return the (canonical) current ID. This implementation returns the canonical ID.
    • currentDescriptor

      public String currentDescriptor()
      Return the current descriptor. This implementation returns the current ID. The current descriptor is used to fully identify an instance of the service in the cache. A factory may handle all descriptors for an ID, or just a particular descriptor. The factory can either parse the descriptor or use custom API on the key in order to instantiate the service.
    • fallback

      public boolean fallback()
      If the key has a fallback, modify the key and return true, otherwise return false. The current ID will change if there is a fallback. No currentIDs should be repeated, and fallback must eventually return false. This implementation has no fallbacks and always returns false.
    • isFallbackOf

      public boolean isFallbackOf(String idToCheck)
      If a key created from id would eventually fallback to match the canonical ID of this key, return true.