org.jboss.virtual.plugins.context
Class AbstractVirtualFileHandler

java.lang.Object
  extended by org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
All Implemented Interfaces:
java.io.Serializable, VirtualFileHandler
Direct Known Subclasses:
AbstractURIHandler, AbstractURLHandler, DelegatingHandler, NestedJarFromStream, NestedJarFromStream.JarEntryContents

public abstract class AbstractVirtualFileHandler
extends java.lang.Object
implements VirtualFileHandler

AbstractVirtualFileHandler.

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

Field Summary
protected  long cachedLastModified
           
protected  org.jboss.logging.Logger log
          The log
protected  java.net.URL vfsUrl
           
 
Constructor Summary
protected AbstractVirtualFileHandler(VFSContext context, VirtualFileHandler parent, java.lang.String name)
          Create a new handler
 
Method Summary
protected  void checkClosed()
          Check whether we are closed
 void close()
          Close the resources
protected  void doClose()
          The real close
 boolean equals(java.lang.Object obj)
           
 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)
 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.
 int hashCode()
           
 VirtualFileHandler simpleFindChild(java.lang.String path)
          Simple implementation of findChild
 VirtualFileHandler structuredFindChild(java.lang.String path)
          Structured implementation of find child
 java.lang.String toString()
           
 java.net.URL toURL()
          Get the VF URL (file://root/org/jboss/X.java)
 java.net.URL toVfsUrl()
          Get a VFS-based URL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.virtual.spi.VirtualFileHandler
findChild, getChildren, getLastModified, getSize, isHidden, isLeaf, openStream, toURI
 

Field Detail

log

protected org.jboss.logging.Logger log
The log


vfsUrl

protected java.net.URL vfsUrl

cachedLastModified

protected transient long cachedLastModified
Constructor Detail

AbstractVirtualFileHandler

protected AbstractVirtualFileHandler(VFSContext context,
                                     VirtualFileHandler parent,
                                     java.lang.String name)
Create a new handler

Parameters:
context - the context
parent - the parent
name - the name
Throws:
java.lang.IllegalArgumentException - if the context or name is null;
Method Detail

hasBeenModified

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

Specified by:
hasBeenModified in interface VirtualFileHandler
Returns:
Throws:
java.io.IOException

getName

public java.lang.String getName()
Description copied from interface: VirtualFileHandler
Get the simple VF name (X.java)

Specified by:
getName in interface VirtualFileHandler
Returns:
the simple file name

getPathName

public java.lang.String getPathName()
Description copied from interface: VirtualFileHandler
Get the VFS relative path name (org/jboss/X.java)

Specified by:
getPathName in interface VirtualFileHandler
Returns:
the VFS relative path name

toURL

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

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

toVfsUrl

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

Specified by:
toVfsUrl in interface VirtualFileHandler
Returns:
the url
Throws:
java.net.MalformedURLException
java.net.URISyntaxException

getVirtualFile

public VirtualFile getVirtualFile()
Description copied from interface: VirtualFileHandler
Get the virtual file wrapper

Specified by:
getVirtualFile in interface VirtualFileHandler
Returns:
the wrapper

getParent

public VirtualFileHandler getParent()
                             throws java.io.IOException
Description copied from interface: VirtualFileHandler
Get the parent

Specified by:
getParent in interface VirtualFileHandler
Returns:
the parent
Throws:
java.io.IOException - for an error accessing the file system

getVFSContext

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

Specified by:
getVFSContext in interface VirtualFileHandler
Returns:
the context

checkClosed

protected void checkClosed()
                    throws java.lang.IllegalStateException
Check whether we are closed

Throws:
java.lang.IllegalStateException - when closed

close

public void close()
Description copied from interface: VirtualFileHandler
Close the resources

Specified by:
close in interface VirtualFileHandler

doClose

protected void doClose()
The real close


structuredFindChild

public VirtualFileHandler structuredFindChild(java.lang.String path)
                                       throws java.io.IOException
Structured implementation of find child

Parameters:
path - the path
Returns:
the handler
Throws:
java.io.IOException - for any error accessing the virtual file system
java.lang.IllegalArgumentException - for a null name

simpleFindChild

public VirtualFileHandler simpleFindChild(java.lang.String path)
                                   throws java.io.IOException
Simple implementation of findChild

Parameters:
path - the path
Returns:
the handler
Throws:
java.io.IOException - for any error accessing the virtual file system
java.lang.IllegalArgumentException - for a null name

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object