uk.ac.starlink.datanode.nodes
Class FtpLocation

java.lang.Object
  extended by uk.ac.starlink.datanode.nodes.FtpLocation

public class FtpLocation
extends Object

Encapsulates the location of a directory on an FTP server.


Constructor Summary
FtpLocation(FtpLocation floc, String path)
          Constructs a new FtpLocation based on this one.
FtpLocation(String loc)
          Constructs a new FtpLocation from a URL-like string.
 
Method Summary
 URL getBaseURL()
          Returns a URL representing the connection used by this object.
 org.apache.commons.net.ftp.FTPClient getClient()
          Returns an FTP client for use at this location from a public pool.
 FtpLocation getParent()
          Returns the FtpLocation representing the parent directory of this one, if it has one.
 String getPath()
          Returns the full directory path for this node.
 URL getURL()
          Returns the URL representing this directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtpLocation

public FtpLocation(String loc)
            throws NoSuchDataException
Constructs a new FtpLocation from a URL-like string. The string must be of the form "ftp://[user[:password]@]hostname[:port]path" where path is a '/'-separated absolute pathname of a directory on the server.

Parameters:
loc - url of the ftp directory
Throws:
NoSuchDataException

FtpLocation

public FtpLocation(FtpLocation floc,
                   String path)
            throws NoSuchDataException
Constructs a new FtpLocation based on this one. The same host and authentication information will be used, but the directory location is specified by the path argument, which may be either absolute (starting with a '/') or relative to this object's path.

Parameters:
floc - the object from which to copy connection information
path - the absolute or relative path of the new location object
Throws:
NoSuchDataException
Method Detail

getPath

public String getPath()
Returns the full directory path for this node.

Returns:
pathname of directory in ftp filesystem

getBaseURL

public URL getBaseURL()
Returns a URL representing the connection used by this object. This contains the host, but not the path to the directory.

Returns:
connection URL

getURL

public URL getURL()
Returns the URL representing this directory.

Returns:
directory URL

getParent

public FtpLocation getParent()
Returns the FtpLocation representing the parent directory of this one, if it has one. If it has no parent (presumably because it is the root) null is returned.

Returns:
parent location, or null

getClient

public org.apache.commons.net.ftp.FTPClient getClient()
                                               throws IOException
Returns an FTP client for use at this location from a public pool. In general the pool keeps only one client for each host. Such clients may be in use by more than one thread at a time, so you should synchronise on them when performing a sequence of commands. Steps are taken to ensure that the returned client is not timed out (and is not just about to be).

Returns:
a pooled client usable at this location
Throws:
IOException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.