atg.vfs
Interface VirtualFile


public interface VirtualFile

Abstraction of an entry in some VirtualFileSystem. It could be a wrapper around a java.io.File, or a java.util.zip.ZipEntry, or whatever file-like element is managed by that layer.


Field Summary
static java.lang.String CLASS_VERSION
           
 
Method Summary
 boolean canRead()
          Tests if the application can read from the specified file.
 boolean canWrite()
          Tests if the application can write to this file.
 boolean createNewFile()
          create this virtual file
 boolean delete()
          Deletes the file specified by this object.
 boolean exists()
          Tests if this File exists.
 java.lang.String getAbsolutePath()
          Returns the absolute pathname of the file represented by this object.
 java.lang.String getCanonicalPath()
          Returns the canonical form of this File object's pathname.
 long getChecksum()
          get the checksum for the file
 VirtualFile getChild(java.lang.String name)
          Get a child file of this file with a given name.
 VirtualFile getChild(atg.vfs.VirtualPath path)
          Get a child file of this file with a given relative path.
 atg.vfs.VirtualFileDescriptor getFileDescriptor()
          Get the VirtualFileDescriptor for this object
 VirtualFileSystem getFileSystem()
          Get the file system used by this VirtualFile
 java.io.InputStream getInputStream()
          Get an input stream for this file.
 long getLastModified()
          Returns the time that the file represented by this File object was last modified.
 long getLength()
          Returns the length of the file represented by this File object.
 java.lang.String[] getList()
          Returns a list of the files in the directory specified by this File object.
 java.lang.String getName()
          Returns the name of the file represented by this object.
 java.io.OutputStream getOutputStream()
          Get 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.
 VirtualFile getParentFile()
          Returns the VirtualFile representing the parent directory of this VirtualFile object, or null if this is the root file of the VirtualFileSystem.
 java.lang.String getPath()
          Returns the pathname of the file represented by this object.
 java.lang.String getVFSName()
          get the application specific name for the vfs that this virtual file lives in.
 atg.vfs.VirtualPath getVirtualPath()
          Returns the pathname of the file represented by this object as a VirtualPath object.
 boolean hasDifferentCase()
          Returns whether the case for the file on the file system is different than the case of the name used to obtain the file.
 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.
 long lastModified()
          Returns the time that the file represented by this File object was last modified.
 long length()
          Returns the length of the file represented by this File object.
 java.lang.String[] list()
          Returns a list of the files in the directory specified by this File object.
 java.lang.String[] list(java.lang.String fileType)
          Returns a list of the files in the directory specified by this File that are of the given type.
 java.lang.String[] list(VirtualFilenameFilter filter)
          Returns a list of the files in the directory specified by this File that satisfy the specified filter.
 boolean mkdir()
          Creates a directory whose pathname is specified by this File object.
 boolean mkdirs()
          Creates a directory whose pathname is specified by this File object, including any necessary parent directories.
 boolean renameTo(VirtualFile dest)
          Renames the file specified by this File object to have the pathname given by the File argument.
 void setLastModified(long pTime)
          Set the time that the file represented by this File object was last modified.
 java.lang.String toExternalForm()
          Return a URL to the external form of this file system.
 java.lang.String toString()
          Return a descriptive string for this file.
 

Field Detail

CLASS_VERSION

static final java.lang.String CLASS_VERSION
See Also:
Constant Field Values
Method Detail

getInputStream

java.io.InputStream getInputStream()
                                   throws java.io.IOException
Get an input stream for this file.

Throws:
java.io.IOException

getOutputStream

java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get an output stream for this file. Returns null if no entry present.

Throws:
java.io.IOException

getChild

VirtualFile getChild(java.lang.String name)
Get a child file of this file with a given name. The name may not contain path separators.


getChild

VirtualFile getChild(atg.vfs.VirtualPath path)
Get a child file of this file with a given relative path.


toString

java.lang.String toString()
Return a descriptive string for this file.

Overrides:
toString in class java.lang.Object

getName

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:
the name of the file (without any directory components) represented by this File object.

getVirtualPath

atg.vfs.VirtualPath getVirtualPath()
Returns the pathname of the file represented by this object as a VirtualPath object.

Returns:
the pathname represented by this VirtualFile object.

getFileSystem

VirtualFileSystem getFileSystem()
Get the file system used by this VirtualFile

Returns:
the VFS used by this VirtualFile

getPath

java.lang.String getPath()
Returns the pathname of the file represented by this object.

Returns:
the pathname represented by this File object.

getAbsolutePath

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

Returns:
a system-dependent absolute pathname for this File.

getCanonicalPath

java.lang.String getCanonicalPath()
                                  throws java.io.IOException
Returns the canonical form of this File object's pathname. The precise definition of canonical form is system-dependent, but it usually specifies an absolute pathname in which all relative references and references to the current user directory have been completely resolved. The canonical form of a pathname of a nonexistent file may not be defined.

Throws:
java.io.IOException - If an I/O error occurs, which is possible because the construction of the canonical path may require filesystem queries.

getParent

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. On UNIX, for example, the parent part of "/usr/lib" is "/usr", whose parent part is "/", which in turn has no parent. On Windows platforms, the parent part of "c:\java" is "c:\", which in turn has no parent.


getParentFile

VirtualFile getParentFile()
Returns the VirtualFile representing the parent directory of this VirtualFile object, or null if this is the root file of the VirtualFileSystem.


exists

boolean exists()
Tests if this File exists.

Returns:
true if the file specified by this object exists; false otherwise.
Throws:
java.lang.SecurityException - if a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.

canWrite

boolean canWrite()
Tests if the application can write to this file.

Returns:
true if the application is allowed to write to a file whose name is specified by this object; false otherwise.
Throws:
java.lang.SecurityException - if a security manager exists, its checkWrite method is called with the pathname of this File to see if the application is allowed write access to the file.

canRead

boolean canRead()
Tests if the application can read from the specified file.

Returns:
true if the file specified by this object exists and the application can read the file; false otherwise.
Throws:
java.lang.SecurityException - if a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.

isFile

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

A file is "normal" if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

Returns:
true if the file specified by this object exists and is a "normal" file; false otherwise.
Throws:
java.lang.SecurityException - If a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

isDirectory

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.
Throws:
java.lang.SecurityException - if a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

isAbsolute

boolean isAbsolute()
Tests if the file represented by this File object is an absolute pathname. The definition of an absolute pathname is system dependent. For example, on UNIX, a pathname is absolute if its first character is the separator character. On Windows platforms, a pathname is absolute if its first character is an ASCII '\' or '/', or if it begins with a letter followed by a colon.

Returns:
true if the pathname indicated by the File object is an absolute pathname; false otherwise.
See Also:
atg.vfs.File#getPath(), atg.vfs.File#separator

lastModified

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

The return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.

Returns:
the time the file specified by this object was last modified, or 0L if the specified file does not exist.
Throws:
java.lang.SecurityException - if a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

getLastModified

long getLastModified()
Returns the time that the file represented by this File object was last modified. This method has been added to expose this as a bean property.

The return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.

Returns:
the time the file specified by this object was last modified, or 0L if the specified file does not exist.
Throws:
java.lang.SecurityException - if a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
lastModified(), atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

setLastModified

void setLastModified(long pTime)
                     throws java.io.IOException
Set the time that the file represented by this File object was last modified.

Throws:
java.lang.SecurityException - if a security manager exists, its checkWrite method is called with the pathname of this File to see if the application is allowed write access to the file.
java.io.IOException - If an I/O error occurs (if the file doesn't exist or the file system doesn't support setting the last modified date).
See Also:
SecurityManager.checkWrite(java.lang.String)

length

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.
Throws:
java.lang.SecurityException - if a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

getLength

long getLength()
Returns the length of the file represented by this File object. This method has been added to expose this as a bean property.

Returns:
the length, in bytes, of the file specified by this object, or 0L if the specified file does not exist.
Throws:
java.lang.SecurityException - if a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
length(), atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

mkdir

boolean mkdir()
Creates a directory whose pathname is specified by this File object.

Returns:
true if the directory could be created; false otherwise.
Throws:
java.lang.SecurityException - if a security manager exists, its checkWrite method is called with the pathname of this File to see if the application is allowed write access to the file.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkWrite(java.lang.String)

renameTo

boolean renameTo(VirtualFile dest)
Renames the file specified by this File object to have the pathname given by the File argument.

Parameters:
dest - the new filename.
Returns:
true if the renaming succeeds; false otherwise.
Throws:
java.lang.SecurityException - if a security manager exists, its checkWrite method is called both with the pathname of this file object and with the pathname of the destination target object to see if the application is allowed to write to both files.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkWrite(java.lang.String)

mkdirs

boolean mkdirs()
Creates a directory whose pathname is specified by this File object, including any necessary parent directories.

Returns:
true if the directory (or directories) could be created; false otherwise.
Throws:
java.lang.SecurityException - if a security manager exists, its checkWrite method is called with the pathname of each of the directories that is to be created, before any of the directories are created.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkWrite(java.lang.String)

list

java.lang.String[] list()
Returns a list of the files in the directory specified by this File object.

Returns:
an array of file names in the specified directory. This list does not include the current directory or the parent directory ("." and ".." on Unix systems). If the VirtualFile does not refer to a directory, an empty array is returned.
Throws:
java.lang.SecurityException - If a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

getList

java.lang.String[] getList()
Returns a list of the files in the directory specified by this File object. This method has been added to expose this as a bean property.

Returns:
an array of file names in the specified directory. This list does not include the current directory or the parent directory ("." and ".." on Unix systems). If the VirtualFile does not refer to a directory, an empty array is returned.
Throws:
java.lang.SecurityException - If a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
list(), atg.vfs.File#getPath(), SecurityManager.checkRead(java.lang.String)

list

java.lang.String[] list(VirtualFilenameFilter filter)
Returns a list of the files in the directory specified by this File that satisfy the specified filter.

Parameters:
filter - a filename filter.
Returns:
an array of file names in the specified directory. This list does not include the current directory or the parent directory ("." and ".." on Unix systems).
Throws:
java.lang.SecurityException - If a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
atg.vfs.File#getPath(), VirtualFilenameFilter, SecurityManager.checkRead(java.lang.String)

list

java.lang.String[] list(java.lang.String fileType)
Returns a list of the files in the directory specified by this File that are of the given type.

Parameters:
fileType - a file type
Returns:
an array of file names in the specified directory. This list does not include the current directory or the parent directory ("." and ".." on Unix systems).
Throws:
java.lang.SecurityException - If a security manager exists, its checkRead method is called with the pathname of this File to see if the application is allowed read access to the file.
See Also:
atg.vfs.File#getPath(), VirtualFilenameFilter, SecurityManager.checkRead(java.lang.String)

delete

boolean delete()
Deletes the file specified by this object. If the target file to be deleted is a directory, it must be empty for deletion to succeed.

Returns:
true if the file is successfully deleted; false otherwise.
Throws:
java.lang.SecurityException - if a security manager exists, its checkDelete method is called with the pathname of this File to see if the application is allowed to delete the file.
See Also:
atg.vfs.File#getPath(), SecurityManager.checkDelete(java.lang.String)

toExternalForm

java.lang.String toExternalForm()
Return a URL to the external form of this file system. May return null if not external URL is available.


hasDifferentCase

boolean hasDifferentCase()
Returns whether the case for the file on the file system is different than the case of the name used to obtain the file.


getVFSName

java.lang.String getVFSName()
get the application specific name for the vfs that this virtual file lives in.


createNewFile

boolean createNewFile()
                      throws java.io.IOException
create this virtual file

Returns:
false is the file already exists, true if the file was created successfully.
Throws:
java.io.IOException

getFileDescriptor

atg.vfs.VirtualFileDescriptor getFileDescriptor()
Get the VirtualFileDescriptor for this object


getChecksum

long getChecksum()
                 throws java.io.IOException
get the checksum for the file

Throws:
java.io.IOException