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

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
              extended by org.jboss.virtual.plugins.context.jar.AbstractStructuredJarHandler<byte[]>
                  extended by org.jboss.virtual.plugins.context.jar.NestedJarFromStream
All Implemented Interfaces:
Serializable, StructuredVirtualFileHandler, VirtualFileHandler

public class NestedJarFromStream
extends AbstractStructuredJarHandler<byte[]>

A nested jar implementation used to represent a jar within a jar.

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

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log
 
Constructor Summary
NestedJarFromStream(VFSContext context, VirtualFileHandler parent, ZipInputStream zis, URL jarURL, JarFile jar, ZipEntry entry, String entryName)
          Create a nested jar from the parent zip inputstream/zip entry.
 
Method Summary
 void close()
          Close the resources
 VirtualFileHandler createChildHandler(String name)
          Create a virtual file context
protected  VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent, org.jboss.virtual.plugins.context.jar.ZipEntryWrapper<byte[]> wrapper, String entryName)
          Create a new virtual file handler
 boolean exists()
          TODO: removing the entry/jar that resulted in this needs to be detected.
protected  void extraWrapperInfo(org.jboss.virtual.plugins.context.jar.ZipEntryWrapper<byte[]> wrapper)
          Handle additional information about wrapper.
 VirtualFileHandler getChild(String path)
          Get a child
 List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
 long getLastModified()
          When the file was last modified
 long getSize()
          Get the size
protected  void init()
          Initialize entries.
protected  void initCacheLastModified()
           
protected  void initJarFile()
          Initialise the jar file
 boolean isHidden()
          Whether it is hidden
 InputStream openStream()
          Access the file contents.
 String toString()
           
 URI toURI()
          Get the VF URI (file://root/org/jboss/X.java)
 
Methods inherited from class org.jboss.virtual.plugins.context.jar.AbstractStructuredJarHandler
buildParents, createSynthenticParent, initJarFile
 
Methods inherited from class org.jboss.virtual.plugins.context.jar.AbstractJarHandler
fromURL, getEntry, getJar, getURL, handleJarFile, isLeaf
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractURLHandler
getURL, toURL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, checkParentExists, decrement, doClose, equals, getChildPathName, getChildVfsUrl, getName, getParent, getPathName, getVFSContext, getVfsUrl, getVirtualFile, hasBeenModified, hashCode, increment, setPathName, setVfsUrl, simpleFindChild, structuredFindChild, toVfsUrl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NestedJarFromStream

public NestedJarFromStream(VFSContext context,
                           VirtualFileHandler parent,
                           ZipInputStream zis,
                           URL jarURL,
                           JarFile jar,
                           ZipEntry entry,
                           String entryName)
                    throws IOException
Create a nested jar from the parent zip inputstream/zip entry.

Parameters:
context - - the context containing the jar
parent - - the jar handler for this nested jar
zis - - the jar zip input stream
jarURL - - the URL to use as the jar URL
jar - - the parent jar file for the nested jar
entry - - the zip entry
entryName - - the entry name
Throws:
IOException - for any error
Method Detail

initCacheLastModified

protected void initCacheLastModified()
Overrides:
initCacheLastModified in class AbstractURLHandler

init

protected void init()
             throws IOException
Initialize entries.

Throws:
IOException - for any error

getChildren

public List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                     throws IOException
Description copied from interface: VirtualFileHandler
Get the children

Specified by:
getChildren in interface VirtualFileHandler
Overrides:
getChildren in class AbstractStructuredJarHandler<byte[]>
Parameters:
ignoreErrors - whether to ignore errors
Returns:
the children
Throws:
IOException - for an error accessing the file system

getChild

public VirtualFileHandler getChild(String path)
                            throws IOException
Description copied from interface: VirtualFileHandler
Get a child

Specified by:
getChild in interface VirtualFileHandler
Overrides:
getChild in class AbstractStructuredJarHandler<byte[]>
Parameters:
path - the path
Returns:
the child or null if not found
Throws:
IOException - for an error accessing the file system

createChildHandler

public VirtualFileHandler createChildHandler(String name)
                                      throws IOException
Description copied from interface: StructuredVirtualFileHandler
Create a virtual file context

Specified by:
createChildHandler in interface StructuredVirtualFileHandler
Overrides:
createChildHandler in class AbstractStructuredJarHandler<byte[]>
Parameters:
name - the name
Returns:
the handler
Throws:
IOException - for any error accessing the virtual file system

extraWrapperInfo

protected void extraWrapperInfo(org.jboss.virtual.plugins.context.jar.ZipEntryWrapper<byte[]> wrapper)
                         throws IOException
Description copied from class: AbstractStructuredJarHandler
Handle additional information about wrapper.

Overrides:
extraWrapperInfo in class AbstractStructuredJarHandler<byte[]>
Parameters:
wrapper - the zip entry wrapper
Throws:
IOException - for any error

createVirtualFileHandler

protected VirtualFileHandler createVirtualFileHandler(VirtualFileHandler parent,
                                                      org.jboss.virtual.plugins.context.jar.ZipEntryWrapper<byte[]> wrapper,
                                                      String entryName)
                                               throws IOException
Description copied from class: AbstractStructuredJarHandler
Create a new virtual file handler

Overrides:
createVirtualFileHandler in class AbstractStructuredJarHandler<byte[]>
Parameters:
parent - the parent
wrapper - the entry wrapper
entryName - - the entry name without any trailing '/'
Returns:
the handler
Throws:
IOException - for any error accessing the file system

exists

public boolean exists()
               throws IOException
TODO: removing the entry/jar that resulted in this needs to be detected.

Specified by:
exists in interface VirtualFileHandler
Overrides:
exists in class AbstractURLHandler
Returns:
true if the file exists, false otherwise.
Throws:
IOException - - thrown on failure to detect existence.
See Also:
URLConnection.getLastModified(), org.jboss.test.virtual.test.URLExistsUnitTestCase

isHidden

public boolean isHidden()
Description copied from interface: VirtualFileHandler
Whether it is hidden

Specified by:
isHidden in interface VirtualFileHandler
Overrides:
isHidden in class AbstractURLHandler
Returns:
true if hidden.

getSize

public long getSize()
Description copied from interface: VirtualFileHandler
Get the size

Specified by:
getSize in interface VirtualFileHandler
Overrides:
getSize in class AbstractURLHandler
Returns:
the size

getLastModified

public long getLastModified()
                     throws IOException
Description copied from interface: VirtualFileHandler
When the file was last modified

Specified by:
getLastModified in interface VirtualFileHandler
Overrides:
getLastModified in class AbstractURLHandler
Returns:
the last modified time
Throws:
IOException - for any problem accessing the virtual file system

openStream

public InputStream openStream()
                       throws IOException
Description copied from interface: VirtualFileHandler
Access the file contents.

Specified by:
openStream in interface VirtualFileHandler
Overrides:
openStream in class AbstractURLHandler
Returns:
An InputStream for the file contents.
Throws:
IOException - for any problem accessing the virtual file system

close

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

Specified by:
close in interface VirtualFileHandler
Overrides:
close in class AbstractVirtualFileHandler

toURI

public URI toURI()
          throws URISyntaxException
Description copied from interface: VirtualFileHandler
Get the VF URI (file://root/org/jboss/X.java)

Specified by:
toURI in interface VirtualFileHandler
Overrides:
toURI in class AbstractURLHandler
Returns:
the full URI to the VF in the VFS.
Throws:
URISyntaxException - for an error parsing the URI

toString

public String toString()
Overrides:
toString in class AbstractVirtualFileHandler

initJarFile

protected void initJarFile()
                    throws IOException
Description copied from class: AbstractStructuredJarHandler
Initialise the jar file

Overrides:
initJarFile in class AbstractStructuredJarHandler<byte[]>
Throws:
IOException - for any error reading the jar file


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