APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.net.ftp

public Class FtpDirEntry

extends Object
Class Inheritance
Imports
java.util.Date, .HashMap, .Locale

A FtpDirEntry is a class agregating all the information that the FTP client can gather from the server by doing a LST (or NLST) command and parsing the output. It will typically contain the name, type, size, last modification time, owner and group of the file, although some of these could be unavailable due to specific FTP server limitations.
Since
1.7
See Also
sun.net.ftp.FtpDirParser

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static enum

Field Summary

Modifier and TypeField and Description
private Date
private HashMap<String, String>
private String
private Date
private final String
private boolean[][]
private long
private FtpDirEntry.Type
private String

Constructor Summary

AccessConstructor and Description
private
public
FtpDirEntry(String
The name of the file
name
)

Creates an FtpDirEntry instance with only the name being set.

Method Summary

Modifier and TypeMethod and Description
public FtpDirEntry

Returns:

this FtpDirEntry
addFact
(String
the name of the fact (e.g. "Media-Type"). It is not case-sensitive.
fact
,
String
the value associated with this fact.
value
)

Adds a 'fact', as defined in RFC 3659, to the list of facts of this file.

public boolean

Returns:

true if execute access is granted.
canExexcute
(FtpDirEntry.Permission
the Permission (user, group, others) to check.
p
)

Returns whether execute access is granted for a specific permission.

public boolean

Returns:

true if read access is granted.
canRead
(FtpDirEntry.Permission
the Permission (user, group, others) to check.
p
)

Returns whether read access is granted for a specific permission.

public boolean

Returns:

true if write access is granted.
canWrite
(FtpDirEntry.Permission
the Permission (user, group, others) to check.
p
)

Returns whether write access is granted for a specific permission.

public Date

Returns:

The Date representing the creation time, or null if the server didn't provide that information.
getCreated
()

Returns the creation time of the file, when provided by the server.

public String

Returns:

The value of the fact or, null if that fact wasn't provided by the server.
getFact
(String
The name of the fact *e.g. "Media-Type"). It is not case sensitive.
fact
)

Returns the requested 'fact', as defined in RFC 3659, if available.

public String

Returns:

a String containing the group name or null if that information is not available.
getGroup
()

Returns the group name of the file as returned by the FTP server, if provided.

public Date

Returns:

a Date representing the last time the file was modified on the server, or null if that information is not available.
getLastModified
()

Returns the last modification time of the remote file as it was returned by the FTP server, if provided, null otherwise.

public String

Returns:

a String containing the name of the remote file.
getName
()

Returns the name of the remote file.

public long

Returns:

the size of the file or -1 if that information is not available.
getSize
()

Returns the size of the remote file as it was returned by the FTP server, if provided.

public FtpDirEntry.Type

Returns:

a FtpDirEntry.Type describing the type of the file or null if that information is not available.
getType
()

Returns the type of the remote file as it was returned by the FTP server, if provided.

public String

Returns:

a String containing the user name or null if that information is not available.
getUser
()

Returns the user name of the owner of the file as returned by the FTP server, if provided.

public FtpDirEntry

Returns:

this FtpDirEntry
setCreated
(Date
the Date representing the creation time for that file, or null if that information is not available.
created
)

Sets the creation time for that file.

public FtpDirEntry

Returns:

this FtpDirEntry
setGroup
(String
The name of the group to which the file belong, or null if that information is not available.
group
)

Sets the name of the group to which the file belong.

public FtpDirEntry

Returns:

this FtpDirEntry
setLastModified
(Date
The Date representing the last modification time, or null if that information is not available.
lastModified
)

Sets the last modification time of the file.

public FtpDirEntry

Returns:

this FtpDirEntry
setPermissions
(boolean[][]
a 3x3 boolean array
permissions
)

Sets the permissions for that file.

public FtpDirEntry

Returns:

this FtpDirEntry
setSize
(long
The size, in bytes, of that file. or -1 if unknown.
size
)

Sets the size of that file.

public FtpDirEntry

Returns:

this FtpDirEntry
setType
(FtpDirEntry.Type
the type of this file or null if that information is not available.
type
)

Sets the type of the file.

public FtpDirEntry

Returns:

this FtpDirEntry
setUser
(String
The user name of the owner of the file, or null if that information is not available.
user
)

Sets the user name of the owner of the file.

public String

Returns:

a string representation of the object.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

createdback to summary
private Date created
factsback to summary
private HashMap<String, String> facts
groupback to summary
private String group
lastModifiedback to summary
private Date lastModified
nameback to summary
private final String name
permissionsback to summary
private boolean[][] permissions
sizeback to summary
private long size
typeback to summary
private FtpDirEntry.Type type
userback to summary
private String user

Constructor Detail

FtpDirEntryback to summary
private FtpDirEntry()
FtpDirEntryback to summary
public FtpDirEntry(String name)

Creates an FtpDirEntry instance with only the name being set.

Parameters
name:String

The name of the file

Method Detail

addFactback to summary
public FtpDirEntry addFact(String fact, String value)

Adds a 'fact', as defined in RFC 3659, to the list of facts of this file. Intended mostly to be used from inside a java.net.FtpDirParser implementation.

Parameters
fact:String

the name of the fact (e.g. "Media-Type"). It is not case-sensitive.

value:String

the value associated with this fact.

Returns:FtpDirEntry

this FtpDirEntry

canExexcuteback to summary
public boolean canExexcute(FtpDirEntry.Permission p)

Returns whether execute access is granted for a specific permission.

Parameters
p:FtpDirEntry.Permission

the Permission (user, group, others) to check.

Returns:boolean

true if execute access is granted.

canReadback to summary
public boolean canRead(FtpDirEntry.Permission p)

Returns whether read access is granted for a specific permission.

Parameters
p:FtpDirEntry.Permission

the Permission (user, group, others) to check.

Returns:boolean

true if read access is granted.

canWriteback to summary
public boolean canWrite(FtpDirEntry.Permission p)

Returns whether write access is granted for a specific permission.

Parameters
p:FtpDirEntry.Permission

the Permission (user, group, others) to check.

Returns:boolean

true if write access is granted.

getCreatedback to summary
public Date getCreated()

Returns the creation time of the file, when provided by the server.

Returns:Date

The Date representing the creation time, or null if the server didn't provide that information.

getFactback to summary
public String getFact(String fact)

Returns the requested 'fact', as defined in RFC 3659, if available.

Parameters
fact:String

The name of the fact *e.g. "Media-Type"). It is not case sensitive.

Returns:String

The value of the fact or, null if that fact wasn't provided by the server.

getGroupback to summary
public String getGroup()

Returns the group name of the file as returned by the FTP server, if provided. This could be a name or a group id (number).

Returns:String

a String containing the group name or null if that information is not available.

getLastModifiedback to summary
public Date getLastModified()

Returns the last modification time of the remote file as it was returned by the FTP server, if provided, null otherwise.

Returns:Date

a Date representing the last time the file was modified on the server, or null if that information is not available.

getNameback to summary
public String getName()

Returns the name of the remote file.

Returns:String

a String containing the name of the remote file.

getSizeback to summary
public long getSize()

Returns the size of the remote file as it was returned by the FTP server, if provided.

Returns:long

the size of the file or -1 if that information is not available.

getTypeback to summary
public FtpDirEntry.Type getType()

Returns the type of the remote file as it was returned by the FTP server, if provided. It returns a FtpDirEntry.Type enum and the values can be: - FtpDirEntry.Type.FILE for a normal file - FtpDirEntry.Type.DIR for a directory - FtpDirEntry.Type.LINK for a symbolic link

Returns:FtpDirEntry.Type

a FtpDirEntry.Type describing the type of the file or null if that information is not available.

getUserback to summary
public String getUser()

Returns the user name of the owner of the file as returned by the FTP server, if provided. This could be a name or a user id (number).

Returns:String

a String containing the user name or null if that information is not available.

setCreatedback to summary
public FtpDirEntry setCreated(Date created)

Sets the creation time for that file. Intended mostly to be used from inside a java.net.FtpDirParser implementation.

Parameters
created:Date

the Date representing the creation time for that file, or null if that information is not available.

Returns:FtpDirEntry

this FtpDirEntry

setGroupback to summary
public FtpDirEntry setGroup(String group)

Sets the name of the group to which the file belong. Intended mostly to be used from inside a java.net.FtpDirParser implementation.

Parameters
group:String

The name of the group to which the file belong, or null if that information is not available.

Returns:FtpDirEntry

this FtpDirEntry

setLastModifiedback to summary
public FtpDirEntry setLastModified(Date lastModified)

Sets the last modification time of the file. Intended mostly to be used from inside an java.net.FtpDirParser implementation.

Parameters
lastModified:Date

The Date representing the last modification time, or null if that information is not available.

Returns:FtpDirEntry

this FtpDirEntry

setPermissionsback to summary
public FtpDirEntry setPermissions(boolean[][] permissions)

Sets the permissions for that file. Intended mostly to be used from inside an java.net.FtpDirParser implementation. The permissions array is a 3x3 boolean array, the first index being the User, group or owner (0, 1 and 2 respectively) while the second index is read, write or execute (0, 1 and 2 respectively again).

E.G.: permissions[1][2] is the group/execute permission.

Parameters
permissions:boolean[][]

a 3x3 boolean array

Returns:FtpDirEntry

this FtpDirEntry

setSizeback to summary
public FtpDirEntry setSize(long size)

Sets the size of that file. Intended mostly to be used from inside an java.net.FtpDirParser implementation.

Parameters
size:long

The size, in bytes, of that file. or -1 if unknown.

Returns:FtpDirEntry

this FtpDirEntry

setTypeback to summary
public FtpDirEntry setType(FtpDirEntry.Type type)

Sets the type of the file. Intended mostly to be used from inside an java.net.FtpDirParser implementation.

Parameters
type:FtpDirEntry.Type

the type of this file or null if that information is not available.

Returns:FtpDirEntry

this FtpDirEntry

setUserback to summary
public FtpDirEntry setUser(String user)

Sets the user name of the owner of the file. Intended mostly to be used from inside a java.net.FtpDirParser implementation.

Parameters
user:String

The user name of the owner of the file, or null if that information is not available.

Returns:FtpDirEntry

this FtpDirEntry

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object. The toString method for class FtpDirEntry returns a string consisting of the name of the file, followed by its type between brackets, followed by the user and group between parenthesis, then size between '{', and, finally, the lastModified of last modification if it's available.

Returns:String

a string representation of the object.

Annotations
@Override
sun.net.ftp back to summary

public final Enum FtpDirEntry.Permission

extends Enum<FtpDirEntry.Permission>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final FtpDirEntry.Permission
public static final FtpDirEntry.Permission
public static final FtpDirEntry.Permission
pack-priv int

Constructor Summary

AccessConstructor and Description
private
Permission(int v)

Method Summary

Modifier and TypeMethod and Description
public static FtpDirEntry.Permission
public static FtpDirEntry.Permission[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

GROUPback to summary
public static final FtpDirEntry.Permission GROUP
OTHERSback to summary
public static final FtpDirEntry.Permission OTHERS
USERback to summary
public static final FtpDirEntry.Permission USER
valueback to summary
pack-priv int value

Constructor Detail

Permissionback to summary
private Permission(int v)

Method Detail

valueOfback to summary
public static FtpDirEntry.Permission valueOf(String name)
valuesback to summary
public static FtpDirEntry.Permission[] values()
sun.net.ftp back to summary

public final Enum FtpDirEntry.Type

extends Enum<FtpDirEntry.Type>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final FtpDirEntry.Type
public static final FtpDirEntry.Type
public static final FtpDirEntry.Type
public static final FtpDirEntry.Type
public static final FtpDirEntry.Type

Constructor Summary

AccessConstructor and Description
private
Type()

Method Summary

Modifier and TypeMethod and Description
public static FtpDirEntry.Type
public static FtpDirEntry.Type[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CDIRback to summary
public static final FtpDirEntry.Type CDIR
DIRback to summary
public static final FtpDirEntry.Type DIR
FILEback to summary
public static final FtpDirEntry.Type FILE
PDIRback to summary
public static final FtpDirEntry.Type PDIR

Constructor Detail

Typeback to summary
private Type()

Method Detail

valueOfback to summary
public static FtpDirEntry.Type valueOf(String name)
valuesback to summary
public static FtpDirEntry.Type[] values()