public interface Directory
DirectoryLayer
. A Directory
stores the path
at which it is located and the layer that was used to create it.
The Directory
interface contains methods to operate on itself and its
subdirectories.Modifier and Type | Method and Description |
---|---|
default java.util.concurrent.CompletableFuture<DirectorySubspace> |
create(TransactionContext tcx,
java.util.List<java.lang.String> subpath)
Creates a subdirectory of this
Directory located at subpath
(creating parent directories if necessary). |
default java.util.concurrent.CompletableFuture<DirectorySubspace> |
create(TransactionContext tcx,
java.util.List<java.lang.String> subpath,
byte[] layer)
Creates a subdirectory of this
Directory located at subpath
(creating parent directories if necessary). |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
create(TransactionContext tcx,
java.util.List<java.lang.String> subpath,
byte[] layer,
byte[] prefix)
Creates a subdirectory of this
Directory located at subpath
(creating parent directories if necessary). |
default java.util.concurrent.CompletableFuture<DirectorySubspace> |
createOrOpen(TransactionContext tcx,
java.util.List<java.lang.String> subpath)
Creates or opens the subdirectory of this
Directory located at subpath
(creating parent directories, if necessary). |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
createOrOpen(TransactionContext tcx,
java.util.List<java.lang.String> subpath,
byte[] layer)
Creates or opens the subdirectory of this
Directory located at subpath
(creating parent directories, if necessary). |
default java.util.concurrent.CompletableFuture<java.lang.Boolean> |
exists(ReadTransactionContext tcx)
Checks if this
Directory exists. |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
exists(ReadTransactionContext tcx,
java.util.List<java.lang.String> subpath)
Checks if the subdirectory of this
Directory located at subpath exists. |
DirectoryLayer |
getDirectoryLayer()
Get the
DirectoryLayer that was used to create this Directory . |
byte[] |
getLayer()
Gets the layer byte string that was stored when this
Directory
was created. |
java.util.List<java.lang.String> |
getPath()
Gets the path represented by this
Directory . |
default java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> |
list(ReadTransactionContext tcx)
List the subdirectories of this directory.
|
java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> |
list(ReadTransactionContext tcx,
java.util.List<java.lang.String> subpath)
List the subdirectories of this directory at a given
subpath . |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
move(TransactionContext tcx,
java.util.List<java.lang.String> oldSubpath,
java.util.List<java.lang.String> newSubpath)
Moves the subdirectory of this
Directory located at oldSubpath to newSubpath . |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
moveTo(TransactionContext tcx,
java.util.List<java.lang.String> newAbsolutePath)
Moves this
Directory to the specified newAbsolutePath . |
default java.util.concurrent.CompletableFuture<DirectorySubspace> |
open(ReadTransactionContext tcx,
java.util.List<java.lang.String> subpath)
Opens the subdirectory of this
Directory located at subpath . |
java.util.concurrent.CompletableFuture<DirectorySubspace> |
open(ReadTransactionContext tcx,
java.util.List<java.lang.String> subpath,
byte[] layer)
Opens the subdirectory of this
Directory located at subpath . |
default java.util.concurrent.CompletableFuture<java.lang.Void> |
remove(TransactionContext tcx)
Removes this
Directory and all of its subdirectories, as well as all of their contents. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
remove(TransactionContext tcx,
java.util.List<java.lang.String> subpath)
Removes the subdirectory of this
Directory located at subpath and all of its subdirectories,
as well as all of their contents. |
default java.util.concurrent.CompletableFuture<java.lang.Boolean> |
removeIfExists(TransactionContext tcx)
Removes this
Directory and all of its subdirectories, as well as all of their contents. |
java.util.concurrent.CompletableFuture<java.lang.Boolean> |
removeIfExists(TransactionContext tcx,
java.util.List<java.lang.String> subpath)
Removes the subdirectory of this
Directory located at subpath and all of its subdirectories,
as well as all of their contents. |
java.util.List<java.lang.String> getPath()
Directory
.Directory
's pathbyte[] getLayer()
Directory
was created.Directory
's layer byte stringDirectoryLayer getDirectoryLayer()
DirectoryLayer
that was used to create this Directory
.DirectoryLayer
that created this Directory
default java.util.concurrent.CompletableFuture<DirectorySubspace> createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Directory
located at subpath
(creating parent directories, if necessary).tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set to the created or opened DirectorySubspace
java.util.concurrent.CompletableFuture<DirectorySubspace> createOrOpen(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Directory
located at subpath
(creating parent directories, if necessary). If the directory is new, then the layer
byte string will be recorded as its layer. If the directory already exists, the layer
byte string will be compared against the layer
set when the directory was created.
The returned CompletableFuture
can be set to the following errors:
MismatchedLayerException
- if the directory has already been created with a different layer
byte stringtcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
layer
- a byte[]
specifying a layer to set on a new directory or check for on an existing directoryCompletableFuture
which will be set to the created or opened DirectorySubspace
default java.util.concurrent.CompletableFuture<DirectorySubspace> open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Directory
located at subpath
.
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if the directory does not existtcx
- the ReadTransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set to the opened DirectorySubspace
java.util.concurrent.CompletableFuture<DirectorySubspace> open(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Directory
located at subpath
.
The layer
byte string will be compared against the layer
set when
the directory was created.
The returned CompletableFuture
can be set to the following errors:
MismatchedLayerException
- if the directory was created with a different layer
byte stringNoSuchDirectoryException
- if the directory does not existtcx
- the ReadTransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
layer
- a byte[]
specifying the expected layerCompletableFuture
which will be set to the opened DirectorySubspace
default java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Directory
located at subpath
(creating parent directories if necessary).
The returned CompletableFuture
can be set to the following errors:
DirectoryAlreadyExistsException
- if the given directory already existstcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set to the created DirectorySubspace
default java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer)
Directory
located at subpath
(creating parent directories if necessary). The layer
byte string will be recorded as
the new directory's layer and checked by future calls to open(ReadTransactionContext, List, byte[])
.
The returned CompletableFuture
can be set to the following errors:
DirectoryAlreadyExistsException
- if the given directory already existstcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
layer
- a byte[]
specifying a layer to set for the directoryCompletableFuture
which will be set to the created DirectorySubspace
java.util.concurrent.CompletableFuture<DirectorySubspace> create(TransactionContext tcx, java.util.List<java.lang.String> subpath, byte[] layer, byte[] prefix)
Directory
located at subpath
(creating parent directories if necessary). The layer
byte string will be recorded as
the new directory's layer and checked by future calls to open(ReadTransactionContext, List, byte[])
.
The specified prefix
will be used for this directory's contents instead of allocating a
prefix automatically.
The returned CompletableFuture
can be set to the following errors:
DirectoryAlreadyExistsException
- if the given directory already existstcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
layer
- a byte[]
specifying a layer to set for the directoryprefix
- a byte[]
specifying the key prefix to use for the directory's contentsCompletableFuture
which will be set to the created DirectorySubspace
java.util.concurrent.CompletableFuture<DirectorySubspace> moveTo(TransactionContext tcx, java.util.List<java.lang.String> newAbsolutePath)
Directory
to the specified newAbsolutePath
.
There is no effect on the physical prefix of the given directory, or on clients that already have the directory open.
It is invalid to move a directory to:
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if this Directory
doesn't existDirectoryAlreadyExistsException
- if a directory already exists at newAbsolutePath
DirectoryMoveException
- if an invalid move location is specifiedtcx
- the TransactionContext
to execute this operation innewAbsolutePath
- a List<String>
specifying the new absolute path for this Directory
CompletableFuture
which will be set to the DirectorySubspace
for this Directory
at its new location.java.util.concurrent.CompletableFuture<DirectorySubspace> move(TransactionContext tcx, java.util.List<java.lang.String> oldSubpath, java.util.List<java.lang.String> newSubpath)
Directory
located at oldSubpath
to newSubpath
.
There is no effect on the physical prefix of the given directory, or on clients that already have the directory open.
It is invalid to move a directory to:
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if no Directory
exists at oldSubpath
DirectoryAlreadyExistsException
- if a directory already exists at newSubpath
DirectoryMoveException
- if an invalid move location is specifiedtcx
- the TransactionContext
to execute this operation inoldSubpath
- a List<String>
specifying the subpath of the directory to movenewSubpath
- a List<String>
specifying the subpath to move toCompletableFuture
which will be set to the DirectorySubspace
for this Directory
at its new location.default java.util.concurrent.CompletableFuture<java.lang.Void> remove(TransactionContext tcx)
Directory
and all of its subdirectories, as well as all of their contents.
This should not be called on the root directory, or it will result in the returned future being
set to a DirectoryException
.
Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if this Directory
doesn't existDirectoryException
- if this is called on the root directorytcx
- the TransactionContext
to execute this operation inCompletableFuture
which will be set once this Directory
has been removedjava.util.concurrent.CompletableFuture<java.lang.Void> remove(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Directory
located at subpath
and all of its subdirectories,
as well as all of their contents.
Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if no directory exists at subpath
tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set once the Directory
has been removeddefault java.util.concurrent.CompletableFuture<java.lang.Boolean> removeIfExists(TransactionContext tcx)
Directory
and all of its subdirectories, as well as all of their contents.
Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
tcx
- the TransactionContext
to execute this operation inCompletableFuture
which will be set to true once this Directory
has been removed,
or false if it didn't exist.java.util.concurrent.CompletableFuture<java.lang.Boolean> removeIfExists(TransactionContext tcx, java.util.List<java.lang.String> subpath)
Directory
located at subpath
and all of its subdirectories,
as well as all of their contents.
Warning: Clients that have already opened the directory might still insert data into its contents after it is removed.
tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set to true once the Directory
has been removed,
or false if it didn't exist.default java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> list(ReadTransactionContext tcx)
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if this Directory
doesn't existstcx
- the ReadTransactionContext
to execute this operation inCompletableFuture
which will be set to a List<String>
of names of the subdirectories
of this Directory
. Each name is a unicode string representing the last component of a
subdirectory's path.java.util.concurrent.CompletableFuture<java.util.List<java.lang.String>> list(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
subpath
.
The returned CompletableFuture
can be set to the following errors:
NoSuchDirectoryException
- if no directory exists at subpath
tcx
- the ReadTransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set to a List<String>
of names of the subdirectories
of the directory at subpath
. Each name is a unicode string representing the last component
of a subdirectory's path.default java.util.concurrent.CompletableFuture<java.lang.Boolean> exists(ReadTransactionContext tcx)
Directory
exists.tcx
- the ReadTransactionContext
to execute this operation inCompletableFuture
which will be set to true
if this Directory
exists, or false
if it
doesn'tjava.util.concurrent.CompletableFuture<java.lang.Boolean> exists(ReadTransactionContext tcx, java.util.List<java.lang.String> subpath)
Directory
located at subpath
exists.tcx
- the TransactionContext
to execute this operation insubpath
- a List<String>
specifying a subpath of this Directory
CompletableFuture
which will be set to true
if the specified subdirectory exists, or false
if it
doesn't