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.jar.NestedJarFromStream
All Implemented Interfaces:
java.io.Serializable, VirtualFileHandler

public class NestedJarFromStream
extends AbstractVirtualFileHandler

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

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

Nested Class Summary
static class NestedJarFromStream.JarEntryContents
           
 
Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log, vfsUrl
 
Constructor Summary
NestedJarFromStream(VFSContext context, VirtualFileHandler parent, java.util.zip.ZipInputStream zis, java.net.URL jarURL, java.util.zip.ZipEntry entry)
          Create a nested jar from the parent zip inputstream/zip entry.
 
Method Summary
 void close()
          Close the resources
 VirtualFileHandler findChild(java.lang.String path)
          Find a child
 java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
 byte[] getContents(java.lang.String name)
           
 java.util.Iterator<NestedJarFromStream.JarEntryContents> getEntries()
           
 NestedJarFromStream.JarEntryContents getEntry(java.lang.String name)
           
 java.util.zip.ZipEntry getJarEntry(java.lang.String name)
           
 long getLastModified()
          When the file was last modified
 java.lang.String getName()
          Get the simple VF name (X.java)
 java.lang.String getPathName()
          Get the VFS relative path name (org/jboss/X.java)
 long getSize()
          Get the size
protected  void init()
           
 boolean isHidden()
          Whether it is hidden
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e.
 java.io.InputStream openStream()
          Access the file contents.
 java.lang.String toString()
           
 java.net.URI toURI()
          Get the VF URI (file://root/org/jboss/X.java)
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, doClose, equals, getParent, getVFSContext, getVirtualFile, hasBeenModified, hashCode, simpleFindChild, structuredFindChild, toURL, 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,
                           java.util.zip.ZipInputStream zis,
                           java.net.URL jarURL,
                           java.util.zip.ZipEntry entry)
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
entry - - the parent jar ZipEntry for the nested jar
Method Detail

findChild

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

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

getChildren

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

Parameters:
ignoreErrors - whether to ignore errors
Returns:
the children
Throws:
java.io.IOException - for an error accessing the file system

isLeaf

public boolean isLeaf()
               throws java.io.IOException
Description copied from interface: VirtualFileHandler
Whether it is a simple leaf of the VFS, i.e. whether it can contain other files

Returns:
true if a simple file.
Throws:
java.io.IOException - for any problem accessing the virtual file system

isHidden

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

Returns:
true if hidden.

getSize

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

Returns:
the size

getLastModified

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

Returns:
the last modified time
Throws:
java.io.IOException - for any problem accessing the virtual file system

getEntries

public java.util.Iterator<NestedJarFromStream.JarEntryContents> getEntries()
                                                                    throws java.io.IOException
Throws:
java.io.IOException

getEntry

public NestedJarFromStream.JarEntryContents getEntry(java.lang.String name)
                                              throws java.io.IOException
Throws:
java.io.IOException

getJarEntry

public java.util.zip.ZipEntry getJarEntry(java.lang.String name)
                                   throws java.io.IOException
Throws:
java.io.IOException

getContents

public byte[] getContents(java.lang.String name)
                   throws java.io.IOException
Throws:
java.io.IOException

getName

public java.lang.String getName()
Description copied from interface: VirtualFileHandler
Get the simple VF name (X.java)

Specified by:
getName in interface VirtualFileHandler
Overrides:
getName in class AbstractVirtualFileHandler
Returns:
the simple file name

getPathName

public java.lang.String getPathName()
Description copied from interface: VirtualFileHandler
Get the VFS relative path name (org/jboss/X.java)

Specified by:
getPathName in interface VirtualFileHandler
Overrides:
getPathName in class AbstractVirtualFileHandler
Returns:
the VFS relative path name

openStream

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

Returns:
An InputStream for the file contents.
Throws:
java.io.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 java.net.URI toURI()
                   throws java.net.URISyntaxException
Description copied from interface: VirtualFileHandler
Get the VF URI (file://root/org/jboss/X.java)

Returns:
the full URI to the VF in the VFS.
Throws:
java.net.URISyntaxException - for an error parsing the URI

toString

public java.lang.String toString()
Overrides:
toString in class AbstractVirtualFileHandler

init

protected void init()
             throws java.io.IOException
Throws:
java.io.IOException