|
TrueZIP File* 7.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.truezip.file.TArchiveDetector
@Immutable @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public final class TArchiveDetector
Detects a prospective archive file by matching its path name against a pattern of file name suffixes like .zip et al and looks up its corresponding file system driver by using a file system driver provider.
There are basically two types of constructors available in this class:
FsDriverLocator.SINGLETON could be filtered by the suffix
list "tar|zip" in order to recognize only TAR and ZIP files.
"foo|bar" could be used to
recognize a custom variant of the JAR file format (you would need to
provide a custom file system driver then, too).
Where a constructor expects a suffix list as a parameter,
it must obeye the syntax constraints for SuffixSets.
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 obviously not in canonical
form.
| Field Summary | |
|---|---|
static TArchiveDetector |
ALL
This instance recognizes all archive files which are known by the file system driver provider FsDriverLocator.SINGLETON. |
private Map<FsScheme,FsDriver> |
drivers
|
private ThreadLocalMatcher |
matcher
The thread local matcher used to match archive file suffixes. |
static TArchiveDetector |
NULL
This instance never recognizes any archive files in a path. |
private String |
suffixes
The canonical string respresentation of the set of suffixes recognized by this archive detector. |
| Constructor Summary | |
|---|---|
TArchiveDetector(FsDriverProvider delegate,
Map<FsScheme,FsDriver> config)
Constructs a new TArchiveDetector by
decorating the configuration of delegate 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). |
|
| Method Summary | |
|---|---|
Map<FsScheme,FsDriver> |
get()
|
(package private) FsDriver |
getDriver(FsScheme scheme)
Reserved for unit testing only. |
FsScheme |
getScheme(String path)
Detects whether the given path name identifies a prospective
archive file or not by applying heuristics to it and returns a
scheme for accessing archive files of this type or null
if the path does not denote a prospective archive file or an
appropriate scheme is unknown. |
private static SuffixSet |
getSuffixes(FsDriverProvider provider)
|
FsController<?> |
newController(FsModel model,
FsController<?> parent)
|
String |
toString()
Returns the canonical suffix list for all federated file system types recognized by this TArchiveDetector. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final TArchiveDetector NULL
TArchiveDetector instances or if archive files
shall be treated like ordinary files rather than (virtual) directories.
public static final TArchiveDetector ALL
FsDriverLocator.SINGLETON.
The file system schemes are used as the archive file suffixes to
recognize.
private final Map<FsScheme,FsDriver> drivers
private final String suffixes
drivers.
private final ThreadLocalMatcher matcher
| Constructor Detail |
|---|
public TArchiveDetector(@CheckForNull
String suffixes)
TArchiveDetector(FsDriverLocator.SINGLETON, suffixes).
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 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(String suffixes,
@CheckForNull
FsDriver driver)
TArchiveDetector(TArchiveDetector.NULL, suffixes, driver).
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 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(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 system 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 delegate,
Map<FsScheme,FsDriver> config)
TArchiveDetector by
decorating the configuration of delegate with
mappings for all entries in config.
delegate - 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 delegate 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.| Method Detail |
|---|
private static SuffixSet getSuffixes(FsDriverProvider provider)
public Map<FsScheme,FsDriver> get()
get in interface FsDriverProvider@CheckForNull public FsScheme getScheme(String path)
path name identifies a prospective
archive file or not by applying heuristics to it and returns a
scheme for accessing archive files of this type or null
if the path does not denote a prospective archive file or an
appropriate scheme is unknown.
Please note that implementations must not check the actual
contents of the file identified by path!
This is because path may refer to a file which is not yet
existing or even an entry in a federated file system, in which case
there is no way to check the file contents in the parent file systems.
path - the path name of the file in the federated file system.
This does not need to be absolute and it does not need to be
accessible in its containing virtual file system!
scheme for accessing the archive file or null
if the path does not denote an archive file (i.e. the path does
not have a known suffix) or an appropriate scheme is
unknown.@CheckForNull FsDriver getDriver(FsScheme scheme)
public FsController<?> newController(FsModel model,
@CheckForNull
FsController<?> parent)
newController in interface FsCompositeDriverpublic 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.
|
TrueZIP File* 7.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||