Package com.ibm.icu.impl
Class TimeZoneNamesImpl
java.lang.Object
com.ibm.icu.text.TimeZoneNames
com.ibm.icu.impl.TimeZoneNamesImpl
- All Implemented Interfaces:
Serializable
The standard ICU implementation of TimeZoneNames
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
private static class
An instance of NameInfo is stored in the zone names trie.private static class
NameSearchHandler is used for collecting name matches.private static class
private static class
This class stores name data for a meta zone or time zone.private static final class
private final class
Loads all meta zone and time zone names for this TimeZoneNames' locale.Nested classes/interfaces inherited from class com.ibm.icu.text.TimeZoneNames
TimeZoneNames.Factory, TimeZoneNames.MatchInfo, TimeZoneNames.NameType
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private TextTrieMap
<TimeZoneNamesImpl.NameInfo> private boolean
private ICUResourceBundle
private static final Pattern
private static final String
private static final TimeZoneNamesImpl.MZ2TZsCache
private static final long
private static final TimeZoneNamesImpl.TZ2MZsCache
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static String
_getMetaZoneID
(String tzID, long date) (package private) static String
_getReferenceZoneID
(String mzID, String region) private void
Caller must synchronize.private Collection
<TimeZoneNames.MatchInfo> doFind
(TimeZoneNamesImpl.NameSearchHandler handler, CharSequence text, int start) find
(CharSequence text, int start, EnumSet<TimeZoneNames.NameType> nameTypes) Finds time zone name prefix matches for the input text at the given offset and returns a collection of the matches.Returns an immutable set of all available meta zone IDs.Returns an immutable set of all available meta zone IDs used by the given time zone.static String
Default exemplar location name based on time zone ID.void
getDisplayNames
(String tzID, TimeZoneNames.NameType[] types, long date, String[] dest, int destOffset) Returns the exemplar location name for the given time zone.getMetaZoneDisplayName
(String mzID, TimeZoneNames.NameType type) Returns the display name of the meta zone.getMetaZoneID
(String tzID, long date) Returns the meta zone ID for the given canonical time zone ID at the given date.getReferenceZoneID
(String mzID, String region) Returns the reference zone ID for the given meta zone ID for the region.getTimeZoneDisplayName
(String tzID, TimeZoneNames.NameType type) Returns the display name of the time zone.private void
initialize
(ULocale locale) Initialize the transient fields, called from the constructor and readObject.private void
Caller must synchronize.void
private TimeZoneNamesImpl.ZNames
loadMetaZoneNames
(String mzID) Returns a set of names for the given meta zone ID.private void
loadStrings
(String tzCanonicalID) Load all strings used by the specified time zone.private TimeZoneNamesImpl.ZNames
loadTimeZoneNames
(String tzID) Returns a set of names for the given time zone ID.private void
private void
Methods inherited from class com.ibm.icu.text.TimeZoneNames
getDisplayName, getInstance, getInstance, getTZDBInstance
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
ZONE_STRINGS_BUNDLE
- See Also:
-
MZ_PREFIX
- See Also:
-
METAZONE_IDS
-
TZ_TO_MZS_CACHE
-
MZ_TO_TZS_CACHE
-
_zoneStrings
-
_mzNamesMap
-
_tzNamesMap
-
_namesFullyLoaded
private transient boolean _namesFullyLoaded -
_namesTrie
-
_namesTrieFullyLoaded
private transient boolean _namesTrieFullyLoaded -
LOC_EXCLUSION_PATTERN
-
-
Constructor Details
-
TimeZoneNamesImpl
-
-
Method Details
-
getAvailableMetaZoneIDs
Description copied from class:TimeZoneNames
Returns an immutable set of all available meta zone IDs.- Specified by:
getAvailableMetaZoneIDs
in classTimeZoneNames
- Returns:
- An immutable set of all available meta zone IDs.
-
_getAvailableMetaZoneIDs
-
getAvailableMetaZoneIDs
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 classTimeZoneNames
- Parameters:
tzID
- The canonical time zone ID.- Returns:
- An immutable set of all available meta zone IDs used by the given time zone.
-
_getAvailableMetaZoneIDs
-
getMetaZoneID
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 classTimeZoneNames
- 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
-
getReferenceZoneID
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 classTimeZoneNames
- 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
-
getMetaZoneDisplayName
Description copied from class:TimeZoneNames
Returns the display name of the meta zone.- Specified by:
getMetaZoneDisplayName
in classTimeZoneNames
- Parameters:
mzID
- The meta zone ID.type
- The display name type. SeeTimeZoneNames.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
Description copied from class:TimeZoneNames
Returns the display name of the time zone. UnlikeTimeZoneNames.getDisplayName(String, NameType, long)
, this method does not get a name from a meta zone used by the time zone.- Specified by:
getTimeZoneDisplayName
in classTimeZoneNames
- Parameters:
tzID
- The canonical time zone ID.type
- The display name type. SeeTimeZoneNames.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
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.- Check if the ID contains "/". If not, return null.
- Check if the ID does not start with "Etc/" or "SystemV/". If it does, return null.
- Extract a substring after the last occurrence of "/".
- Replace "_" with " ".
- Overrides:
getExemplarLocationName
in classTimeZoneNames
- 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 classTimeZoneNames
- Parameters:
text
- the text.start
- the starting offset within the text.nameTypes
- the set of name types, ornull
for all name types.- Returns:
- A collection of matches.
- See Also:
-
doFind
private Collection<TimeZoneNames.MatchInfo> doFind(TimeZoneNamesImpl.NameSearchHandler handler, CharSequence text, int start) -
loadAllDisplayNames
public void loadAllDisplayNames()- Overrides:
loadAllDisplayNames
in classTimeZoneNames
-
getDisplayNames
public void getDisplayNames(String tzID, TimeZoneNames.NameType[] types, long date, String[] dest, int destOffset) - Overrides:
getDisplayNames
in classTimeZoneNames
-
internalLoadAllDisplayNames
private void internalLoadAllDisplayNames()Caller must synchronize. -
addAllNamesIntoTrie
private void addAllNamesIntoTrie()Caller must synchronize. -
initialize
Initialize the transient fields, called from the constructor and readObject.- Parameters:
locale
- The locale
-
loadStrings
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
- Throws:
IOException
-
readObject
- Throws:
IOException
ClassNotFoundException
-
loadMetaZoneNames
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
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
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.
-