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, ByteArrayHandler, DelegatingHandler

public abstract class AbstractVirtualFileHandler
extends Object
implements VirtualFileHandler

AbstractVirtualFileHandler.

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

Field Summary
protected  long cachedLastModified
          The cached last modified
protected static org.jboss.logging.Logger log
          The log
 
Constructor Summary
protected AbstractVirtualFileHandler(VFSContext context, VirtualFileHandler parent, String name)
          Create a new handler
 
Method Summary
protected  void checkClosed()
          Check whether we are closed
protected  void checkParentExists()
          Check if parent exists.
 void close()
          Close the resources
protected  int decrement()
          Decrement the reference count
protected  void doClose()
          The real close
 boolean equals(Object obj)
           
protected  String getChildPathName(String childPath, boolean isDirectory)
          Get child path name.
protected  URL getChildVfsUrl(String childPath, boolean isDirectory)
          Get child url.
 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
protected  URL getVfsUrl()
          Get VFS url.
 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
protected  void setVfsUrl(URL vfsUrl)
          Set the vfs URL.
 VirtualFileHandler simpleFindChild(String path)
          Simple implementation of findChild
 VirtualFileHandler structuredFindChild(String path)
          Structured implementation of get 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, getChild, getChildren, getLastModified, getSize, isHidden, isLeaf, openStream, toURI
 

Field Detail

log

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


cachedLastModified

protected transient long cachedLastModified
The cached last modified

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

checkParentExists

protected void checkParentExists()
Check if parent exists.


getChildVfsUrl

protected URL getChildVfsUrl(String childPath,
                             boolean isDirectory)
                      throws IOException,
                             URISyntaxException
Get child url.

Parameters:
childPath - the child path
isDirectory - is directory
Returns:
full child URL
Throws:
IOException - for any io error
URISyntaxException - for any uri error

getChildPathName

protected String getChildPathName(String childPath,
                                  boolean isDirectory)
                           throws IOException
Get child path name.

Parameters:
childPath - the child path
isDirectory - is directory
Returns:
full child URL
Throws:
IOException - for any io error

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:
true if modified, false otherwise
Throws:
IOException - for any error

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 - for any error
URISyntaxException - for an error parsing the URI

getVfsUrl

protected URL getVfsUrl()
Get VFS url.

Returns:
vfs url

setVfsUrl

protected void setVfsUrl(URL vfsUrl)
Set the vfs URL.

Parameters:
vfsUrl - vfs url

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 get child

Parameters:
path - the path
Returns:
the handler or null if it doesn't exist
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 © 2008 JBoss, A division of Red Hat, Inc. All Rights Reserved.