|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
@Generated(value="br.com.objectos.core.multirelease.processor.TemplateProcessor") public interface Directory
A façade for directory only operations.
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.
| Method Summary | ||
|---|---|---|
|
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. |
|
| Methods inherited from interface java.lang.Comparable |
|---|
compareTo |
| Methods inherited from interface br.com.objectos.core.object.ToStringObject |
|---|
formatToString |
| Method Detail |
|---|
void 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 directory
FoundException - if any directory or file with the same relative pathname exists in
the destination
IOException - if an I/O error occurs
Directory createDirectory(String directoryName)
throws FoundException,
IOException
directoryName - the name of the directory to be created
Directory instance representing the newly created
directory
IllegalArgumentException - if the resolved pathname is not a direct child of this directory
FoundException - if the resolved pathname already exists
IOException - if an I/O error occurs
RegularFile 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 options
IllegalArgumentException - if the resolved pathname is not a direct child of this directory
FoundException - if the resolved pathname already exists
IOException - if an I/O error occurs
void delete()
throws IOException
IOException - if an I/O error occursdeleteContents()
void deleteContents()
throws IOException
IOException - if an I/O error occurs
Directory getDirectory(String directoryName)
throws NotFoundException,
NotDirectoryException,
IOException
directoryName - the name of the directory to be located
IllegalArgumentException - if the resolved pathname is not a direct child of this directory
NotFoundException - if the resolved pathname does not exist
NotDirectoryException - 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 created
IllegalArgumentException - if the resolved pathname is not a direct child of this directory
NotRegularFileException - if the resolved pathname exists but it is not a regular file (it is
a directory, for example)
IOException - if an I/O error occurs
Directory 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 located
IllegalArgumentException - if the resolved pathname is not a direct child of this directory
NotFoundException - if the resolved pathname does not exist
NotRegularFileException - 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 entries
void visitContents(DirectoryContentsVisitor visitor)
throws IOException
visitor - the visitor instance
IOException - 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 visitor
IOException - 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 pathname
ResolvedPath 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 directory
ResolvedPath representing the pathname of a descendant of
this directory
IllegalArgumentException - if the resolved pathname is not a descendant of this directory
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||