br.com.objectos.fs
Interface ResolvedPath

All Superinterfaces:
OutputStreamSource, PathName, WritablePathName, WriterSource

public interface ResolvedPath
extends PathName, WritablePathName

A façade for operating on a pathname in a file system for which is not known if it is a directory, a file or if it does not exist.

Instances of this interface are usually obtained from the PathNameResolver.resolve(String, String...) method hence the name resolved path.

Since:
2

Method Summary
<R,P> R
acceptPathNameVisitor(PathNameVisitor<R,P> visitor, P p)
          Accept method used to implement the visitor pattern.
 Directory createDirectory()
          Creates a directory whose pathname is given by this object or fails if the pathname already exists.
 ResolvedPath createParents()
          Creates all nonexistent parent directories of this pathname.
 RegularFile createRegularFile(RegularFileCreateOption... options)
          Creates a new (regular) file whose pathname is given by this object with the specified creation options or fails if the pathname already exists.
 boolean exists()
          Returns true if the pathname represented by this object exists.
 String getName()
          Returns the name of this object.
 String getPath()
          Returns the full path of this object.
 Directory toDirectory()
          Returns the directory denoted by this pathname; fails if the directory does not exist or if the pathname is not a directory.
 Directory toDirectoryCreateIfNotFound()
          Returns the directory denoted by this pathname; creates a new directory if it does not exist or fails if the pathname is not a directory.
 File toFile()
          Returns a File representation of this pathname.
 RegularFile toRegularFile()
          Returns the file denoted by this pathname; fails if the file does not exist or if the pathname is not a regular file.
 URI toUri()
          Returns an URI representation of this pathname.
 
Methods inherited from interface br.com.objectos.fs.WritablePathName
openOutputStream, openWriteChannel, openWriter
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface br.com.objectos.core.object.ToStringObject
formatToString
 

Method Detail

createDirectory

Directory createDirectory()
                          throws FoundException,
                                 IOException
Creates a directory whose pathname is given by this object or fails if the pathname already exists.

Nonexistent parent directories are not created by this method, use createParents() if necessary.

Returns:
a façade representing a newly created directory
Throws:
FoundException - if this pathname exists (even if it is a directory)
IOException - if an I/O error occurs

createParents

ResolvedPath createParents()
                           throws IOException
Creates all nonexistent parent directories of this pathname.

Returns:
a reference to this object
Throws:
IOException - if an I/O error occurs

createRegularFile

RegularFile createRegularFile(RegularFileCreateOption... options)
                              throws FoundException,
                                     IOException
Creates a new (regular) file whose pathname is given by this object with the specified creation options or fails if the pathname already exists.

Nonexistent parent directories are not created by this method, use createParents() if necessary.

Parameters:
options - the file creation options
Returns:
a façade representing a newly created file
Throws:
FoundException - if this pathname exists (even if it is a regular file)
IOException - if an I/O error occurs

toDirectory

Directory toDirectory()
                      throws NotFoundException,
                             NotDirectoryException,
                             IOException
Returns the directory denoted by this pathname; fails if the directory does not exist or if the pathname is not a directory.

Returns:
a façade for directory only operations
Throws:
NotFoundException - if this pathname does not exist
NotDirectoryException - if this pathname exists but it is not a directory (it is a regular file for instance)
IOException - if an I/O error occurs

toDirectoryCreateIfNotFound

Directory toDirectoryCreateIfNotFound()
                                      throws NotDirectoryException,
                                             IOException
Returns the directory denoted by this pathname; creates a new directory if it does not exist or fails if the pathname is not a directory.

Nonexistent parent directories are not created by this method, use createParents() if necessary.

Returns:
a façade for directory only operations
Throws:
NotDirectoryException - if this pathname exists but it is not a directory (it is a file for instance)
IOException - if an I/O error occurs

toRegularFile

RegularFile toRegularFile()
                          throws NotFoundException,
                                 NotRegularFileException,
                                 IOException
Returns the file denoted by this pathname; fails if the file does not exist or if the pathname is not a regular file.

Returns:
a façade for regular file only operations
Throws:
NotFoundException - if this pathname does not exist
NotRegularFileException - if this pathname exists but it is not a regular file (it is a directory for instance)
IOException - if an I/O error occurs

acceptPathNameVisitor

<R,P> R acceptPathNameVisitor(PathNameVisitor<R,P> visitor,
                              P p)
                        throws IOException
Accept method used to implement the visitor pattern.

Type Parameters:
R - the result type of this operation
P - the type of the additional object
Parameters:
visitor - the visitor operating on this PathName instance
p - additional object passed to the visitor
Returns:
the value returned from the visitor method
Throws:
IOException - if an I/O error occurs

exists

boolean exists()
Returns true if the pathname represented by this object exists.

Returns:
true if the pathname represented by this object exists

getName

String getName()
Returns the name of this object.

Returns:
the name of this object

getPath

String getPath()
Returns the full path of this object.

Returns:
the full path of this object

toFile

File toFile()
Returns a File representation of this pathname.

Returns:
a File representation of this pathname

toUri

URI toUri()
Returns an URI representation of this pathname.

Returns:
an URI representation of this pathname


Copyright © 2021 Objectos Software LTDA. All rights reserved.