@Immutable public final class TArchiveDetector extends FsAbstractCompositeDriver
The map of detectable archive file name suffixes and corresponding archive drivers is configured by the constructors of this class. There are two types of constructors available:
FsDriverLocator.SINGLETON
could be filtered by the file name
suffix 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 suffixes as a parameter,
it must obeye the syntax constraints for SuffixSet
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 types for which an archive driver
can be found by the file system driver service locator singleton
FsDriverLocator.SINGLETON . |
static TArchiveDetector |
NULL
This instance never recognizes any archive files in a path.
|
Constructor and Description |
---|
TArchiveDetector(FsDriverProvider provider,
Map<FsScheme,FsDriver> config)
Constructs a new
TArchiveDetector by decorating the given driver
provider with mappings for all entries in config . |
TArchiveDetector(FsDriverProvider delegate,
Object[][] config)
Creates a new
TArchiveDetector by
decorating the configuration of delegate with
mappings for all entries in config . |
TArchiveDetector(FsDriverProvider provider,
String suffixes)
Constructs a new
TArchiveDetector by filtering the given driver
provider for all canonicalized suffixes in the suffixes list. |
TArchiveDetector(FsDriverProvider delegate,
String suffixes,
FsDriver driver)
Constructs a new
TArchiveDetector by
decorating the configuration of delegate with
mappings for all canonicalized suffixes in suffixes to
driver . |
TArchiveDetector(String suffixes)
Equivalent to
TArchiveDetector(FsDriverLocator.SINGLETON, suffixes) . |
TArchiveDetector(String suffixes,
FsDriver driver)
Equivalent to
TArchiveDetector(TArchiveDetector.NULL, suffixes, driver) . |
Modifier and Type | Method and Description |
---|---|
Map<FsScheme,FsDriver> |
get()
Returns a dedicated immutable map of file system schemes to drivers.
|
FsScheme |
getScheme(String path)
Detects whether the given
path name identifies a prospective
archive file by matching its file name suffixes against the set of file
system schemes in the archive driver map. |
String |
toString()
Returns the canonical suffix list for all federated file system
types recognized by this
TArchiveDetector . |
newController
public static final TArchiveDetector ALL
FsDriverLocator.SINGLETON
.public static final TArchiveDetector NULL
TArchiveDetector
instances or if archive files
shall be treated like regular files rather than (virtual) directories.public TArchiveDetector(FsDriverProvider 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 suffix lists.
public TArchiveDetector(FsDriverProvider delegate, Object[][] config)
TArchiveDetector
by
decorating the configuration of delegate
with
mappings for all entries in config
.delegate
- 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 suffixes by calling
new SuffixSet(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 delegate
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 suffix lists.
public TArchiveDetector(FsDriverProvider provider, @CheckForNull String suffixes)
TArchiveDetector
by filtering the given driver
provider for all canonicalized suffixes in the suffixes
list.provider
- the file system driver provider to filter.suffixes
- A list of file name suffixes 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 suffixes in the list
names a suffix for which no file system driver is known by the
provider.Syntax constraints for suffix lists.
public TArchiveDetector(FsDriverProvider delegate, String suffixes, @CheckForNull FsDriver driver)
TArchiveDetector
by
decorating the configuration of delegate
with
mappings for all canonicalized suffixes in suffixes
to
driver
.delegate
- the file system driver provider to decorate.suffixes
- A list of file name suffixes 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 suffix list.
null
may be used to shadow a mapping for an equal
file system scheme in delegate
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 suffix lists.
public TArchiveDetector(@CheckForNull String suffixes)
TArchiveDetector(FsDriverLocator.SINGLETON, suffixes)
.public TArchiveDetector(String suffixes, @CheckForNull FsDriver driver)
TArchiveDetector(TArchiveDetector.NULL, suffixes, driver)
.public Map<FsScheme,FsDriver> get()
FsDriverProvider
null
and subsequent calls must return the same map.@CheckForNull public FsScheme getScheme(String path)
path
name identifies a prospective
archive file by matching its file name suffixes against the set of file
system schemes in the archive driver map.
If a match is found, the file name suffix gets converted to a file
system scheme and returned.
Otherwise, null
is returned.path
- the path name.null
if no archive file name
suffix has been detected.public String toString()
TArchiveDetector
.toString
in class Object
""
to indicate an empty set or
a string of the form "suffix[|suffix]*"
,
where suffix
is a combination of lower case
letters which does not start with a dot.
The string never contains empty or duplicated suffixes and the
suffixes are sorted in natural order.TArchiveDetector(String)
,
Syntax constraints for suffix lists.
Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.