com.ssh.sft
Class Location

java.lang.Object
  extended bycom.ssh.sft.SftLib
      extended bycom.ssh.sft.SftBase
          extended bycom.ssh.sft.Location
All Implemented Interfaces:
SftLibConstants

public class Location
extends com.ssh.sft.SftBase

A location for a remote file. Instances of this class represent remote file locations which may be occupied by files. A location has two components: a Session that determines a host, and a path within that host. Operations on file locations are not reliable if the relevant parts of the file system are concurrently being modified by external processes.


Field Summary
 
Fields inherited from interface com.ssh.sft.SftLibConstants
SSH_SFT_API_VERSION, SSH_SFT_DIR_RECURSIVE, SSH_SFT_HASH_MAX_BLOCK_SIZE, SSH_SFT_HASH_MAX_ITERATIONS, SSH_SFT_HASH_MIN_BLOCK_SIZE, SSH_SFT_REQUEST_MAX_NUM, SSH_SFT_REQUEST_MAX_SIZE
 
Method Summary
 Directory createDirectory(FileAttributes attrs)
          Creates a new directory at this location.
 RegularFile createFile()
          Creates a new file at this location, initially empty.
 SymLink createSymLink(Location target)
          Creates a new symbolic link at this location.
 Location getCanonicalPath()
          Resolve absolute path of this location.
 File getFile()
          Returns a representation of the file at this location.
 String getPath()
          Returns the path that this location's session uses to access this location.
 Session getSession()
          Returns the session that is used to access this location.
 URI getURI()
          Returns the URI that is used to access this location.
 Location resolve(String relPath)
          Constructs a new Location by parsing the given parth and then resolving it against this Location object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFile

public File getFile()
             throws NoSuchFileException,
                    SftException
Returns a representation of the file at this location. The returned object is transient, i.e. it only represents the file's state and location at the time when this method was called, and becomes invalid when the file is moved, deleted or changed.

Returns:
a representation of the file at this location
Throws:
NoSuchFileException - if no file is found at this location
SftException

getPath

public String getPath()
Returns the path that this location's session uses to access this location.

Returns:
the path to this location

resolve

public Location resolve(String relPath)
Constructs a new Location by parsing the given parth and then resolving it against this Location object.

Parameters:
relPath - The string to be parsed into a location.
Returns:
The resulting Location

getCanonicalPath

public Location getCanonicalPath()
Resolve absolute path of this location. A new Location object containing the absolute path of this object is returned.

Returns:
A new Location with absolute path representing the same Location as this object.

createDirectory

public Directory createDirectory(FileAttributes attrs)
                          throws PermissionDeniedException,
                                 NoSuchFileException,
                                 SftException
Creates a new directory at this location. For this operation to succeed, the parent directory of this location must exist, and no file must yet exist at this location.

Parameters:
attrs - the attributes to assign to the new directory
Returns:
a handle to the newly created directory
Throws:
NoSuchFileException - if the parent directory of this location does not exist
PermissionDeniedException - if the client does not have the rights to create a new directory
SftException

createSymLink

public SymLink createSymLink(Location target)
                      throws SftException
Creates a new symbolic link at this location. For this operation to succeed, the parent directory of this location must exist, and no file must yet exist at this location. The target location must have the same session as this location.

Parameters:
target - the location to link to
Returns:
a handle to the newly created symbolic link
Throws:
SftException

createFile

public RegularFile createFile()
                       throws SftException
Creates a new file at this location, initially empty. For this operation to succeed, the parent directory of this location must exist, and no file must yet exist at this location.

Returns:
a handle to the newly created file
Throws:
SftException

getSession

public Session getSession()
Returns the session that is used to access this location.

Returns:
this location's session.

getURI

public URI getURI()
Returns the URI that is used to access this location.

Returns:
this location's URI.