org.jboss.virtual.plugins.context
Class DelegatingHandler

java.lang.Object
  extended by org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
      extended by org.jboss.virtual.plugins.context.DelegatingHandler
All Implemented Interfaces:
java.io.Serializable, VirtualFileHandler

public class DelegatingHandler
extends AbstractVirtualFileHandler

A delegating VirtualFileHandler that allows for overriding the delegate parent and name. One usecase is a link which roots another VFSContext under a different parent and name.

Version:
$Revision:$
Author:
Scott.Stark@jboss.org
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log, vfsUrl
 
Constructor Summary
DelegatingHandler(VFSContext context, VirtualFileHandler parent, java.lang.String name, VirtualFileHandler delegate)
          Create a DelegatingHandler
 
Method Summary
 VirtualFileHandler findChild(java.lang.String path)
          Find a child
 java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
 long getLastModified()
          When the file was last modified
 long getSize()
          Get the size
 boolean isHidden()
          Whether it is hidden
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e.
 java.io.InputStream openStream()
          Access the file contents.
 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)
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, close, doClose, equals, getName, getParent, getPathName, getVFSContext, getVirtualFile, hasBeenModified, hashCode, simpleFindChild, structuredFindChild, toString, toVfsUrl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelegatingHandler

public DelegatingHandler(VFSContext context,
                         VirtualFileHandler parent,
                         java.lang.String name,
                         VirtualFileHandler delegate)
Create a DelegatingHandler

Parameters:
context - - the context for the parent
parent - - the parent of the delegate in this VFS
name - - the name of the delegate in this VFS
delegate - - the handler delegate
Method Detail

findChild

public VirtualFileHandler findChild(java.lang.String path)
                             throws java.io.IOException
Description copied from interface: VirtualFileHandler
Find a child

Parameters:
path - the path
Returns:
the child
Throws:
java.io.IOException - for an error accessing the file system (or the child doesn't exist)

getChildren

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

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

getLastModified

public long getLastModified()
                     throws java.io.IOException
Description copied from interface: VirtualFileHandler
When the file was last modified

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

getSize

public long getSize()
             throws java.io.IOException
Description copied from interface: VirtualFileHandler
Get the size

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

isLeaf

public boolean isLeaf()
               throws java.io.IOException
Description copied from interface: VirtualFileHandler
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

isHidden

public boolean isHidden()
                 throws java.io.IOException
Description copied from interface: VirtualFileHandler
Whether it is hidden

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

openStream

public java.io.InputStream openStream()
                               throws java.io.IOException
Description copied from interface: VirtualFileHandler
Access the file contents.

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

toURI

public java.net.URI toURI()
                   throws java.net.URISyntaxException
Description copied from interface: VirtualFileHandler
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

public java.net.URL toURL()
                   throws java.net.URISyntaxException,
                          java.net.MalformedURLException
Description copied from interface: VirtualFileHandler
Get the VF URL (file://root/org/jboss/X.java)

Specified by:
toURL in interface VirtualFileHandler
Overrides:
toURL in class AbstractVirtualFileHandler
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