public abstract class FsAccessOptionsController extends FsDecoratingController
For example, let's assume you would like to use the JAR file format with all entries encrypted according to the WinZip AES specification as your custom application file format. Then you could subclass this class as follows:
class EncryptionController extends FsAccessOptionsController {
EncryptionController(FsController controller) { super(controller); }
\@Override
protected BitField<FsAccessOption> map(BitField<FsAccessOption> options) {
return options.set(FsAccessOption.ENCRYPT);
}
}
Next, you would have to subclass the JarDriver
in order to inject
an instance of the EncryptionController
as follows:
class EncryptionJarDriver extends JarDriver {
\@Override
public FsController decorate(FsController controller) {
return new EncryptionController(super.decorate(controller));
}
}
Note the call to super.decorate()
- this is required to let the
super class install the built-in key manager.
Now, whenever you use this driver it would encrypt all entries written to your custom application file format according to the WinZip AES specification.
Mind that this is just sample code - for encryption, you should generally prefer the TrueZIP Driver ZIP.RAES for its increased security level!
FsController.Factory<Context>
controller
Modifier | Constructor and Description |
---|---|
protected |
FsAccessOptionsController(FsController controller) |
Modifier and Type | Method and Description |
---|---|
void |
checkAccess(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name,
net.java.truecommons.shed.BitField<net.java.truecommons.cio.Entry.Access> types)
Checks if the file system node for the given
name exists when
constrained by the given access options and permits the given
access types . |
net.java.truecommons.cio.InputSocket<? extends net.java.truecommons.cio.Entry> |
input(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name)
Returns an input socket for reading the contents of the file system
node addressed by the given name from the file system.
|
void |
make(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name,
net.java.truecommons.cio.Entry.Type type,
net.java.truecommons.cio.Entry template)
Creates or replaces and finally links a chain of one or more entries
for the given node
name into the file system. |
protected abstract net.java.truecommons.shed.BitField<FsAccessOption> |
map(net.java.truecommons.shed.BitField<FsAccessOption> options)
Maps the given access options.
|
FsNode |
node(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name)
Returns the file system node for the given
name or null
if it doesn't exist. |
net.java.truecommons.cio.OutputSocket<? extends net.java.truecommons.cio.Entry> |
output(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name,
net.java.truecommons.cio.Entry template)
Returns an output socket for writing the contents of the node addressed
by the given name to the file system.
|
void |
setReadOnly(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name)
Sets the named file system node as read-only.
|
boolean |
setTime(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name,
net.java.truecommons.shed.BitField<net.java.truecommons.cio.Entry.Access> types,
long value)
Makes an attempt to set the last access time of all types in the given
bit field for the file system node with the given name.
|
boolean |
setTime(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name,
Map<net.java.truecommons.cio.Entry.Access,Long> times)
Makes an attempt to set the last access time of all types in the given
map for the file system node with the given name.
|
void |
unlink(net.java.truecommons.shed.BitField<FsAccessOption> options,
FsNodeName name)
Removes the named file system node from the file system.
|
getParent, sync, toString
getModel, getMountPoint, isMounted, setMounted
protected FsAccessOptionsController(FsController controller)
public final void checkAccess(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name, net.java.truecommons.shed.BitField<net.java.truecommons.cio.Entry.Access> types) throws IOException
FsController
name
exists when
constrained by the given access options
and permits the given
access types
.checkAccess
in interface FsController
checkAccess
in class FsDecoratingController
options
- the options for accessing the file system node.name
- the name of the file system node.types
- the types of the desired access.IOException
- on any I/O error.public final net.java.truecommons.cio.InputSocket<? extends net.java.truecommons.cio.Entry> input(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name)
FsController
input
in interface FsController
input
in class FsDecoratingController
options
- the options for accessing the file system node.name
- the name of the file system node.InputSocket
.public final void make(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name, net.java.truecommons.cio.Entry.Type type, net.java.truecommons.cio.Entry template) throws IOException
FsController
name
into the file system.make
in interface FsController
make
in class FsDecoratingController
options
- the options for accessing the file system node.
If FsAccessOption.CREATE_PARENTS
is set, any missing
parent directories shall get created with an undefined last
modification time.name
- the name of the file system node.type
- the file system node type.template
- if not null
, then the file system node
at the end of the chain shall inherit as much properties from
this node as possible - with the exception of its name and type.IOException
- on any I/O error, including but not limited to
these reasons:
name
contains characters which are not
supported by the file system.
FsAccessOption.EXCLUSIVE
is set or the node is a
directory.
createParents
is
false
.
protected abstract net.java.truecommons.shed.BitField<FsAccessOption> map(net.java.truecommons.shed.BitField<FsAccessOption> options)
options
- the access options to map.public final FsNode node(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name) throws IOException
FsController
name
or null
if it doesn't exist.
Modifying the returned node does not show any effect on the file system
and should result in an UnsupportedOperationException
.node
in interface FsController
node
in class FsDecoratingController
options
- the options for accessing the file system node.name
- the name of the file system node.null
if no file system node
exists for the given name.IOException
- on any I/O error.public final net.java.truecommons.cio.OutputSocket<? extends net.java.truecommons.cio.Entry> output(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name, net.java.truecommons.cio.Entry template)
FsController
output
in interface FsController
output
in class FsDecoratingController
options
- the options for accessing the file system node.
If FsAccessOption.CREATE_PARENTS
is set, any missing
parent directories shall get created with an undefined last
modification time.name
- the name of the file system node.template
- if not null
, then the file system node
at the end of the chain shall inherit as much properties from
this node as possible - with the exception of its name and type.OutputSocket
.public final void setReadOnly(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name) throws IOException
FsController
setReadOnly
in interface FsController
setReadOnly
in class FsDecoratingController
options
- the options for accessing the file system node.name
- the name of the file system node.IOException
- on any I/O error or if this operation is not
supported.public final boolean setTime(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name, net.java.truecommons.shed.BitField<net.java.truecommons.cio.Entry.Access> types, long value) throws IOException
FsController
false
is returned or an IOException
is thrown, then
still some of the last access times may have been set.setTime
in interface FsController
setTime
in class FsDecoratingController
options
- the options for accessing the file system node.name
- the name of the file system node.types
- the access types.value
- the last access time.true
if and only if setting the access time for all
types in types
succeeded.IOException
- on any I/O error.public final boolean setTime(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name, Map<net.java.truecommons.cio.Entry.Access,Long> times) throws IOException
FsController
false
is returned or an IOException
is thrown, then
still some of the last access times may have been set.
Whether or not this is an atomic operation is specific to the
implementation.setTime
in interface FsController
setTime
in class FsDecoratingController
options
- the options for accessing the file system node.name
- the name of the file system node.times
- the access times.true
if and only if setting the access time for all
types in times
succeeded.IOException
- on any I/O error.public final void unlink(net.java.truecommons.shed.BitField<FsAccessOption> options, FsNodeName name) throws IOException
FsController
unlink
in interface FsController
unlink
in class FsDecoratingController
options
- the options for accessing the file system node.name
- the name of the file system node.IOException
- on any I/O error.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.