Package com.ibm.icu.impl
Class TimeZoneNamesImpl
- java.lang.Object
-
- com.ibm.icu.text.TimeZoneNames
-
- com.ibm.icu.impl.TimeZoneNamesImpl
-
- All Implemented Interfaces:
java.io.Serializable
public class TimeZoneNamesImpl extends TimeZoneNames
The standard ICU implementation of TimeZoneNames- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TimeZoneNamesImpl.MZ2TZsCache
private static class
TimeZoneNamesImpl.MZMapEntry
private static class
TimeZoneNamesImpl.NameInfo
An instance of NameInfo is stored in the zone names trie.private static class
TimeZoneNamesImpl.NameSearchHandler
NameSearchHandler is used for collecting name matches.private static class
TimeZoneNamesImpl.TZ2MZsCache
private static class
TimeZoneNamesImpl.ZNames
This class stores name data for a meta zone or time zone.private static class
TimeZoneNamesImpl.ZNamesLoader
private class
TimeZoneNamesImpl.ZoneStringsLoader
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
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentHashMap<java.lang.String,TimeZoneNamesImpl.ZNames>
_mzNamesMap
private boolean
_namesFullyLoaded
private TextTrieMap<TimeZoneNamesImpl.NameInfo>
_namesTrie
private boolean
_namesTrieFullyLoaded
private java.util.concurrent.ConcurrentHashMap<java.lang.String,TimeZoneNamesImpl.ZNames>
_tzNamesMap
private ICUResourceBundle
_zoneStrings
private static java.util.regex.Pattern
LOC_EXCLUSION_PATTERN
private static java.util.Set<java.lang.String>
METAZONE_IDS
private static java.lang.String
MZ_PREFIX
private static TimeZoneNamesImpl.MZ2TZsCache
MZ_TO_TZS_CACHE
private static long
serialVersionUID
private static TimeZoneNamesImpl.TZ2MZsCache
TZ_TO_MZS_CACHE
private static java.lang.String
ZONE_STRINGS_BUNDLE
-
Constructor Summary
Constructors Constructor Description TimeZoneNamesImpl(ULocale locale)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.util.Set<java.lang.String>
_getAvailableMetaZoneIDs()
(package private) static java.util.Set<java.lang.String>
_getAvailableMetaZoneIDs(java.lang.String tzID)
(package private) static java.lang.String
_getMetaZoneID(java.lang.String tzID, long date)
(package private) static java.lang.String
_getReferenceZoneID(java.lang.String mzID, java.lang.String region)
private void
addAllNamesIntoTrie()
Caller must synchronize.private java.util.Collection<TimeZoneNames.MatchInfo>
doFind(TimeZoneNamesImpl.NameSearchHandler handler, java.lang.CharSequence text, int start)
java.util.Collection<TimeZoneNames.MatchInfo>
find(java.lang.CharSequence text, int start, java.util.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.java.util.Set<java.lang.String>
getAvailableMetaZoneIDs()
Returns an immutable set of all available meta zone IDs.java.util.Set<java.lang.String>
getAvailableMetaZoneIDs(java.lang.String tzID)
Returns an immutable set of all available meta zone IDs used by the given time zone.static java.lang.String
getDefaultExemplarLocationName(java.lang.String tzID)
Default exemplar location name based on time zone ID.void
getDisplayNames(java.lang.String tzID, TimeZoneNames.NameType[] types, long date, java.lang.String[] dest, int destOffset)
java.lang.String
getExemplarLocationName(java.lang.String tzID)
Returns the exemplar location name for the given time zone.java.lang.String
getMetaZoneDisplayName(java.lang.String mzID, TimeZoneNames.NameType type)
Returns the display name of the meta zone.java.lang.String
getMetaZoneID(java.lang.String tzID, long date)
Returns the meta zone ID for the given canonical time zone ID at the given date.java.lang.String
getReferenceZoneID(java.lang.String mzID, java.lang.String region)
Returns the reference zone ID for the given meta zone ID for the region.java.lang.String
getTimeZoneDisplayName(java.lang.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
internalLoadAllDisplayNames()
Caller must synchronize.void
loadAllDisplayNames()
private TimeZoneNamesImpl.ZNames
loadMetaZoneNames(java.lang.String mzID)
Returns a set of names for the given meta zone ID.private void
loadStrings(java.lang.String tzCanonicalID)
Load all strings used by the specified time zone.private TimeZoneNamesImpl.ZNames
loadTimeZoneNames(java.lang.String tzID)
Returns a set of names for the given time zone ID.private void
readObject(java.io.ObjectInputStream in)
private void
writeObject(java.io.ObjectOutputStream out)
-
Methods inherited from class com.ibm.icu.text.TimeZoneNames
getDisplayName, getInstance, getInstance, getTZDBInstance
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
ZONE_STRINGS_BUNDLE
private static final java.lang.String ZONE_STRINGS_BUNDLE
- See Also:
- Constant Field Values
-
MZ_PREFIX
private static final java.lang.String MZ_PREFIX
- See Also:
- Constant Field Values
-
METAZONE_IDS
private static volatile java.util.Set<java.lang.String> METAZONE_IDS
-
TZ_TO_MZS_CACHE
private static final TimeZoneNamesImpl.TZ2MZsCache TZ_TO_MZS_CACHE
-
MZ_TO_TZS_CACHE
private static final TimeZoneNamesImpl.MZ2TZsCache MZ_TO_TZS_CACHE
-
_zoneStrings
private transient ICUResourceBundle _zoneStrings
-
_mzNamesMap
private transient java.util.concurrent.ConcurrentHashMap<java.lang.String,TimeZoneNamesImpl.ZNames> _mzNamesMap
-
_tzNamesMap
private transient java.util.concurrent.ConcurrentHashMap<java.lang.String,TimeZoneNamesImpl.ZNames> _tzNamesMap
-
_namesFullyLoaded
private transient boolean _namesFullyLoaded
-
_namesTrie
private transient TextTrieMap<TimeZoneNamesImpl.NameInfo> _namesTrie
-
_namesTrieFullyLoaded
private transient boolean _namesTrieFullyLoaded
-
LOC_EXCLUSION_PATTERN
private static final java.util.regex.Pattern LOC_EXCLUSION_PATTERN
-
-
Constructor Detail
-
TimeZoneNamesImpl
public TimeZoneNamesImpl(ULocale locale)
-
-
Method Detail
-
getAvailableMetaZoneIDs
public java.util.Set<java.lang.String> 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
static java.util.Set<java.lang.String> _getAvailableMetaZoneIDs()
-
getAvailableMetaZoneIDs
public java.util.Set<java.lang.String> getAvailableMetaZoneIDs(java.lang.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 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
static java.util.Set<java.lang.String> _getAvailableMetaZoneIDs(java.lang.String tzID)
-
getMetaZoneID
public java.lang.String getMetaZoneID(java.lang.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 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
static java.lang.String _getMetaZoneID(java.lang.String tzID, long date)
-
getReferenceZoneID
public java.lang.String getReferenceZoneID(java.lang.String mzID, java.lang.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 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
static java.lang.String _getReferenceZoneID(java.lang.String mzID, java.lang.String region)
-
getMetaZoneDisplayName
public java.lang.String getMetaZoneDisplayName(java.lang.String mzID, TimeZoneNames.NameType type)
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
public java.lang.String getTimeZoneDisplayName(java.lang.String tzID, TimeZoneNames.NameType type)
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
public java.lang.String getExemplarLocationName(java.lang.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.- 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 java.util.Collection<TimeZoneNames.MatchInfo> find(java.lang.CharSequence text, int start, java.util.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:
TimeZoneNames.NameType
,TimeZoneNames.MatchInfo
-
doFind
private java.util.Collection<TimeZoneNames.MatchInfo> doFind(TimeZoneNamesImpl.NameSearchHandler handler, java.lang.CharSequence text, int start)
-
loadAllDisplayNames
public void loadAllDisplayNames()
- Overrides:
loadAllDisplayNames
in classTimeZoneNames
-
getDisplayNames
public void getDisplayNames(java.lang.String tzID, TimeZoneNames.NameType[] types, long date, java.lang.String[] dest, int destOffset)
- Overrides:
getDisplayNames
in classTimeZoneNames
-
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(java.lang.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(java.io.ObjectOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
loadMetaZoneNames
private TimeZoneNamesImpl.ZNames loadMetaZoneNames(java.lang.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(java.lang.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 java.lang.String getDefaultExemplarLocationName(java.lang.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.
-
-