Package org.joda.time.tz
Class ZoneInfoProvider
java.lang.Object
org.joda.time.tz.ZoneInfoProvider
- All Implemented Interfaces:
Provider
ZoneInfoProvider loads compiled data files as generated by
ZoneInfoCompiler.
ZoneInfoProvider is thread-safe and publicly immutable.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FileThe directory where the files are held.private final ClassLoaderThe class loader to use.private final StringThe resource path.Maps ids to strings or SoftReferences to DateTimeZones.Maps ids to strings or SoftReferences to DateTimeZones. -
Constructor Summary
ConstructorsModifierConstructorDescriptionSearch the default classloader resource path for compiled data files.ZoneInfoProvider(File fileDir) ZoneInfoProvider searches the given directory for compiled data files.ZoneInfoProvider(String resourcePath) ZoneInfoProvider searches the given ClassLoader resource path for compiled data files.ZoneInfoProvider(String resourcePath, ClassLoader loader) ZoneInfoProvider searches the given ClassLoader resource path for compiled data files.privateZoneInfoProvider(String resourcePath, ClassLoader loader, boolean favorSystemLoader) -
Method Summary
Modifier and TypeMethodDescriptionGets a list of all the available zone ids.If an error is thrown while loading zone data, the exception is logged to system error and null is returned for this and all future requests.private DateTimeZoneloadZoneData(String id) Loads the time zone data for one id.Loads the zone info map.private InputStreamopenResource(String name) Opens a resource from file or classpath.private static voidreadZoneInfoMap(DataInputStream din, Map<String, Object> zimap) Reads the zone info map from file.protected voidCalled if an exception is thrown from getZone while loading zone data.
-
Field Details
-
iFileDir
The directory where the files are held. -
iResourcePath
The resource path. -
iLoader
The class loader to use. -
iZoneInfoMap
Maps ids to strings or SoftReferences to DateTimeZones. -
iZoneInfoKeys
Maps ids to strings or SoftReferences to DateTimeZones.
-
-
Constructor Details
-
ZoneInfoProvider
Search the default classloader resource path for compiled data files.- Throws:
IOException- if directory or map file cannot be read
-
ZoneInfoProvider
ZoneInfoProvider searches the given directory for compiled data files.- Throws:
IOException- if directory or map file cannot be read
-
ZoneInfoProvider
ZoneInfoProvider searches the given ClassLoader resource path for compiled data files. Resources are loaded from the ClassLoader that loaded this class.- Throws:
IOException- if directory or map file cannot be read
-
ZoneInfoProvider
ZoneInfoProvider searches the given ClassLoader resource path for compiled data files.- Parameters:
loader- ClassLoader to load compiled data files from. If null, use system ClassLoader.- Throws:
IOException- if directory or map file cannot be read
-
ZoneInfoProvider
private ZoneInfoProvider(String resourcePath, ClassLoader loader, boolean favorSystemLoader) throws IOException - Parameters:
favorSystemLoader- when true, use the system class loader if loader null. When false, use the current class loader if loader is null.- Throws:
IOException
-
-
Method Details
-
getZone
If an error is thrown while loading zone data, the exception is logged to system error and null is returned for this and all future requests. -
getAvailableIDs
Gets a list of all the available zone ids.- Specified by:
getAvailableIDsin interfaceProvider- Returns:
- the zone ids
-
uncaughtException
Called if an exception is thrown from getZone while loading zone data.- Parameters:
ex- the exception
-
openResource
Opens a resource from file or classpath.- Parameters:
name- the name to open- Returns:
- the input stream
- Throws:
IOException- if an error occurs
-
loadZoneData
Loads the time zone data for one id.- Parameters:
id- the id to load- Returns:
- the zone
-
loadZoneInfoMap
Loads the zone info map.- Parameters:
in- the input stream- Returns:
- the map
- Throws:
IOException
-
readZoneInfoMap
private static void readZoneInfoMap(DataInputStream din, Map<String, Object> zimap) throws IOExceptionReads the zone info map from file.- Parameters:
din- the input streamzimap- gets filled with string id to string id mappings- Throws:
IOException
-