public class ZoneInfoProvider extends java.lang.Object implements Provider
ZoneInfoCompiler
.
ZoneInfoProvider is thread-safe and publicly immutable.
Modifier and Type | Field and Description |
---|---|
private java.io.File |
iFileDir
The directory where the files are held.
|
private java.lang.ClassLoader |
iLoader
The class loader to use.
|
private java.lang.String |
iResourcePath
The resource path.
|
private java.util.Set<java.lang.String> |
iZoneInfoKeys
Maps ids to strings or SoftReferences to DateTimeZones.
|
private java.util.Map<java.lang.String,java.lang.Object> |
iZoneInfoMap
Maps ids to strings or SoftReferences to DateTimeZones.
|
Modifier | Constructor and 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.
|
private |
ZoneInfoProvider(java.lang.String resourcePath,
java.lang.ClassLoader loader,
boolean favorSystemLoader) |
Modifier and Type | Method and Description |
---|---|
java.util.Set<java.lang.String> |
getAvailableIDs()
Gets a list of all the available zone ids.
|
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.
|
private DateTimeZone |
loadZoneData(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.InputStream |
openResource(java.lang.String name)
Opens a resource from file or classpath.
|
private static void |
readZoneInfoMap(java.io.DataInputStream din,
java.util.Map<java.lang.String,java.lang.Object> zimap)
Reads the zone info map from file.
|
protected void |
uncaughtException(java.lang.Exception ex)
Called if an exception is thrown from getZone while loading zone data.
|
private final java.io.File iFileDir
private final java.lang.String iResourcePath
private final java.lang.ClassLoader iLoader
private final java.util.Map<java.lang.String,java.lang.Object> iZoneInfoMap
private final java.util.Set<java.lang.String> iZoneInfoKeys
public ZoneInfoProvider(java.io.File fileDir) throws java.io.IOException
java.io.IOException
- if directory or map file cannot be readpublic ZoneInfoProvider(java.lang.String resourcePath) throws java.io.IOException
java.io.IOException
- if directory or map file cannot be readpublic ZoneInfoProvider(java.lang.String resourcePath, java.lang.ClassLoader loader) throws java.io.IOException
loader
- ClassLoader to load compiled data files from. If null,
use system ClassLoader.java.io.IOException
- if directory or map file cannot be readprivate ZoneInfoProvider(java.lang.String resourcePath, java.lang.ClassLoader loader, boolean favorSystemLoader) throws java.io.IOException
favorSystemLoader
- when true, use the system class loader if
loader null. When false, use the current class loader if loader is null.java.io.IOException
public DateTimeZone getZone(java.lang.String id)
public java.util.Set<java.lang.String> getAvailableIDs()
getAvailableIDs
in interface Provider
protected void uncaughtException(java.lang.Exception ex)
ex
- the exceptionprivate java.io.InputStream openResource(java.lang.String name) throws java.io.IOException
name
- the name to openjava.io.IOException
- if an error occursprivate DateTimeZone loadZoneData(java.lang.String id)
id
- the id to loadprivate static java.util.Map<java.lang.String,java.lang.Object> loadZoneInfoMap(java.io.InputStream in) throws java.io.IOException
in
- the input streamjava.io.IOException
private static void readZoneInfoMap(java.io.DataInputStream din, java.util.Map<java.lang.String,java.lang.Object> zimap) throws java.io.IOException
din
- the input streamzimap
- gets filled with string id to string id mappingsjava.io.IOException