cz.dhl.io
Interface CoFile

All Superinterfaces:
CoComparable, java.lang.Comparable, CoOpen, CoOrder
All Known Implementing Classes:
FtpFile, LocalFile

public interface CoFile
extends CoOrder, CoOpen

Allows uniform manipulation with files from various sources. Equivalent for File object.

Only absolute pathnames are supported!

Version:
0.72 08/10/2003
Author:
Bea Petrovicova
See Also:
File

Method Summary
 boolean canRead()
          Tests whether the application can read the file denoted by this abstract pathname.
 boolean canWrite()
          Tests whether the application can modify to the file denoted by this abstract pathname.
 boolean delete()
          Deletes the file or directory denoted by this abstract pathname.
 boolean exists()
          Tests whether the file denoted by this abstract pathname exists.
 java.lang.String getAbsolutePath()
          Returns the absolute pathname of the file represented by this object.
 java.lang.String getAccess()
          Returns access string.
 java.lang.String getHost()
          Returns the host name.
 java.lang.String getName()
          Returns the name of the file represented by this object.
 java.lang.String getParent()
          Returns the parent part of the pathname of this File object, or null if the name has no parent part.
 java.lang.String[] getPathArray()
          Tokens the pathname by separator.
 int getPathDepth()
          Returns depth (number of levels) of this abstract pathname.
 CoFile getPathFragment(int depth)
          Returns abstract pathname containing first depth levels of this pathname of the file represented by this object.
 boolean isAbsolute()
          Tests if the file represented by this File object is an absolute pathname.
 boolean isDirectory()
          Tests if the file represented by this File object is a directory.
 boolean isFile()
          Tests if the file represented by this File object is a "normal" file.
 boolean isHidden()
          Tests whether the file named by this abstract pathname is a hidden file.
 boolean isLink()
          Tests whether the file named by this abstract pathname is a link.
 boolean isSpecial()
          Tests whether the file named by this abstract pathname is a special file.
 long lastModified()
          Returns the time that the file represented by this File object was last modified.
 java.lang.String lastModifiedString()
          Returns the time string that the file represented by this CoFile object was last modified in short mode.
 long length()
          Returns the length of the file represented by this File object.
 CoFile[] listCoFiles()
          Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
 CoFile[] listCoFiles(CoFilenameFilter filter)
          Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.
 CoFile[] listCoRoots()
          List the available filesystem roots.
 boolean mkdir()
          Creates the directory named by this abstract pathname.
 boolean mkdirs()
          Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.
 java.lang.String propertyString()
          Returns a property string.
 boolean renameTo(CoFile dest)
          Renames the file denoted by this abstract pathname.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from interface cz.dhl.io.CoOrder
compareExtToIgnoreCase, compareNameToIgnoreCase, compareTo, equalsExtTo, equalsExtTo, isConnected, startsWithIgnoreCase
 
Methods inherited from interface cz.dhl.io.CoOpen
getConsole, getDataType, getInputStream, getOutputStream, getOutputStream, newFileChild, newFileRename
 

Method Detail

canRead

public boolean canRead()
Tests whether the application can read the file denoted by this abstract pathname.


canWrite

public boolean canWrite()
Tests whether the application can modify to the file denoted by this abstract pathname.


delete

public boolean delete()
               throws java.lang.SecurityException
Deletes the file or directory denoted by this abstract pathname.

Throws:
java.lang.SecurityException

exists

public boolean exists()
Tests whether the file denoted by this abstract pathname exists.


getAbsolutePath

public java.lang.String getAbsolutePath()
Returns the absolute pathname of the file represented by this object.

Returns:
full pathname (directory components + filename).

getAccess

public java.lang.String getAccess()
Returns access string.
This function is not part of java.io.File specification.


getHost

public java.lang.String getHost()
Returns the host name.
This function is not part of java.io.File specification.


getName

public java.lang.String getName()
Returns the name of the file represented by this object. The name is everything in the pathame after the last occurrence of the separator character.

Returns:
name of the file (NO directory components).

getParent

public java.lang.String getParent()
Returns the parent part of the pathname of this File object, or null if the name has no parent part. The parent part is generally everything leading up to the last occurrence of the separator character, although the precise definition is system dependent.

Returns:
directory part of the pathname (NO filename).

getPathArray

public java.lang.String[] getPathArray()
Tokens the pathname by separator.
This function is not part of java.io.File specification.

Returns:
Array of strings describing directory part of the pathname: [Server-name]/[Disk-root]
[1st-level-parent-dir-name]
[2nd-level-parent-dir-name]
...
[Top-level-parent-dir-name]

getPathDepth

public int getPathDepth()
Returns depth (number of levels) of this abstract pathname.
This function is not part of java.io.File specification.


getPathFragment

public CoFile getPathFragment(int depth)
Returns abstract pathname containing first depth levels of this pathname of the file represented by this object.
This function is not part of java.io.File specification.


isAbsolute

public boolean isAbsolute()
Tests if the file represented by this File object is an absolute pathname.

Returns:
true if the pathname indicated by the File object is an absolute pathname; false otherwise

isDirectory

public boolean isDirectory()
Tests if the file represented by this File object is a directory.

Returns:
true if this File exists and is a directory; false otherwise

isFile

public boolean isFile()
Tests if the file represented by this File object is a "normal" file.

Returns:
true if the file specified by this object exists and is a "normal" file; false otherwise

isHidden

public boolean isHidden()
Tests whether the file named by this abstract pathname is a hidden file.


isLink

public boolean isLink()
Tests whether the file named by this abstract pathname is a link.
This function is not part of java.io.File specification.


isSpecial

public boolean isSpecial()
Tests whether the file named by this abstract pathname is a special file.
This function is not part of java.io.File specification.


lastModified

public long lastModified()
Returns the time that the file represented by this File object was last modified.

Returns:
the time the file specified by this object was last modified, or 0L if the specified file does not exist.

lastModifiedString

public java.lang.String lastModifiedString()
Returns the time string that the file represented by this CoFile object was last modified in short mode.

Returns:
the time string the file specified by this object was last modified.

length

public long length()
Returns the length of the file represented by this File object.

Returns:
the length, in bytes, of the file specified by this object, or 0L if the specified file does not exist.

listCoFiles

public CoFile[] listCoFiles()
                     throws java.lang.SecurityException
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname. If this abstract pathname does not denote a directory, then this method returns null. Otherwise an array of File objects is returned, one for each file or directory in the directory. Pathnames denoting the directory itself and the directory's parent directory are not included in the result. Each resulting abstract pathname is constructed from this abstract pathname. There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.

Throws:
java.lang.SecurityException

listCoFiles

public CoFile[] listCoFiles(CoFilenameFilter filter)
                     throws java.lang.SecurityException
Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. The behavior of this method is the same as that of the listCoFiles()} method, except that the strings in the returned array must satisfy the filter. If the given filter is null then all names are accepted.

Throws:
java.lang.SecurityException

listCoRoots

public CoFile[] listCoRoots()
List the available filesystem roots.
This function is static in java.io.File specification.


mkdir

public boolean mkdir()
              throws java.lang.SecurityException
Creates the directory named by this abstract pathname.

Throws:
java.lang.SecurityException

mkdirs

public boolean mkdirs()
               throws java.lang.SecurityException
Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

Throws:
java.lang.SecurityException

propertyString

public java.lang.String propertyString()
Returns a property string.
This function is not part of java.io.File specification.

Returns:
a property string.

renameTo

public boolean renameTo(CoFile dest)
                 throws java.lang.SecurityException
Renames the file denoted by this abstract pathname.

Throws:
java.lang.SecurityException

toString

public java.lang.String toString()
Returns a string representation of this object.

Returns:
a string giving the pathname of this object.


Available from sourceforge http://sourceforge.net/projects/jvftp under the terms of GNU Lesser General Public License (LGPL).