org.jboss.virtual.spi
Interface VirtualFileHandler

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AbstractJarHandler, AbstractStructuredJarHandler, AbstractURIHandler, AbstractURLHandler, AbstractVirtualFileHandler, AssembledDirectoryHandler, AssembledFileHandler, ByteArrayHandler, DelegatingHandler, FileHandler, JarEntryContents, JarEntryHandler, JarHandler, LinkHandler, MemoryContextHandler, NestedJarFromStream, NestedJarHandler, NoCopyNestedJarHandler, ReplacementHandler, SynthenticDirEntryHandler, ZipEntryHandler

public interface VirtualFileHandler
extends java.io.Serializable

A virtual file handler

Version:
$Revision: 44334 $
Author:
Scott.Stark@jboss.org, Adrian.Brock, Ales.Justin@jboss.org

Method Summary
 void cleanup()
          Cleanup resources.
 void close()
          Close the resources
 boolean delete(int gracePeriod)
          Delete a file represented by this handler
 boolean exists()
          Tests whether the underlying implementation file still exists.
 java.security.cert.Certificate[] getCertificates()
          Get certificates.
 VirtualFileHandler getChild(java.lang.String path)
          Get a child
 java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
 long getLastModified()
          When the file was last modified
 java.lang.String getLocalPathName()
          Get the VFS local path name.
 java.lang.String getName()
          Get the simple VF name (X.java)
 VirtualFileHandler getParent()
          Get the parent
 java.lang.String getPathName()
          Get the VFS relative path name (org/jboss/X.java)
 java.net.URL getRealURL()
          Get a file: or jar:file: URL representing a resource as precisely as possible.
 long getSize()
          Get the size
 VFSContext getVFSContext()
          Get the VFSContext this file belongs to
 VirtualFile getVirtualFile()
          Get the virtual file wrapper
 boolean hasBeenModified()
          Returns true if the file has been modified since this method was last called Last modified time is initialized at handler instantiation.
 boolean isArchive()
          Does this represent an archive.
 boolean isHidden()
          Whether it is hidden
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e.
 boolean isNested()
          Are we nested in some archive.
 java.io.InputStream openStream()
          Access the file contents.
 boolean removeChild(java.lang.String name)
          Remove a child
 void replaceChild(VirtualFileHandler original, VirtualFileHandler replacement)
          Replace child.
 java.net.URI toURI()
          Get the VF URI (file://root/org/jboss/X.java)
 java.net.URL toURL()
          Get the VF URL (file://root/org/jboss/X.java)
 java.net.URL toVfsUrl()
          Get a VFS-based URL
 

Method Detail

getName

java.lang.String getName()
Get the simple VF name (X.java)

Returns:
the simple file name

getPathName

java.lang.String getPathName()
Get the VFS relative path name (org/jboss/X.java)

Returns:
the VFS relative path name

getLocalPathName

java.lang.String getLocalPathName()
Get the VFS local path name. Relative to root.

Returns:
the VFS local path name

toVfsUrl

java.net.URL toVfsUrl()
                      throws java.net.MalformedURLException,
                             java.net.URISyntaxException
Get a VFS-based URL

Returns:
the url
Throws:
java.net.URISyntaxException - for an error parsing the URI
java.net.MalformedURLException - for any error

getRealURL

java.net.URL getRealURL()
                        throws java.io.IOException,
                               java.net.URISyntaxException
Get a file: or jar:file: URL representing a resource as precisely as possible. file: urls can represent files in the file system (i.e.: file:/classes/MyClass.class) jar:file: urls can represent entries within zip archives in the filesystem (i.e.: jar:file:/lib/classes.jar!/MyClass.class) There is no standard URL handler to represent entries within archives that are themselves entries within archives. (i.e.: this doesn't work: jar:file:/lib/app.ear!/classes.jar!/MyClass.class In this case the most precise supported resource locator is: jar:file:/lib/app.ear!/classes.jar )

Returns:
the url
Throws:
java.net.URISyntaxException - for an error parsing the URI
java.net.MalformedURLException - for any error constructing the URL
java.io.IOException

toURI

java.net.URI toURI()
                   throws java.net.URISyntaxException
Get the VF URI (file://root/org/jboss/X.java)

Returns:
the full URI to the VF in the VFS.
Throws:
java.net.URISyntaxException - for an error parsing the URI

toURL

java.net.URL toURL()
                   throws java.net.MalformedURLException,
                          java.net.URISyntaxException
Get the VF URL (file://root/org/jboss/X.java)

Returns:
the full URL to the VF in the VFS.
Throws:
java.net.URISyntaxException - for an error parsing the URI
java.net.MalformedURLException - for any error

getLastModified

long getLastModified()
                     throws java.io.IOException
When the file was last modified

Returns:
the last modified time
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if closed

hasBeenModified

boolean hasBeenModified()
                        throws java.io.IOException
Returns true if the file has been modified since this method was last called Last modified time is initialized at handler instantiation.

Returns:
true if modified, false otherwise
Throws:
java.io.IOException - for any error

getSize

long getSize()
             throws java.io.IOException
Get the size

Returns:
the size
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if closed

exists

boolean exists()
               throws java.io.IOException
Tests whether the underlying implementation file still exists.

Returns:
true if the file exists, false otherwise.
Throws:
java.io.IOException - - thrown on failure to detect existence.

isLeaf

boolean isLeaf()
               throws java.io.IOException
Whether it is a simple leaf of the VFS, i.e. whether it can contain other files

Returns:
true if a simple file.
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if the file is closed

isArchive

boolean isArchive()
                  throws java.io.IOException
Does this represent an archive. e.g. zip, tar, ...

Returns:
true if archive, false otherwise
Throws:
java.io.IOException - for any problem accessing the virtual file system

isHidden

boolean isHidden()
                 throws java.io.IOException
Whether it is hidden

Returns:
true if hidden.
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if closed

openStream

java.io.InputStream openStream()
                               throws java.io.IOException
Access the file contents.

Returns:
An InputStream for the file contents.
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if closed

getParent

VirtualFileHandler getParent()
                             throws java.io.IOException
Get the parent

Returns:
the parent
Throws:
java.io.IOException - for an error accessing the file system
java.lang.IllegalStateException - if closed

getChildren

java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                               throws java.io.IOException
Get the children

Parameters:
ignoreErrors - whether to ignore errors
Returns:
the children
Throws:
java.io.IOException - for an error accessing the file system
java.lang.IllegalStateException - if closed

getChild

VirtualFileHandler getChild(java.lang.String path)
                            throws java.io.IOException
Get a child

Parameters:
path - the path
Returns:
the child or null if not found
Throws:
java.io.IOException - for an error accessing the file system
java.lang.IllegalStateException - if closed

removeChild

boolean removeChild(java.lang.String name)
                    throws java.io.IOException
Remove a child

Parameters:
name - child name
Returns:
true if child was removed, false otherwise
Throws:
java.lang.IllegalStateException - if closed
java.io.IOException - if an error occurs

getVFSContext

VFSContext getVFSContext()
Get the VFSContext this file belongs to

Returns:
the context
Throws:
java.lang.IllegalStateException - if closed

getVirtualFile

VirtualFile getVirtualFile()
Get the virtual file wrapper

Returns:
the wrapper
Throws:
java.lang.IllegalStateException - if closed

cleanup

void cleanup()
Cleanup resources.


close

void close()
Close the resources


replaceChild

void replaceChild(VirtualFileHandler original,
                  VirtualFileHandler replacement)
Replace child.

Parameters:
original - the original
replacement - the replacement

isNested

boolean isNested()
                 throws java.io.IOException
Are we nested in some archive.

Returns:
true if this is archive entry
Throws:
java.io.IOException - for any error

delete

boolean delete(int gracePeriod)
               throws java.io.IOException
Delete a file represented by this handler

Parameters:
gracePeriod - max time to wait for locks (in milliseconds)
Returns:
boolean true if file was deleted, false otherwise
Throws:
java.io.IOException - for any error

getCertificates

java.security.cert.Certificate[] getCertificates()
Get certificates.

Returns:
the certificates associated with this virtual file handler