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.
-
VirtualObject()
- Create a virtual resource
-
canList()
- Check if this object is a readable directory.
-
canRead()
- Check if this object is not a folder and can be read.
-
canWrite()
- Check if this object is not a folder and can be written.
-
delete()
- Request to delete this resource
-
formatLsString(boolean, String, String, Object, long, String)
- Convenience function that formats single line of
list printout.
-
getAnnotationReader()
- Returns annotation stream for this resource.
-
getMimeType()
- Return MIME-type for the content of this object.
-
getMimeType(String)
- Convenience function that guesses mime type on
the grounds of the resource name.
-
lastModified()
- Return when this object was last modified
-
list(PrintWriter, String, boolean)
- produce a list of the subresources in this resource.
-
mkdir()
- Creates a folder specified by the path (given in the
constructor).
-
read(OutputStream, int, long)
- Read this object and write it (as it is being read) to out.
-
renameTo(VirtualObject)
- Rename this resource
-
size()
- Return the size of this object in bytes
-
write(InputStream, int, long)
- Write this object reading data from the stream.
VirtualObject
protected VirtualObject()
- Create a virtual resource
canList
public boolean canList()
- Check if this object is a readable directory.
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
canRead
public boolean canRead()
- Check if this object is not a folder and can be read.
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
canWrite
public boolean canWrite()
- Check if this object is not a folder and can be written.
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
size
public long size() throws FTPDException
- Return the size of this object in bytes
- Throws: FTPDException
- throws if resource size cannot be determined
lastModified
public long lastModified() throws FTPDException
- Return when this object was last modified
- Throws: FTPDException
- throws if modification time cannot be determined
getMimeType
public String getMimeType()
- Return MIME-type for the content of this object.
This information can be accessed using SITE MIME command.
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.
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
delete
public void delete() throws FTPDException
- Request to delete this resource
- Throws: FTPDException
- throws if this resource cannot be deleted
renameTo
public void renameTo(VirtualObject dest) throws FTPDException
- Rename this resource
- Throws: FTPDException
- throws an exception if resource
cannot be renamed
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
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