br.com.objectos.fs
@Generated(value="br.com.objectos.latest.processor.TemplateProcessor") public interface Directory extends PathName
This is only a façade. More specifically, the underlying object may or may not represent an actual directory. For example, the directory may have been deleted between the time an instance of this interface is obtained and the time a method in this interface is invoked.
Unless noted, methods of this interface will reject values that resolve to a pathname that is not the directory itself or a direct child. This restriction is tested against pathnames only. In other words, the pathname might resolve to a child but it might be a symlink to a directory or a file that is not a direct child of this directory.
| Modifier and Type | Method and Description |
|---|---|
<R,P> R |
acceptPathNameVisitor(PathNameVisitor<R,P> visitor,
P p)
Accept method used to implement the visitor pattern.
|
void |
copyTo(Directory dest)
Recursively copies the contents of this directory to the specified
destination directory.
|
Directory |
createDirectory(String directoryName)
Creates a directory with the specified name.
|
RegularFile |
createRegularFile(String fileName,
RegularFileCreateOption... options)
Creates a (regular) file with the specified file name and with the
specified creation options.
|
void |
delete()
Deletes this directory or fails if the directory is not empty.
|
void |
deleteContents()
Recursively deletes the contents of this directory.
|
boolean |
exists()
Returns
true if the pathname represented by this object exists. |
Directory |
getDirectory(String directoryName)
Returns an existing subdirectory having the specified name.
|
String |
getName()
Returns the name of this directory.
|
RegularFile |
getOrCreateRegularFile(String fileName)
Returns an existing (regular) file or creates new one with the specified
file name.
|
Directory |
getParent()
Returns the parent directory of this directory.
|
String |
getPath()
Returns the full path of this directory.
|
RegularFile |
getRegularFile(String fileName)
Returns an existing (regular) file with the specified file name.
|
boolean |
isEmpty()
Returns
true if this directory contains no entries. |
ResolvedPath |
resolve(String first,
String... more)
Returns a new
ResolvedPath object representing the resolved
pathname of a descendant of this directory or returns this object if the
specified names result in the empty string. |
File |
toFile()
Returns a
File representation of this pathname. |
URI |
toUri()
Returns an
URI representation of this pathname. |
void |
visitContents(DirectoryContentsVisitor visitor)
Visits each child of this directory with the specified visitor.
|
compareTovoid copyTo(Directory dest) throws FoundException, IOException
This operation will not overwrite any file in the destination directory nor will it proceed if a subdirectory in the destination with the same as in this directory already exists. This operation will fail at the first directory or file that cannot be created at the destination because it already exists. In this case, the result will be an incomplete (partial) copy operation.
dest - the destination directoryFoundException - if any directory or file with the same relative pathname exists in
the destinationIOException - if an I/O error occursDirectory createDirectory(String directoryName) throws FoundException, IOException
directoryName - the name of the directory to be createdDirectory instance representing the newly created
directoryIllegalArgumentException - if the resolved pathname is not a direct child of this directoryFoundException - if the resolved pathname already existsIOException - if an I/O error occursRegularFile createRegularFile(String fileName, RegularFileCreateOption... options) throws FoundException, IOException
The specified file name is resolved against this directory.
fileName - the name of the file to be createdoptions - file creation optionsIllegalArgumentException - if the resolved pathname is not a direct child of this directoryFoundException - if the resolved pathname already existsIOException - if an I/O error occursvoid delete()
throws IOException
IOException - if an I/O error occursdeleteContents()void deleteContents()
throws IOException
IOException - if an I/O error occursDirectory getDirectory(String directoryName) throws NotFoundException, NotDirectoryException, IOException
directoryName - the name of the directory to be locatedIllegalArgumentException - if the resolved pathname is not a direct child of this directoryNotFoundException - if the resolved pathname does not existNotDirectoryException - if the resolved pathname exists but it is not a directory (it is a
regular file, for example)IOException - if an I/O error occursString getName()
RegularFile getOrCreateRegularFile(String fileName) throws NotRegularFileException, IOException
The specified file name is resolved against this directory.
fileName - the name of the file to be createdIllegalArgumentException - if the resolved pathname is not a direct child of this directoryNotRegularFileException - if the resolved pathname exists but it is not a regular file (it is
a directory, for example)IOException - if an I/O error occursDirectory getParent() throws NotFoundException
NotFoundException - if a parent for this directory cannot be foundString getPath()
RegularFile getRegularFile(String fileName) throws NotFoundException, NotRegularFileException, IOException
fileName - the name of the file to be locatedIllegalArgumentException - if the resolved pathname is not a direct child of this directoryNotFoundException - if the resolved pathname does not existNotRegularFileException - if the resolved pathname exists but it is not a regular file (it is
a directory, for example)IOException - if an I/O error occursboolean isEmpty()
true if this directory contains no entries.true if this directory contains no entriesvoid visitContents(DirectoryContentsVisitor visitor) throws IOException
visitor - the visitor instanceIOException - if an I/O error occurs<R,P> R acceptPathNameVisitor(PathNameVisitor<R,P> visitor, P p) throws IOException
R - the result type of this operationP - the type of the additional objectvisitor - the visitor operating on this PathName instancep - additional object passed to the visitorIOException - if an I/O error occursboolean exists()
true if the pathname represented by this object exists.true if the pathname represented by this object existsFile toFile()
File representation of this pathname.File representation of this pathnameURI toUri()
URI representation of this pathname.URI representation of this pathnameResolvedPath resolve(String first, String... more)
ResolvedPath object representing the resolved
pathname of a descendant of this directory or returns this object if the
specified names result in the empty string.
All of the specified names are combined together, in a system dependant manner, resulting in a relative pathname. This pathname is resolved against this directory.
Usage example (for a system with a name separator "/"):
Directory tmp = ... // for example "/tmp"
tmp.resolve("a"); // resolves to "/tmp/a"
tmp.resolve("x", "..", "z"); // resolves to "/tmp/x/../z" (eq. to "/tmp/z")
tmp.resolve(""); // resolves to "/tmp"
tmp.resolve("..", "root", ".ssh"); // fails with IllegalArgumentException (not descendant)
tmp.resolve("/root"); // fails with IllegalArgumentException (absolute)
first - the first part of the pathname relative to this directorymore - the remaining parts of the pathname relative to this directoryResolvedPath representing the pathname of a descendant of
this directoryIllegalArgumentException - if the resolved pathname is not a descendant of this directoryCopyright © 2021–2022 Objectos Software LTDA. All rights reserved.