public class TzdbZoneRulesProvider extends ZoneRulesProvider
Constructor and Description |
---|
TzdbZoneRulesProvider()
Creates a provider and initializes it.
|
Modifier and Type | Method and Description |
---|---|
protected ZoneRules |
provideRules(String zoneId,
boolean forCaching)
SPI method to get the rules for the zone ID.
|
protected NavigableMap<String,ZoneRules> |
provideVersions(String zoneId)
SPI method to get the history of rules for the zone ID.
|
protected Set<String> |
provideZoneIds()
SPI method to get the available zone IDs.
|
getAvailableZoneIds, getRules, getVersions, provideRefresh, refresh
public TzdbZoneRulesProvider() throws IOException
The initialization phase attempts to read from the tzdb binary resource that contains the zone rules. If it fails to open or read the resource, it will throw an exception.
IOException
- if the tzdb binary resource could not be open/read, or the tzdb data is not valid@Nullable protected ZoneRules provideRules(String zoneId, boolean forCaching)
ZoneRulesProvider
This loads the rules for the specified zone ID. The provider implementation must validate that the zone ID is
valid and available, throwing a ZoneRulesException
if it is not. The result of the method in the valid
case depends on the caching flag.
If the provider implementation is not dynamic, then the result of the method must be the non-null set of rules selected by the ID.
If the provider implementation is dynamic, then the flag gives the option of preventing the returned rules from
being cached in ZoneId
. When the flag is true, the provider is permitted to return null, where null will
prevent the rules from being cached in ZoneId
. When the flag is false, the provider must return non-null
rules.
provideRules
in class ZoneRulesProvider
zoneId
- the zone ID as defined by ZoneId
, not nullforCaching
- whether the rules are being queried for caching, true if the returned rules will be cached by
ZoneId
, false if they will be returned to the user without being cached in ZoneId
forCaching
is true and this is a dynamic provider that wants to prevent
caching in ZoneId
, otherwise not nullprotected NavigableMap<String,ZoneRules> provideVersions(String zoneId)
ZoneRulesProvider
This returns a map of historical rules keyed by a version string. The exact meaning and format of the version is provider specific. The version must follow lexicographical order, thus the returned map will be ordered from the oldest known rules to the newest available rules.
Implementations must provide a result for each valid zone ID, however they do not have to provide a history of rules. Thus, the map will contain at least one element, and will only contain more than one element if historical rule information is available.
The returned versions remain available and valid for the lifetime of the application. A dynamic provider may increase the set of versions as more data becomes available.
provideVersions
in class ZoneRulesProvider
zoneId
- the zone ID as defined by ZoneId
, not nullprotected Set<String> provideZoneIds()
ZoneRulesProvider
This obtains the IDs that this ZoneRulesProvider
provides. A provider should provide data for at least
one zone ID.
The returned zone IDs remain available and valid for the lifetime of the application. A dynamic provider may increase the set of IDs as more data becomes available.
provideZoneIds
in class ZoneRulesProvider