All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class kmy.net.ftpd.VirtualObject

kmy.net.ftpd.VirtualObject

public class VirtualObject
This class descripes a "virtual object" that can be refered using certain path (usually using FTP). Some objects map directly to some files, while others can be generated on the fly.


Constructor Index

 o VirtualObject()
Create a virtual resource

Method Index

 o canList()
Check if this object is a readable directory.
 o canRead()
Check if this object is not a folder and can be read.
 o canWrite()
Check if this object is not a folder and can be written.
 o delete()
Request to delete this resource
 o formatLsString(boolean, String, String, Object, long, String)
Convenience function that formats single line of list printout.
 o getAnnotationReader()
Returns annotation stream for this resource.
 o getMimeType()
Return MIME-type for the content of this object.
 o getMimeType(String)
Convenience function that guesses mime type on the grounds of the resource name.
 o lastModified()
Return when this object was last modified
 o list(PrintWriter, String, boolean)
produce a list of the subresources in this resource.
 o mkdir()
Creates a folder specified by the path (given in the constructor).
 o read(OutputStream, int, long)
Read this object and write it (as it is being read) to out.
 o renameTo(VirtualObject)
Rename this resource
 o size()
Return the size of this object in bytes
 o write(InputStream, int, long)
Write this object reading data from the stream.

Constructors

 o VirtualObject
 protected VirtualObject()
Create a virtual resource

Methods

 o canList
 public boolean canList()
Check if this object is a readable directory.

 o list
 public void list(PrintWriter out,
                  String patt,
                  boolean verbose) throws FTPDException
produce a list of the subresources in this resource.

Parameters:
out - output stream where the list should be printed.
patt - optional pattern that should be used to filter resources.
verbose - if verbose (ls -l) or compact (just name) list should be probuced.
Throws: FTPDException
throws if resource cannot be listed
 o canRead
 public boolean canRead()
Check if this object is not a folder and can be read.

 o read
 public void read(OutputStream out,
                  int mode,
                  long offset) throws IOException, FTPDException
Read this object and write it (as it is being read) to out.

Parameters:
out - output stream
mode - transfer mode: FTPConnection.DATA_ASCII or DATA_BIN
offset - offset where to start transfer
Throws: FTPDException
throws if resource cannot be read
Throws: IOException
throws if read operation failed
 o canWrite
 public boolean canWrite()
Check if this object is not a folder and can be written.

 o write
 public void write(InputStream in,
                   int mode,
                   long offset) throws IOException, FTPDException
Write this object reading data from the stream.

Parameters:
in - input stream
mode - transfer mode: FTPConnection.DATA_ASCII or DATA_BIN
offset - offset where to start writing data
Throws: FTPDException
throws if resource cannot be written to
Throws: IOException
throws if write operation failed
 o size
 public long size() throws FTPDException
Return the size of this object in bytes

Throws: FTPDException
throws if resource size cannot be determined
 o lastModified
 public long lastModified() throws FTPDException
Return when this object was last modified

Throws: FTPDException
throws if modification time cannot be determined
 o getMimeType
 public String getMimeType()
Return MIME-type for the content of this object. This information can be accessed using SITE MIME command.

 o getAnnotationReader
 public Reader getAnnotationReader()
Returns annotation stream for this resource. Normally annotations are used only for folders and are printed in multiline responce on the CWD command. Return null if no annotation is available.

 o mkdir
 public void mkdir() throws FTPDException
Creates a folder specified by the path (given in the constructor).

Throws: FTPDException
throws an exception if resource folder cannot be created
 o delete
 public void delete() throws FTPDException
Request to delete this resource

Throws: FTPDException
throws if this resource cannot be deleted
 o renameTo
 public void renameTo(VirtualObject dest) throws FTPDException
Rename this resource

Throws: FTPDException
throws an exception if resource cannot be renamed
 o formatLsString
 public static String formatLsString(boolean dir,
                                     String rw,
                                     String user,
                                     Object date,
                                     long size,
                                     String name)
Convenience function that formats single line of list printout.

Parameters:
dir - if the subresource is a subfolder
rw - "rw-" for read-write, also possible: "r--", "-w-", "---"
user - username of the subresource's owner
size - a size of this subresource in bytes
name - name of the subresource
 o getMimeType
 public static String getMimeType(String name)
Convenience function that guesses mime type on the grounds of the resource name.


All Packages  Class Hierarchy  This Package  Previous  Next  Index