org.jboss.virtual.plugins.context
Class AbstractVirtualFileHandler

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

public abstract class AbstractVirtualFileHandler
extends 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 static org.jboss.logging.Logger log
          The log
protected  URL vfsUrl
           
 
Constructor Summary
protected AbstractVirtualFileHandler(VFSContext context, VirtualFileHandler parent, String name)
          Create a new handler
 
Method Summary
protected  void checkClosed()
          Check whether we are closed
 void close()
          Close the resources
protected  int decrement()
          Decrement the reference count
protected  void doClose()
          The real close
 boolean equals(Object obj)
           
 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)
 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()
           
protected  int increment()
          Increment the reference count
 void setPathName(String path)
          todo This is a hack until we can fix http://jira.jboss.com/jira/browse/JBMICROCONT-164
 VirtualFileHandler simpleFindChild(String path)
          Simple implementation of findChild
 VirtualFileHandler structuredFindChild(String path)
          Structured implementation of find child
 String toString()
           
 URL toURL()
          Get the VF URL (file://root/org/jboss/X.java)
 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
exists, findChild, getChildren, getLastModified, getSize, isHidden, isLeaf, openStream, toURI
 

Field Detail

log

protected static final org.jboss.logging.Logger log
The log


vfsUrl

protected URL vfsUrl

cachedLastModified

protected transient long cachedLastModified
Constructor Detail

AbstractVirtualFileHandler

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

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

hasBeenModified

public boolean hasBeenModified()
                        throws 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:
IOException

getName

public 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 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

setPathName

public void setPathName(String path)
todo This is a hack until we can fix http://jira.jboss.com/jira/browse/JBMICROCONT-164

Parameters:
path -

toURL

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

toVfsUrl

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

Specified by:
toVfsUrl in interface VirtualFileHandler
Returns:
the url
Throws:
MalformedURLException
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 IOException
Description copied from interface: VirtualFileHandler
Get the parent

Specified by:
getParent in interface VirtualFileHandler
Returns:
the parent
Throws:
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

increment

protected int increment()
Increment the reference count

Returns:
the resulting count

decrement

protected int decrement()
Decrement the reference count

Returns:
the resulting count

checkClosed

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

Throws:
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(String path)
                                       throws IOException
Structured implementation of find child

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

simpleFindChild

public VirtualFileHandler simpleFindChild(String path)
                                   throws IOException
Simple implementation of findChild

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

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


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