org.jboss.virtual.plugins.context.jar
Class AbstractJarHandler

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.jar.AbstractJarHandler
All Implemented Interfaces:
java.io.Serializable, StructuredVirtualFileHandler, VirtualFileHandler
Direct Known Subclasses:
JarHandler, NestedJarHandler, NoCopyNestedJarHandler

public class AbstractJarHandler
extends AbstractURLHandler
implements StructuredVirtualFileHandler

AbstractJarHandler.

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, vfsUrl
 
Constructor Summary
protected AbstractJarHandler(VFSContext context, VirtualFileHandler parent, java.net.URL url, java.lang.String name)
          Create a new JarHandler.
 
Method Summary
protected  VirtualFileHandler buildParents(java.lang.String parentName, java.util.Map<java.lang.String,VirtualFileHandler> parentMap, java.util.jar.JarEntry entry)
          Create any missing parents.
 VirtualFileHandler createChildHandler(java.lang.String name)
          Create a virtual file context
protected  VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent, java.util.jar.JarEntry entry, java.lang.String entryName)
          Create a new virtual file handler
protected  void doClose()
          The real close
 VirtualFileHandler findChild(java.lang.String path)
          Find a child
static java.util.jar.JarFile fromURL(java.net.URL url)
          Convert a URL into a JarFIle
 java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
protected static java.lang.String getEntryName(java.util.jar.JarEntry entry)
          Get a jar entry name
 java.util.jar.JarFile getJar()
          Get the jar.
protected  java.net.URL getURL(VirtualFileHandler parent, java.lang.String path, boolean isDirEntry)
          Create the URL for the entry represented by path.
protected  void initJarFile(java.util.jar.JarFile jarFile)
          Initialise the jar file
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e.
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractURLHandler
getLastModified, getSize, getURL, initCacheLastModified, isHidden, openStream, toURI, toURL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, close, 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

AbstractJarHandler

protected AbstractJarHandler(VFSContext context,
                             VirtualFileHandler parent,
                             java.net.URL url,
                             java.lang.String name)
                      throws java.io.IOException
Create a new JarHandler.

Parameters:
context - the context
parent - the parent
url - the url
name - the name
Throws:
java.io.IOException - for an error accessing the file system
java.lang.IllegalArgumentException - for a null context, url or vfsPath
Method Detail

getEntryName

protected static java.lang.String getEntryName(java.util.jar.JarEntry entry)
Get a jar entry name

Parameters:
entry - the entry
Returns:
the name
Throws:
java.lang.IllegalArgumentException - for a null entry

getJar

public java.util.jar.JarFile getJar()
Get the jar.

Returns:
the jar.

initJarFile

protected void initJarFile(java.util.jar.JarFile jarFile)
                    throws java.io.IOException
Initialise the jar file

Parameters:
jarFile - the jar file
Throws:
java.io.IOException - for any error reading the jar file
java.lang.IllegalArgumentException - for a null jarFile

buildParents

protected VirtualFileHandler buildParents(java.lang.String parentName,
                                          java.util.Map<java.lang.String,VirtualFileHandler> parentMap,
                                          java.util.jar.JarEntry entry)
                                   throws java.io.IOException
Create any missing parents.

Parameters:
parentName - full vfs path name of parent
parentMap - initJarFile parentMap
entry - JarEntry missing a parent
Returns:
the VirtualFileHandler for the parent
Throws:
java.io.IOException

getURL

protected java.net.URL getURL(VirtualFileHandler parent,
                              java.lang.String path,
                              boolean isDirEntry)
                       throws java.net.MalformedURLException
Create the URL for the entry represented by path.

Parameters:
parent - - the parent handler
path - - the simple path to the entry without any trailing '/'
isDirEntry - - whether this is a directory entry
Returns:
the jar entry URL
Throws:
java.net.MalformedURLException

doClose

protected void doClose()
Description copied from class: AbstractVirtualFileHandler
The real close

Overrides:
doClose in class AbstractVirtualFileHandler

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.

getChildren

public java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                               throws java.io.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:
java.io.IOException - for an error accessing the file system

findChild

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

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

createChildHandler

public VirtualFileHandler createChildHandler(java.lang.String name)
                                      throws java.io.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:
java.io.IOException - for any error accessing the virtual file system

createVirtualFileHandler

protected VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent,
                                                      java.util.jar.JarEntry entry,
                                                      java.lang.String entryName)
                                               throws java.io.IOException
Create a new virtual file handler

Parameters:
parent - the parent
entry - the entry
entryName - - the entry name without any trailing '/'
Returns:
the handler
Throws:
java.io.IOException - for any error accessing the file system
java.lang.IllegalArgumentException - for a null parent or entry

fromURL

public static java.util.jar.JarFile fromURL(java.net.URL url)
                                     throws java.io.IOException
Convert a URL into a JarFIle

Parameters:
url - the url to convert
Returns:
the jar file
Throws:
java.io.IOException