|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap
de.schlichtherle.io.ArchiveDriverRegistry
class ArchiveDriverRegistry
The head of a chain of registries for archive file suffixes and archive
drivers.
Each element in the chain is an instance of this class which
maps single archive file suffixes (not lists) [String] to the
fully qualified class name, class object or instance of an archive driver
[String, Class or ArchiveDriver].
The getArchiveDriver(java.lang.String) method can then be used to recursively
lookup an archive driver for a given (file name) suffix in the registry
chain.
This class is serializable in order to meet the requirements of the
File class.
However, it's not really recommended to serialize this class:
Together with the instance, all associated archive drivers are serialized
too, which is pretty inefficient for a single instance.
| Nested Class Summary | |
|---|---|
(package private) static class |
ArchiveDriverRegistry.IllegalArchiveDriverException
|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Field Summary | |
|---|---|
private static String |
CLASS_NAME
|
private ArchiveDriverRegistry |
delegate
The delegate used to lookup archive drivers when no driver is configured locally. |
(package private) static String |
KWD_DEFAULT
|
(package private) static String |
KWD_DRIVER
|
private static Logger |
logger
|
private static ResourceBundle |
resources
|
private static long |
serialVersionUID
|
| Constructor Summary | |
|---|---|
ArchiveDriverRegistry()
Creates an empty ArchiveDriverRegistry. |
|
ArchiveDriverRegistry(ArchiveDriverRegistry delegate,
Map config)
Creates a new DefaultArchiveDriverRegistry by
decorating the configuration of delegate with
mappings for all entries in config. |
|
| Method Summary | |
|---|---|
private static ArchiveDriver |
createArchiveDriver(Object driver)
Creates an archive driver from the given blueprint. |
SuffixSet |
decorate(SuffixSet set)
Decorates the given suffix set by adding all suffixes which map to a valid archive driver and removing all suffixes which map to null in the local registry. |
ArchiveDriver |
getArchiveDriver(String suffix)
Returns the archive driver for the given canonical suffix
or null if no archive driver is found in the registry. |
private static String |
getString(String key)
|
private static String |
getString(String key,
String arg)
|
private void |
registerArchiveDriver(String list,
Object driver,
boolean eager)
Registers the given archive id for the given
list of suffixes. |
(package private) void |
registerArchiveDrivers(Map config,
boolean eager)
Processes the given config and adds the configured archive
driver mappings. |
SuffixSet |
suffixes()
Returns the set of all suffixes which map to a valid archive driver in the registry. |
| Methods inherited from class java.util.HashMap |
|---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Field Detail |
|---|
private static final long serialVersionUID
private static final String CLASS_NAME
private static final ResourceBundle resources
private static final Logger logger
static final String KWD_DRIVER
static final String KWD_DEFAULT
private final ArchiveDriverRegistry delegate
null.
| Constructor Detail |
|---|
ArchiveDriverRegistry()
ArchiveDriverRegistry.
ArchiveDriverRegistry(ArchiveDriverRegistry delegate,
Map config)
DefaultArchiveDriverRegistry by
decorating the configuration of delegate with
mappings for all entries in config.
delegate - The ArchiveDriverRegistry which's
configuration is to be virtually inherited.config - A map of suffix lists and archive drivers.
Each key in this map must be a non-null, non-empty archive file
suffix list, obeying the usual syntax.
Each value must either be an archive driver instance, an archive
driver class, a string with the fully qualified name name of
an archive driver class, or null.
A null archive driver may be used to shadow a
mapping for the same archive driver in delegate,
effectively removing it.
NullPointerException - If any parameter or configuration element
other than an archive driver is null.
IllegalArgumentException - If any other parameter precondition
does not hold or an illegal keyword is found in the
configuration.Syntax Definition for Suffix Lists| Method Detail |
|---|
final void registerArchiveDrivers(Map config,
boolean eager)
config and adds the configured archive
driver mappings.
config - A map of suffix lists and archive driver IDs.
Each key in this map must be a non-null, non-empty suffix list,
obeying the usual syntax.
Each value must either be an archive driver instance, an archive
driver class, or a string with the fully qualified name name of
an archive driver class.eager - Iff true, archive drivers are immediately
instantiated and the keyword DEFAULT is not allowed.
NullPointerException - If any parameter or config element
is null.
IllegalArgumentException - If any other parameter precondition
does not hold or the keyword DRIVER is found.
private void registerArchiveDriver(String list,
Object driver,
boolean eager)
id for the given
list of suffixes.
eager - Whether the archive driver shall be instantiated or not.
NullPointerException - If id is null.
ClassCastException - If eager is false
and driver isn't a string.
ArchiveDriverRegistry.IllegalArchiveDriverException - If eager is
true and driver can't get instantiated
for some reason.
The cause is wrapped in the exception.public final ArchiveDriver getArchiveDriver(String suffix)
suffix
or null if no archive driver is found in the registry.
This instance is the head element of the registry chain. If this head element does not hold an archive driver for the given suffix, then the next element in the registry chain is searched. This repeats recursively until either an archive driver is found or the end of the chain is reached.
An archive driver is looked up in the registry as follows:
ArchiveDriver
implementation. The class will be loaded and stored in the registry.
ArchiveDriver type and stored in the registry.
ArchiveDriver implementation, it's returned.
null is returned.
RuntimeException - A subclass is thrown if loading or
instantiating an archive driver class fails.private static final ArchiveDriver createArchiveDriver(Object driver)
driver - A string with the fully qualified class name of an archive
driver implementation, a class instance for an archive driver
implementation, an archive driver instance or null.
null iff
driver is null.
ArchiveDriverRegistry.IllegalArchiveDriverException - If an archive driver cannot get
returned.
The cause is wrapped in the exception.public final SuffixSet suffixes()
public final SuffixSet decorate(SuffixSet set)
null in the local registry.
set - A non-null set of canonical archive file suffixes.
set, decorated according to the mappings in the
local registry.private static final String getString(String key)
private static final String getString(String key,
String arg)
|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||