org.jboss.virtual.spi
Interface VirtualFileHandler

All Superinterfaces:
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 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.
 VirtualFileHandler getChild(String path)
          Get a child
 List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
 long getLastModified()
          When the file was last modified
 String getLocalPathName()
          Get the VFS local path name.
 String getName()
          Get the simple VF name (X.java)
 VirtualFileHandler getParent()
          Get the parent
 String getPathName()
          Get the VFS relative path name (org/jboss/X.java)
 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.
 InputStream openStream()
          Access the file contents.
 boolean removeChild(String name)
          Remove a child
 void replaceChild(VirtualFileHandler original, VirtualFileHandler replacement)
          Replace child.
 URI toURI()
          Get the VF URI (file://root/org/jboss/X.java)
 URL toURL()
          Get the VF URL (file://root/org/jboss/X.java)
 URL toVfsUrl()
          Get a VFS-based URL
 

Method Detail

getName

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

Returns:
the simple file name

getPathName

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

Returns:
the VFS relative path name

getLocalPathName

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

Returns:
the VFS local path name

toVfsUrl

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

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

getRealURL

URL getRealURL()
               throws IOException,
                      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:
URISyntaxException - for an error parsing the URI
MalformedURLException - for any error constructing the URL
IOException

toURI

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

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

toURL

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

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

getLastModified

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

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

hasBeenModified

boolean hasBeenModified()
                        throws 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:
IOException - for any error

getSize

long getSize()
             throws IOException
Get the size

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

exists

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

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

isLeaf

boolean isLeaf()
               throws 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:
IOException - for any problem accessing the virtual file system
IllegalStateException - if the file is closed

isArchive

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

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

isHidden

boolean isHidden()
                 throws IOException
Whether it is hidden

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

openStream

InputStream openStream()
                       throws IOException
Access the file contents.

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

getParent

VirtualFileHandler getParent()
                             throws IOException
Get the parent

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

getChildren

List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                     throws IOException
Get the children

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

getChild

VirtualFileHandler getChild(String path)
                            throws IOException
Get a child

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

removeChild

boolean removeChild(String name)
                    throws IOException
Remove a child

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

getVFSContext

VFSContext getVFSContext()
Get the VFSContext this file belongs to

Returns:
the context
Throws:
IllegalStateException - if closed

getVirtualFile

VirtualFile getVirtualFile()
Get the virtual file wrapper

Returns:
the wrapper
Throws:
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 IOException
Are we nested in some archive.

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

delete

boolean delete(int gracePeriod)
               throws 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:
IOException - for any error


Copyright © 2010 JBoss, A division of Red Hat, Inc. All Rights Reserved.