Class | Description |
---|---|
FileAttributesFactory |
File attributes factory
|
Right now, there is a bug with the way classes in this package implement
attribute views; they are supposedly only loaded when you need them (Files.getFileAttributeView(java.nio.file.Path, java.lang.Class,
java.nio.file.LinkOption...)
does not throw an exception), however this
package loads them eagerly. At this moment, if attributes fail to load, an
UncaughtIOException
(unchecked)
is thrown.
This will be fixed in a future release.
This package provides everything you need to implement attributes; not
only the ones defined by the JDK, but also your own. Attribute dispatch
(creation, string handling etc) is already done for you in FileSystemDriverBase
; you only have to
implement attributes and provide a FileAttributesFactory
.
This package wraps all attribute views in provider
classes
. After you implement the attribute providers you need, you will need
to extend FileAttributesFactory
and register your
attribute providers. For instance:
public final class MyFileAttributesProvider extends FileAttributesProvider { public MyFileAttributesProvider() { // You MUST do this first setMetadataClass(MyMetadataClass.class); addImplementation("basic", MyBasicFileAttributesProvider.class); } }
Reminder: the API requires that basic
attributes be implemented by
all filesystem implementations.
You are not limited to the basic types provided by the JDK; you can also
provide your own attributes. For this, you should first have an
implementation for your attributes (either by extending an existing attribute
provider class or by directly extending FileAttributesProvider
),
choose a name for your attribute view and create an AttributesDescriptor
for it.
You will then register it to the factory -- do this before
registering an implementation. The default factory already includes all
descriptors for attributes defined by the JDK.
Example:
public final class MyFileAttributesProvider extends FileAttributesProvider { public MyFileAttributesProvider() { // You MUST do this first setMetadataClass(MyMetadataClass.class); addDescriptor(new MyCoolAttributesDescriptor()); // Provided that the name returned by the descriptor is "cool" addImplementation("cool", MyCoolFileAttributesProvider.class); } }
Note that this is an error to try and register a descriptor with the same name twice.