@Immutable public final class TArchiveDetector extends FsAbstractCompositeDriver
The map of detectable archive file name extensions and corresponding archive drivers is configured by the constructors of this class. There are two types of constructors available:
FsDriverMapLocator.SINGLETON
could be filtered by the file name
extension list "tar|zip"
in order to recognize only TAR and ZIP
files.
"foo|bar"
could be used
to detect a custom variant of the JAR file format (you need to provide
a custom archive driver then, too).
Where a constructor expects a list of file name extensions as a parameter,
it must obeye the syntax constraints for ExtensionSet
s.
As an example, the parameter "zip|jar"
would cause
the archive detector to recognize ZIP and JAR files in a path.
The same would be true for "||.ZiP||.JaR||ZIP||JAR||"
,
but this notation is discouraged because it's not in canonical form.
Modifier and Type | Field and Description |
---|---|
static TArchiveDetector |
ALL
This instance recognizes all archive file name extensions for which an
archive driver can get located on the class path by the file system
driver map locator singleton
FsDriverMapLocator.SINGLETON . |
static TArchiveDetector |
NULL
This instance never recognizes any archive files in a path.
|
Constructor and Description |
---|
TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider,
Map<FsScheme,FsDriver> config)
Constructs a new
TArchiveDetector by decorating the given driver
provider with mappings for all entries in config . |
TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider,
Object[][] config)
Creates a new
TArchiveDetector by
decorating the configuration of provider with
mappings for all entries in config . |
TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider,
String extensions)
Constructs a new
TArchiveDetector by filtering the given driver
provider for all canonicalized extensions in the extensions list. |
TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider,
String extensions,
FsDriver driver)
Constructs a new
TArchiveDetector by
decorating the configuration of provider with
mappings for all canonicalized extensions in extensions to
driver . |
TArchiveDetector(String extensions)
Equivalent to
TArchiveDetector(FsDriverMapLocator.SINGLETON, extensions) . |
TArchiveDetector(String extensions,
FsDriver driver)
Equivalent to
TArchiveDetector(TArchiveDetector.NULL, extensions, driver) . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
Map<FsScheme,FsDriver> |
get() |
Map<FsScheme,FsDriver> |
getDrivers()
Returns the immutable map of file system drivers.
|
String |
getExtensions()
Returns the canonical extension list for all archive file system
schemes recognized by this
TArchiveDetector . |
int |
hashCode() |
FsScheme |
scheme(String path)
Detects whether the given
path name identifies a prospective
archive file by matching its file name extension against the set of
file system schemes in the file system driver map. |
String |
toString() |
newController, newModel
public static final TArchiveDetector ALL
FsDriverMapLocator.SINGLETON
.public static final TArchiveDetector NULL
TArchiveDetector
instances or if archive files
shall be treated like regular files rather than (virtual) directories.public TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider, Map<FsScheme,FsDriver> config)
TArchiveDetector
by decorating the given driver
provider with mappings for all entries in config
.provider
- the file system driver provider to decorate.config
- a map of file system schemes to file system drivers.
null
may be used to shadow a mapping for an equal
file system scheme in provider
by removing it from the
resulting map for this detector.NullPointerException
- if a required configuration element is
null
.ClassCastException
- if a configuration element is of the wrong
type.IllegalArgumentException
- if any other parameter precondition
does not hold.Syntax contraints for extension lists.
public TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider, Object[][] config)
TArchiveDetector
by
decorating the configuration of provider
with
mappings for all entries in config
.provider
- the file system driver provider to decorate.config
- an array of key-value pair arrays.
The first element of each inner array must either be a
file system scheme
, an object o
which
can get converted to a set of file name extensions by calling
new ExtensionSet(o.toString())
or a collection
of these.
The second element of each inner array must either be a
file system driver object
, a
file system driver class
, a
fully qualified name of a file system driver class
,
or null
.
null
may be used to shadow a mapping for an equal
file system scheme in provider
by removing it from the
resulting map for this detector.NullPointerException
- if a required configuration element is
null
.IllegalArgumentException
- if any other parameter precondition
does not hold.Syntax contraints for extension lists.
public TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider, @CheckForNull String extensions)
TArchiveDetector
by filtering the given driver
provider for all canonicalized extensions in the extensions
list.provider
- the file system driver provider to filter.extensions
- A list of file name extensions which shall identify
prospective archive files.
If this is null
, no filtering is applied and all drivers
known by the given provider are available for use with this
archive detector.IllegalArgumentException
- If any of the extensions in the list
names a extension for which no file system driver is known by the
provider.Syntax constraints for extension lists.
public TArchiveDetector(javax.inject.Provider<Map<FsScheme,FsDriver>> provider, String extensions, @CheckForNull FsDriver driver)
TArchiveDetector
by
decorating the configuration of provider
with
mappings for all canonicalized extensions in extensions
to
driver
.provider
- the file system driver provider to decorate.extensions
- A list of file name extensions which shall identify
prospective archive files.
This must not be null
and must not be empty.driver
- the file system driver to map for the extension list.
null
may be used to shadow a mapping for an equal
file system scheme in provider
by removing it from the
resulting map for this detector.NullPointerException
- if a required configuration element is
null
.IllegalArgumentException
- if any other parameter precondition
does not hold.Syntax contraints for extension lists.
public TArchiveDetector(@CheckForNull String extensions)
TArchiveDetector(FsDriverMapLocator.SINGLETON, extensions)
.public TArchiveDetector(String extensions, @CheckForNull FsDriver driver)
TArchiveDetector(TArchiveDetector.NULL, extensions, driver)
.public Map<FsScheme,FsDriver> getDrivers()
get()
.public String getExtensions()
TArchiveDetector
.""
to indicate an empty set or
a string of the form "extension[|extension]*"
,
where extension
is a combination of lower case
letters which does not start with a dot.
The string never contains empty or duplicated extensions and the
extensions are sorted in natural order.TArchiveDetector(String)
,
Syntax constraints for extension lists.
@CheckForNull public FsScheme scheme(String path)
path
name identifies a prospective
archive file by matching its file name extension against the set of
file system schemes in the file system driver map.
If a match is found, the file name extension gets converted to a file
system scheme and returned.
Otherwise, null
is returned.path
- the path name.null
if no archive file name
extension has been detected.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.