cz.dhl.io
Class LocalFile

java.lang.Object
  extended byjava.io.File
      extended bycz.dhl.io.LocalFile
All Implemented Interfaces:
CoComparable, CoFile, java.lang.Comparable, CoOpen, CoOrder, java.io.Serializable

public final class LocalFile
extends java.io.File
implements CoFile

Allows uniform manipulation with local files. Equivalent for File object.

Only absolute pathnames are supported!

Version:
0.72 08/10/2003
Author:
Bea Petrovicova
See Also:
CoFile, File, Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
LocalFile(LocalFile dir, java.lang.String name)
          Creates a new LocalFile instance from a parent abstract pathname and a child pathname string.
LocalFile(java.lang.String path)
          Creates a new LocalFile instance by converting the given pathname string into an abstract pathname.
LocalFile(java.lang.String path, java.lang.String name)
          Creates a new LocalFile instance from a parent pathname string and a child pathname string.
 
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.
 int compareExtToIgnoreCase(CoOrder file)
          Compares two abstract pathnames lexicographically by extension.
 int compareNameToIgnoreCase(CoOrder file)
          Compares two abstract pathnames lexicographically by name.
 int compareTo(java.lang.Object o)
          Compares two abstract pathnames lexicographically (by pathname).
 boolean delete()
          Deletes the file or directory denoted by this abstract pathname.
 boolean equals(java.lang.Object o)
           
 boolean equalsExtTo(java.lang.String filter)
          Tests this abstract pathname for equality with the given extension.
 boolean equalsExtTo(java.lang.String[] filter)
          Tests this abstract pathname for equality with one of the given extensions.
 boolean exists()
          Tests whether the file denoted by this abstract pathname exists.
 java.lang.String getAccess()
          Returns access string.
 CoConsole getConsole()
          Gets console if implemented or null.
 char getDataType()
          Get type of data transfer.
 java.lang.String getHost()
          Returns the host name.
 java.io.InputStream getInputStream()
          Returns an input stream for this file.
 java.lang.String getName()
          Returns the name of the file represented by this object.
 java.io.OutputStream getOutputStream()
          Returns an output stream for this file.
 java.io.OutputStream getOutputStream(boolean append)
          Returns an output stream for this file.
 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 isConnected()
          Tests if corresponding connection to remote host is active.
 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.
 CoFile newFileChild(java.lang.String child)
          Creates a new file instance from this abstract pathname and a child string.
 CoFile newFileRename(java.lang.String name)
          Creates a new file instance from a parent of this abstract pathname and a name string.
 java.lang.String propertyString()
          Returns a property string.
 boolean renameTo(CoFile dest)
          Renames the file denoted by this abstract pathname.
 boolean startsWithIgnoreCase(char ch)
          Tests this abstract pathname whether name starts with the given character.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.io.File
compareTo, createNewFile, createTempFile, createTempFile, deleteOnExit, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getParentFile, getPath, hashCode, list, list, listFiles, listFiles, listFiles, listRoots, renameTo, setLastModified, setReadOnly, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface cz.dhl.io.CoFile
getAbsolutePath
 

Constructor Detail

LocalFile

public LocalFile(LocalFile dir,
                 java.lang.String name)
Creates a new LocalFile instance from a parent abstract pathname and a child pathname string.


LocalFile

public LocalFile(java.lang.String path)
Creates a new LocalFile instance by converting the given pathname string into an abstract pathname.


LocalFile

public LocalFile(java.lang.String path,
                 java.lang.String name)
Creates a new LocalFile instance from a parent pathname string and a child pathname string.

Method Detail

canRead

public boolean canRead()
Description copied from interface: CoFile
Tests whether the application can read the file denoted by this abstract pathname.

Specified by:
canRead in interface CoFile

canWrite

public boolean canWrite()
Description copied from interface: CoFile
Tests whether the application can modify to the file denoted by this abstract pathname.

Specified by:
canWrite in interface CoFile

compareExtToIgnoreCase

public int compareExtToIgnoreCase(CoOrder file)
Description copied from interface: CoOrder
Compares two abstract pathnames lexicographically by extension.

Specified by:
compareExtToIgnoreCase in interface CoOrder

compareNameToIgnoreCase

public int compareNameToIgnoreCase(CoOrder file)
Description copied from interface: CoOrder
Compares two abstract pathnames lexicographically by name.

Specified by:
compareNameToIgnoreCase in interface CoOrder

compareTo

public int compareTo(java.lang.Object o)
Description copied from interface: CoOrder
Compares two abstract pathnames lexicographically (by pathname).

Specified by:
compareTo in interface CoOrder

delete

public boolean delete()
               throws java.lang.SecurityException
Description copied from interface: CoFile
Deletes the file or directory denoted by this abstract pathname.

Specified by:
delete in interface CoFile
Throws:
java.lang.SecurityException

equals

public boolean equals(java.lang.Object o)

equalsExtTo

public boolean equalsExtTo(java.lang.String filter)
Description copied from interface: CoOrder
Tests this abstract pathname for equality with the given extension.

Specified by:
equalsExtTo in interface CoOrder
Parameters:
filter - must be uppercase string with a leading '.' sign; example: ".TXT" or ".HTM" or ".HTML" etc ...

equalsExtTo

public boolean equalsExtTo(java.lang.String[] filter)
Description copied from interface: CoOrder
Tests this abstract pathname for equality with one of the given extensions.

Specified by:
equalsExtTo in interface CoOrder
Parameters:
filter - must be array of uppercase strings with a leading '.' sign; example: { ".TXT", ".HTM", ".HTML", etc ... }

exists

public boolean exists()
Description copied from interface: CoFile
Tests whether the file denoted by this abstract pathname exists.

Specified by:
exists in interface CoFile

getAccess

public java.lang.String getAccess()
Description copied from interface: CoFile
Returns access string.
This function is not part of java.io.File specification.

Specified by:
getAccess in interface CoFile

getConsole

public CoConsole getConsole()
Description copied from interface: CoOpen
Gets console if implemented or null.

Specified by:
getConsole in interface CoOpen

getDataType

public char getDataType()
Description copied from interface: CoOpen
Get type of data transfer.

Specified by:
getDataType in interface CoOpen
Returns:
One of following optional values: 'A'=ASCII, 'I'=BINARY;

getHost

public java.lang.String getHost()
Description copied from interface: CoFile
Returns the host name.
This function is not part of java.io.File specification.

Specified by:
getHost in interface CoFile

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: CoOpen
Returns an input stream for this file.

Specified by:
getInputStream in interface CoOpen
Throws:
java.io.IOException

getName

public java.lang.String getName()
Description copied from interface: CoFile
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.

Specified by:
getName in interface CoFile

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Description copied from interface: CoOpen
Returns an output stream for this file.

Specified by:
getOutputStream in interface CoOpen
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream(boolean append)
                                     throws java.io.IOException
Description copied from interface: CoOpen
Returns an output stream for this file.

Specified by:
getOutputStream in interface CoOpen
Throws:
java.io.IOException

getParent

public java.lang.String getParent()
Description copied from interface: CoFile
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.

Specified by:
getParent in interface CoFile

getPathArray

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

Specified by:
getPathArray in interface CoFile
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()
Description copied from interface: CoFile
Returns depth (number of levels) of this abstract pathname.
This function is not part of java.io.File specification.

Specified by:
getPathDepth in interface CoFile

getPathFragment

public CoFile getPathFragment(int depth)
Description copied from interface: CoFile
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.

Specified by:
getPathFragment in interface CoFile

isAbsolute

public boolean isAbsolute()
Description copied from interface: CoFile
Tests if the file represented by this File object is an absolute pathname.

Specified by:
isAbsolute in interface CoFile

isConnected

public boolean isConnected()
Description copied from interface: CoOrder
Tests if corresponding connection to remote host is active.

Specified by:
isConnected in interface CoOrder

isDirectory

public boolean isDirectory()
Description copied from interface: CoFile
Tests if the file represented by this File object is a directory.

Specified by:
isDirectory in interface CoFile

isFile

public boolean isFile()
Description copied from interface: CoFile
Tests if the file represented by this File object is a "normal" file.

Specified by:
isFile in interface CoFile

isHidden

public boolean isHidden()
Description copied from interface: CoFile
Tests whether the file named by this abstract pathname is a hidden file.

Specified by:
isHidden in interface CoFile

isLink

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

Specified by:
isLink in interface CoFile

isSpecial

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

Specified by:
isSpecial in interface CoFile

lastModified

public long lastModified()
Description copied from interface: CoFile
Returns the time that the file represented by this File object was last modified.

Specified by:
lastModified in interface CoFile

lastModifiedString

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

Specified by:
lastModifiedString in interface CoFile
Returns:
the time string the file specified by this object was last modified.

length

public long length()
Description copied from interface: CoFile
Returns the length of the file represented by this File object.

Specified by:
length in interface CoFile

listCoFiles

public CoFile[] listCoFiles()
                     throws java.lang.SecurityException
Description copied from interface: CoFile
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.

Specified by:
listCoFiles in interface CoFile
Throws:
java.lang.SecurityException

listCoFiles

public CoFile[] listCoFiles(CoFilenameFilter filter)
                     throws java.lang.SecurityException
Description copied from interface: CoFile
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 CoFile.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.

Specified by:
listCoFiles in interface CoFile
Throws:
java.lang.SecurityException

listCoRoots

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

Specified by:
listCoRoots in interface CoFile

mkdir

public boolean mkdir()
              throws java.lang.SecurityException
Description copied from interface: CoFile
Creates the directory named by this abstract pathname.

Specified by:
mkdir in interface CoFile
Throws:
java.lang.SecurityException

mkdirs

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

Specified by:
mkdirs in interface CoFile
Throws:
java.lang.SecurityException

newFileChild

public CoFile newFileChild(java.lang.String child)
Description copied from interface: CoOpen
Creates a new file instance from this abstract pathname and a child string.

Specified by:
newFileChild in interface CoOpen

newFileRename

public CoFile newFileRename(java.lang.String name)
Description copied from interface: CoOpen
Creates a new file instance from a parent of this abstract pathname and a name string.

Specified by:
newFileRename in interface CoOpen

propertyString

public java.lang.String propertyString()
Description copied from interface: CoFile
Returns a property string.
This function is not part of java.io.File specification.

Specified by:
propertyString in interface CoFile
Returns:
a property string.

renameTo

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

Specified by:
renameTo in interface CoFile
Throws:
java.lang.SecurityException

startsWithIgnoreCase

public boolean startsWithIgnoreCase(char ch)
Description copied from interface: CoOrder
Tests this abstract pathname whether name starts with the given character.

Specified by:
startsWithIgnoreCase in interface CoOrder

toString

public java.lang.String toString()
Description copied from interface: CoFile
Returns a string representation of this object.

Specified by:
toString in interface CoFile


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