Class TimeZoneNamesImpl

java.lang.Object
com.ibm.icu.text.TimeZoneNames
com.ibm.icu.impl.TimeZoneNamesImpl
All Implemented Interfaces:
Serializable

public class TimeZoneNamesImpl extends TimeZoneNames
The standard ICU implementation of TimeZoneNames
See Also:
  • Field Details

  • Constructor Details

    • TimeZoneNamesImpl

      public TimeZoneNamesImpl(ULocale locale)
  • Method Details

    • getAvailableMetaZoneIDs

      public Set<String> getAvailableMetaZoneIDs()
      Description copied from class: TimeZoneNames
      Returns an immutable set of all available meta zone IDs.
      Specified by:
      getAvailableMetaZoneIDs in class TimeZoneNames
      Returns:
      An immutable set of all available meta zone IDs.
    • _getAvailableMetaZoneIDs

      static Set<String> _getAvailableMetaZoneIDs()
    • getAvailableMetaZoneIDs

      public Set<String> getAvailableMetaZoneIDs(String tzID)
      Description copied from class: TimeZoneNames
      Returns an immutable set of all available meta zone IDs used by the given time zone.
      Specified by:
      getAvailableMetaZoneIDs in class TimeZoneNames
      Parameters:
      tzID - The canonical time zone ID.
      Returns:
      An immutable set of all available meta zone IDs used by the given time zone.
    • _getAvailableMetaZoneIDs

      static Set<String> _getAvailableMetaZoneIDs(String tzID)
    • getMetaZoneID

      public String getMetaZoneID(String tzID, long date)
      Description copied from class: TimeZoneNames
      Returns the meta zone ID for the given canonical time zone ID at the given date.
      Specified by:
      getMetaZoneID in class TimeZoneNames
      Parameters:
      tzID - The canonical time zone ID.
      date - The date.
      Returns:
      The meta zone ID for the given time zone ID at the given date. If the time zone does not have a corresponding meta zone at the given date or the implementation does not support meta zones, null is returned.
    • _getMetaZoneID

      static String _getMetaZoneID(String tzID, long date)
    • getReferenceZoneID

      public String getReferenceZoneID(String mzID, String region)
      Description copied from class: TimeZoneNames
      Returns the reference zone ID for the given meta zone ID for the region. Note: Each meta zone must have a reference zone associated with a special region "001" (world). Some meta zones may have region specific reference zone IDs other than the special region "001". When a meta zone does not have any region specific reference zone IDs, this method return the reference zone ID for the special region "001" (world).
      Specified by:
      getReferenceZoneID in class TimeZoneNames
      Parameters:
      mzID - The meta zone ID.
      region - The region.
      Returns:
      The reference zone ID ("golden zone" in the LDML specification) for the given time zone ID for the region. If the meta zone is unknown or the implementation does not support meta zones, null is returned.
    • _getReferenceZoneID

      static String _getReferenceZoneID(String mzID, String region)
    • getMetaZoneDisplayName

      public String getMetaZoneDisplayName(String mzID, TimeZoneNames.NameType type)
      Description copied from class: TimeZoneNames
      Returns the display name of the meta zone.
      Specified by:
      getMetaZoneDisplayName in class TimeZoneNames
      Parameters:
      mzID - The meta zone ID.
      type - The display name type. See TimeZoneNames.NameType.
      Returns:
      The display name of the meta zone. When this object does not have a localized display name for the given meta zone with the specified type or the implementation does not provide any display names associated with meta zones, null is returned.
    • getTimeZoneDisplayName

      public String getTimeZoneDisplayName(String tzID, TimeZoneNames.NameType type)
      Description copied from class: TimeZoneNames
      Returns the display name of the time zone. Unlike TimeZoneNames.getDisplayName(String, NameType, long), this method does not get a name from a meta zone used by the time zone.
      Specified by:
      getTimeZoneDisplayName in class TimeZoneNames
      Parameters:
      tzID - The canonical time zone ID.
      type - The display name type. See TimeZoneNames.NameType.
      Returns:
      The display name for the time zone. When this object does not have a localized display name for the given time zone with the specified type, null is returned.
    • getExemplarLocationName

      public String getExemplarLocationName(String tzID)
      Description copied from class: TimeZoneNames
      Returns the exemplar location name for the given time zone. When this object does not have a localized location name, the default implementation may still returns a programmatically generated name with the logic described below.
      1. Check if the ID contains "/". If not, return null.
      2. Check if the ID does not start with "Etc/" or "SystemV/". If it does, return null.
      3. Extract a substring after the last occurrence of "/".
      4. Replace "_" with " ".
      For example, "New York" is returned for the time zone ID "America/New_York" when this object does not have the localized location name.
      Overrides:
      getExemplarLocationName in class TimeZoneNames
      Parameters:
      tzID - The canonical time zone ID
      Returns:
      The exemplar location name for the given time zone, or null when a localized location name is not available and the fallback logic described above cannot extract location from the ID.
    • find

      public Collection<TimeZoneNames.MatchInfo> find(CharSequence text, int start, EnumSet<TimeZoneNames.NameType> nameTypes)
      Description copied from class: TimeZoneNames
      Finds time zone name prefix matches for the input text at the given offset and returns a collection of the matches.
      Overrides:
      find in class TimeZoneNames
      Parameters:
      text - the text.
      start - the starting offset within the text.
      nameTypes - the set of name types, or null for all name types.
      Returns:
      A collection of matches.
      See Also:
    • doFind

    • loadAllDisplayNames

      public void loadAllDisplayNames()
      Overrides:
      loadAllDisplayNames in class TimeZoneNames
    • getDisplayNames

      public void getDisplayNames(String tzID, TimeZoneNames.NameType[] types, long date, String[] dest, int destOffset)
      Overrides:
      getDisplayNames in class TimeZoneNames
    • internalLoadAllDisplayNames

      private void internalLoadAllDisplayNames()
      Caller must synchronize.
    • addAllNamesIntoTrie

      private void addAllNamesIntoTrie()
      Caller must synchronize.
    • initialize

      private void initialize(ULocale locale)
      Initialize the transient fields, called from the constructor and readObject.
      Parameters:
      locale - The locale
    • loadStrings

      private void loadStrings(String tzCanonicalID)
      Load all strings used by the specified time zone. This is called from the initializer to load default zone's strings.
      Parameters:
      tzCanonicalID - the canonical time zone ID
    • writeObject

      private void writeObject(ObjectOutputStream out) throws IOException
      Throws:
      IOException
    • readObject

      private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
      Throws:
      IOException
      ClassNotFoundException
    • loadMetaZoneNames

      private TimeZoneNamesImpl.ZNames loadMetaZoneNames(String mzID)
      Returns a set of names for the given meta zone ID. This method loads the set of names into the internal map and trie for future references.
      Parameters:
      mzID - the meta zone ID
      Returns:
      An instance of ZNames that includes a set of meta zone display names.
    • loadTimeZoneNames

      private TimeZoneNamesImpl.ZNames loadTimeZoneNames(String tzID)
      Returns a set of names for the given time zone ID. This method loads the set of names into the internal map and trie for future references.
      Parameters:
      tzID - the canonical time zone ID
      Returns:
      An instance of ZNames that includes a set of time zone display names.
    • getDefaultExemplarLocationName

      public static String getDefaultExemplarLocationName(String tzID)
      Default exemplar location name based on time zone ID. For example, "America/New_York" -> "New York"
      Parameters:
      tzID - the time zone ID
      Returns:
      the exemplar location name or null if location is not available.