Package org.joda.time.tz
Class ZoneInfoProvider
- java.lang.Object
-
- org.joda.time.tz.ZoneInfoProvider
-
- All Implemented Interfaces:
Provider
public class ZoneInfoProvider extends java.lang.Object implements Provider
ZoneInfoProvider loads compiled data files as generated byZoneInfoCompiler.ZoneInfoProvider is thread-safe and publicly immutable.
- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FileiFileDirThe directory where the files are held.private java.lang.ClassLoaderiLoaderThe class loader to use.private java.lang.StringiResourcePathThe resource path.private java.util.Set<java.lang.String>iZoneInfoKeysMaps ids to strings or SoftReferences to DateTimeZones.private java.util.Map<java.lang.String,java.lang.Object>iZoneInfoMapMaps ids to strings or SoftReferences to DateTimeZones.
-
Constructor Summary
Constructors Modifier Constructor Description ZoneInfoProvider(java.io.File fileDir)ZoneInfoProvider searches the given directory for compiled data files.ZoneInfoProvider(java.lang.String resourcePath)ZoneInfoProvider searches the given ClassLoader resource path for compiled data files.ZoneInfoProvider(java.lang.String resourcePath, java.lang.ClassLoader loader)ZoneInfoProvider searches the given ClassLoader resource path for compiled data files.privateZoneInfoProvider(java.lang.String resourcePath, java.lang.ClassLoader loader, boolean favorSystemLoader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<java.lang.String>getAvailableIDs()Gets a list of all the available zone ids.DateTimeZonegetZone(java.lang.String id)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(java.lang.String id)Loads the time zone data for one id.private static java.util.Map<java.lang.String,java.lang.Object>loadZoneInfoMap(java.io.InputStream in)Loads the zone info map.private java.io.InputStreamopenResource(java.lang.String name)Opens a resource from file or classpath.private static voidreadZoneInfoMap(java.io.DataInputStream din, java.util.Map<java.lang.String,java.lang.Object> zimap)Reads the zone info map from file.protected voiduncaughtException(java.lang.Exception ex)Called if an exception is thrown from getZone while loading zone data.
-
-
-
Field Detail
-
iFileDir
private final java.io.File iFileDir
The directory where the files are held.
-
iResourcePath
private final java.lang.String iResourcePath
The resource path.
-
iLoader
private final java.lang.ClassLoader iLoader
The class loader to use.
-
iZoneInfoMap
private final java.util.Map<java.lang.String,java.lang.Object> iZoneInfoMap
Maps ids to strings or SoftReferences to DateTimeZones.
-
iZoneInfoKeys
private final java.util.Set<java.lang.String> iZoneInfoKeys
Maps ids to strings or SoftReferences to DateTimeZones.
-
-
Constructor Detail
-
ZoneInfoProvider
public ZoneInfoProvider(java.io.File fileDir) throws java.io.IOExceptionZoneInfoProvider searches the given directory for compiled data files.- Throws:
java.io.IOException- if directory or map file cannot be read
-
ZoneInfoProvider
public ZoneInfoProvider(java.lang.String resourcePath) throws java.io.IOExceptionZoneInfoProvider searches the given ClassLoader resource path for compiled data files. Resources are loaded from the ClassLoader that loaded this class.- Throws:
java.io.IOException- if directory or map file cannot be read
-
ZoneInfoProvider
public ZoneInfoProvider(java.lang.String resourcePath, java.lang.ClassLoader loader) throws java.io.IOExceptionZoneInfoProvider 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:
java.io.IOException- if directory or map file cannot be read
-
ZoneInfoProvider
private ZoneInfoProvider(java.lang.String resourcePath, java.lang.ClassLoader loader, boolean favorSystemLoader) throws java.io.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:
java.io.IOException
-
-
Method Detail
-
getZone
public DateTimeZone getZone(java.lang.String id)
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
public java.util.Set<java.lang.String> getAvailableIDs()
Gets a list of all the available zone ids.- Specified by:
getAvailableIDsin interfaceProvider- Returns:
- the zone ids
-
uncaughtException
protected void uncaughtException(java.lang.Exception ex)
Called if an exception is thrown from getZone while loading zone data.- Parameters:
ex- the exception
-
openResource
private java.io.InputStream openResource(java.lang.String name) throws java.io.IOExceptionOpens a resource from file or classpath.- Parameters:
name- the name to open- Returns:
- the input stream
- Throws:
java.io.IOException- if an error occurs
-
loadZoneData
private DateTimeZone loadZoneData(java.lang.String id)
Loads the time zone data for one id.- Parameters:
id- the id to load- Returns:
- the zone
-
loadZoneInfoMap
private static java.util.Map<java.lang.String,java.lang.Object> loadZoneInfoMap(java.io.InputStream in) throws java.io.IOExceptionLoads the zone info map.- Parameters:
in- the input stream- Returns:
- the map
- Throws:
java.io.IOException
-
readZoneInfoMap
private static void readZoneInfoMap(java.io.DataInputStream din, java.util.Map<java.lang.String,java.lang.Object> zimap) throws java.io.IOExceptionReads the zone info map from file.- Parameters:
din- the input streamzimap- gets filled with string id to string id mappings- Throws:
java.io.IOException
-
-