org.jboss.virtual.plugins.context.file
Class FileHandler

java.lang.Object
  extended by org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
      extended by org.jboss.virtual.plugins.context.AbstractURLHandler
          extended by org.jboss.virtual.plugins.context.file.FileHandler
All Implemented Interfaces:
Serializable, StructuredVirtualFileHandler, VirtualFileHandler

public class FileHandler
extends AbstractURLHandler
implements StructuredVirtualFileHandler

FileHandler.

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Scott.Stark@jboss.org
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log
 
Constructor Summary
FileHandler(FileSystemContext context, VirtualFileHandler parent, File file, URI uri)
          Create a new FileHandler
FileHandler(FileSystemContext context, VirtualFileHandler parent, File file, URL url)
          Create a new FileHandler.
 
Method Summary
 VirtualFileHandler createChildHandler(String name)
          Create a virtual file context
 VirtualFileHandler getChild(String path)
          Get a child
 List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
protected  File getFile()
          Get the file for this file handler
 long getLastModified()
          When the file was last modified
 long getSize()
          Get the size
 FileSystemContext getVFSContext()
          Get the VFSContext this file belongs to
 boolean isHidden()
          Whether it is hidden
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e. whether it can contain other files
 URL toVfsUrl()
          Get a VFS-based URL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractURLHandler
exists, getURL, initCacheLastModified, openStream, toURI, toURL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, checkParentExists, close, decrement, doClose, equals, getChildPathName, getChildVfsUrl, getName, getParent, getPathName, getVfsUrl, getVirtualFile, hasBeenModified, hashCode, increment, setPathName, setVfsUrl, simpleFindChild, structuredFindChild, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileHandler

public FileHandler(FileSystemContext context,
                   VirtualFileHandler parent,
                   File file,
                   URL url)
            throws IOException
Create a new FileHandler.

Parameters:
context - the context
parent - the parent
file - the file
url - the url
Throws:
IOException - for an error accessing the file system
IllegalArgumentException - for a null context, url

FileHandler

public FileHandler(FileSystemContext context,
                   VirtualFileHandler parent,
                   File file,
                   URI uri)
            throws IOException
Create a new FileHandler

Parameters:
context - the context
parent - the parent
file - the file
uri - the uri
Throws:
IOException - for an error accessing the file system
IllegalArgumentException - for a null context, uri
Method Detail

toVfsUrl

public URL toVfsUrl()
             throws MalformedURLException,
                    URISyntaxException
Description copied from interface: VirtualFileHandler
Get a VFS-based URL

Specified by:
toVfsUrl in interface VirtualFileHandler
Overrides:
toVfsUrl in class AbstractVirtualFileHandler
Returns:
the url
Throws:
MalformedURLException - for any error
URISyntaxException - for an error parsing the URI

getVFSContext

public FileSystemContext getVFSContext()
Description copied from interface: VirtualFileHandler
Get the VFSContext this file belongs to

Specified by:
getVFSContext in interface VirtualFileHandler
Overrides:
getVFSContext in class AbstractVirtualFileHandler
Returns:
the context

getFile

protected File getFile()
Get the file for this file handler

Returns:
the file

getLastModified

public long getLastModified()
Description copied from interface: VirtualFileHandler
When the file was last modified

Specified by:
getLastModified in interface VirtualFileHandler
Overrides:
getLastModified in class AbstractURLHandler
Returns:
the last modified time

getSize

public long getSize()
Description copied from interface: VirtualFileHandler
Get the size

Specified by:
getSize in interface VirtualFileHandler
Overrides:
getSize in class AbstractURLHandler
Returns:
the size

isLeaf

public boolean isLeaf()
Description copied from interface: VirtualFileHandler
Whether it is a simple leaf of the VFS, i.e. whether it can contain other files

Specified by:
isLeaf in interface VirtualFileHandler
Returns:
true if a simple file.

isHidden

public boolean isHidden()
Description copied from interface: VirtualFileHandler
Whether it is hidden

Specified by:
isHidden in interface VirtualFileHandler
Overrides:
isHidden in class AbstractURLHandler
Returns:
true if hidden.

getChildren

public List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                     throws IOException
Description copied from interface: VirtualFileHandler
Get the children

Specified by:
getChildren in interface VirtualFileHandler
Parameters:
ignoreErrors - whether to ignore errors
Returns:
the children
Throws:
IOException - for an error accessing the file system

createChildHandler

public VirtualFileHandler createChildHandler(String name)
                                      throws IOException
Description copied from interface: StructuredVirtualFileHandler
Create a virtual file context

Specified by:
createChildHandler in interface StructuredVirtualFileHandler
Parameters:
name - the name
Returns:
the handler
Throws:
IOException - for any error accessing the virtual file system

getChild

public VirtualFileHandler getChild(String path)
                            throws IOException
Description copied from interface: VirtualFileHandler
Get a child

Specified by:
getChild in interface VirtualFileHandler
Parameters:
path - the path
Returns:
the child or null if not found
Throws:
IOException - for an error accessing the file system


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