FileDocCategorySizeDatePackage
FTPFile.javaAPI DocApache Commons NET 1.4.1 API10580Sat Dec 03 10:05:48 GMT 2005org.apache.commons.net.ftp

FTPFile

public class FTPFile extends Object implements Serializable
The FTPFile class is used to represent information about files stored on an FTP server. Because there is no standard representation for file information on FTP servers, it may not always be possible to extract all the information that can be represented by FTPFile, or it may even be possible to extract more information. In cases where more information can be extracted, you will want to subclass FTPFile and implement your own {@link org.apache.commons.net.ftp.FTPFileListParser} to extract the information. However, most FTP servers return file information in a format that can be completely parsed by {@link org.apache.commons.net.ftp.DefaultFTPFileListParser} and stored in FTPFile.

author
Daniel F. Savarese
see
FTPFileListParser
see
DefaultFTPFileListParser
see
FTPClient#listFiles

Fields Summary
public static final int
FILE_TYPE
A constant indicating an FTPFile is a file.
public static final int
DIRECTORY_TYPE
A constant indicating an FTPFile is a directory.
public static final int
SYMBOLIC_LINK_TYPE
A constant indicating an FTPFile is a symbolic link.
public static final int
UNKNOWN_TYPE
A constant indicating an FTPFile is of unknown type.
public static final int
USER_ACCESS
A constant indicating user access permissions.
public static final int
GROUP_ACCESS
A constant indicating group access permissions.
public static final int
WORLD_ACCESS
A constant indicating world access permissions.
public static final int
READ_PERMISSION
A constant indicating file/directory read permission.
public static final int
WRITE_PERMISSION
A constant indicating file/directory write permission.
public static final int
EXECUTE_PERMISSION
A constant indicating file execute permission or directory listing permission.
int
_type
int
_hardLinkCount
long
_size
String
_rawListing
String
_user
String
_group
String
_name
String
_link
Calendar
_date
boolean[]
_permissions
Constructors Summary
public FTPFile()
Creates an empty FTPFile.


         
     
    
        _permissions = new boolean[3][3];
        _rawListing = null;
        _type = UNKNOWN_TYPE;
        _hardLinkCount = 0;
        _size = 0;
        _user = null;
        _group = null;
        _date = null;
        _name = null;
    
Methods Summary
public java.lang.StringgetGroup()
Returns the name of the group owning the file. Sometimes this will be a string representation of the group number.

return
The name of the group owning the file.

        return _group;
    
public intgetHardLinkCount()
Return the number of hard links to this file. This is not to be confused with symbolic links.

return
The number of hard links to this file.

        return _hardLinkCount;
    
public java.lang.StringgetLink()
If the FTPFile is a symbolic link, this method returns the name of the file being pointed to by the symbolic link. Otherwise it returns null.

return
The file pointed to by the symbolic link (null if the FTPFile is not a symbolic link).

        return _link;
    
public java.lang.StringgetName()
Return the name of the file.

return
The name of the file.

        return _name;
    
public java.lang.StringgetRawListing()
Get the original FTP server raw listing used to initialize the FTPFile.

return
The original FTP server raw listing used to initialize the FTPFile.

        return _rawListing;
    
public longgetSize()
Return the file size in bytes.

return
The file size in bytes.

        return _size;
    
public java.util.CalendargetTimestamp()
Returns the file timestamp. This usually the last modification time.

return
A Calendar instance representing the file timestamp.

        return _date;
    
public intgetType()
Return the type of the file (one of the _TYPE constants), e.g., if it is a directory, a regular file, or a symbolic link.

return
The type of the file.

        return _type;
    
public java.lang.StringgetUser()
Returns the name of the user owning the file. Sometimes this will be a string representation of the user number.

return
The name of the user owning the file.

        return _user;
    
public booleanhasPermission(int access, int permission)
Determines if the given access group (one of the _ACCESS constants) has the given access permission (one of the _PERMISSION constants) to the file.

param
access The access group (one of the _ACCESS constants)
param
permission The access permission (one of the _PERMISSION constants)

        return _permissions[access][permission];
    
public booleanisDirectory()
Determine if the file is a directory.

return
True if the file is of type DIRECTORY_TYPE, false if not.

        return (_type == DIRECTORY_TYPE);
    
public booleanisFile()
Determine if the file is a regular file.

return
True if the file is of type FILE_TYPE, false if not.

        return (_type == FILE_TYPE);
    
public booleanisSymbolicLink()
Determine if the file is a symbolic link.

return
True if the file is of type UNKNOWN_TYPE, false if not.

        return (_type == SYMBOLIC_LINK_TYPE);
    
public booleanisUnknown()
Determine if the type of the file is unknown.

return
True if the file is of type UNKNOWN_TYPE, false if not.

        return (_type == UNKNOWN_TYPE);
    
public voidsetGroup(java.lang.String group)
Set the name of the group owning the file. This may be a string representation of the group number.

param
group The name of the group owning the file.

        _group = group;
    
public voidsetHardLinkCount(int links)
Set the number of hard links to this file. This is not to be confused with symbolic links.

param
links The number of hard links to this file.

        _hardLinkCount = links;
    
public voidsetLink(java.lang.String link)
If the FTPFile is a symbolic link, use this method to set the name of the file being pointed to by the symbolic link.

param
link The file pointed to by the symbolic link.

        _link = link;
    
public voidsetName(java.lang.String name)
Set the name of the file.

param
name The name of the file.

        _name = name;
    
public voidsetPermission(int access, int permission, boolean value)
Set if the given access group (one of the _ACCESS constants) has the given access permission (one of the _PERMISSION constants) to the file.

param
access The access group (one of the _ACCESS constants)
param
permission The access permission (one of the _PERMISSION constants)
param
value True if permission is allowed, false if not.

        _permissions[access][permission] = value;
    
public voidsetRawListing(java.lang.String rawListing)
Set the original FTP server raw listing from which the FTPFile was created.

param
rawListing The raw FTP server listing.

        _rawListing = rawListing;
    
public voidsetSize(long size)
Set the file size in bytes.

param
size The file size in bytes.

        _size = size;
    
public voidsetTimestamp(java.util.Calendar date)
Set the file timestamp. This usually the last modification time. The parameter is not cloned, so do not alter its value after calling this method.

param
date A Calendar instance representing the file timestamp.

        _date = date;
    
public voidsetType(int type)
Set the type of the file (DIRECTORY_TYPE, FILE_TYPE, etc.).

param
type The integer code representing the type of the file.

        _type = type;
    
public voidsetUser(java.lang.String user)
Set the name of the user owning the file. This may be a string representation of the user number;

param
user The name of the user owning the file.

        _user = user;
    
public java.lang.StringtoString()
Returns a string representation of the FTPFile information. This will be the raw FTP server listing that was used to initialize the FTPFile instance.

return
A string representation of the FTPFile information.

        return _rawListing;