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:
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, URL url, String name)
          Create a new JarHandler.
 
Method Summary
protected  VirtualFileHandler buildParents(String parentName, Map<String,VirtualFileHandler> parentMap, JarEntry entry)
          Create any missing parents.
 VirtualFileHandler createChildHandler(String name)
          Create a virtual file context
protected  VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent, JarEntry entry, String entryName)
          Create a new virtual file handler
protected  void doClose()
          The real close
 VirtualFileHandler findChild(String path)
          Find a child
static JarFile fromURL(URL url)
          Convert a URL into a JarFIle
 List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
protected static String getEntryName(JarEntry entry)
          Get a jar entry name
 JarFile getJar()
          Get the jar.
protected  URL getURL(VirtualFileHandler parent, String path, boolean isDirEntry)
          Create the URL for the entry represented by path.
protected  void initJarFile(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
exists, getLastModified, getSize, getURL, initCacheLastModified, isHidden, openStream, toURI, toURL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, close, decrement, equals, getName, getParent, getPathName, getVFSContext, getVirtualFile, hasBeenModified, hashCode, increment, setPathName, 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,
                             URL url,
                             String name)
                      throws IOException
Create a new JarHandler.

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

getEntryName

protected static String getEntryName(JarEntry entry)
Get a jar entry name

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

getJar

public JarFile getJar()
Get the jar.

Returns:
the jar.

initJarFile

protected void initJarFile(JarFile jarFile)
                    throws IOException
Initialise the jar file

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

buildParents

protected VirtualFileHandler buildParents(String parentName,
                                          Map<String,VirtualFileHandler> parentMap,
                                          JarEntry entry)
                                   throws 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:
IOException

getURL

protected URL getURL(VirtualFileHandler parent,
                     String path,
                     boolean isDirEntry)
              throws 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:
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 List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                     throws 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:
IOException - for an error accessing the file system

findChild

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

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

createChildHandler

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

createVirtualFileHandler

protected VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent,
                                                      JarEntry entry,
                                                      String entryName)
                                               throws 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:
IOException - for any error accessing the file system
IllegalArgumentException - for a null parent or entry

fromURL

public static JarFile fromURL(URL url)
                       throws IOException
Convert a URL into a JarFIle

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


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