org.knopflerfish.framework.bundlestorage.file
Class Archive

java.lang.Object
  extended by org.knopflerfish.framework.bundlestorage.file.Archive
All Implemented Interfaces:
FileArchive

public class Archive
extends java.lang.Object
implements FileArchive

JAR file handling.


Constructor Summary
Archive(java.io.File dir, int rev, java.io.InputStream is, java.net.URL source, java.lang.String location, boolean checkSigned)
          Create an Archive based on contents of an InputStream, the archive is saved as local copy in the specified directory.
 
Method Summary
 java.util.Enumeration findResourcesPath(java.lang.String path)
           
 java.lang.String getAttribute(java.lang.String key)
          Get an attribute from the manifest of the archive.
 byte[] getClassBytes(java.lang.String classFile)
          Get a byte array containg the contents of named class file from the archive.
 java.io.InputStream getInputStream(java.lang.String component)
          Get an InputStream to named entry inside an Archive.
 java.util.jar.Manifest getManifest()
          Get manifest for this archive.
 FileArchive getSubArchive(java.lang.String path)
          Get an Archive handle to a named Jar file within this archive.
 void removeCertificates()
           
 void saveCertificates()
           
 java.lang.String toString()
          Show file name for archive, if zip show if it is sub archive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Archive

public Archive(java.io.File dir,
               int rev,
               java.io.InputStream is,
               java.net.URL source,
               java.lang.String location,
               boolean checkSigned)
        throws java.io.IOException,
               BundleException
Create an Archive based on contents of an InputStream, the archive is saved as local copy in the specified directory.

Parameters:
storage - BundleStorageImpl for this archive.
dir - Directory to save data in.
rev - Revision of bundle content (used for updates).
is - Jar file data in an InputStream.
url - URL to use to CodeSource.
location - Location for archive
checkSigned - Check signed bundles
Throws:
java.io.IOException
BundleException
Method Detail

toString

public java.lang.String toString()
Show file name for archive, if zip show if it is sub archive.

Overrides:
toString in class java.lang.Object
Returns:
A string with result.

getAttribute

public java.lang.String getAttribute(java.lang.String key)
Get an attribute from the manifest of the archive.

Specified by:
getAttribute in interface FileArchive
Parameters:
key - Name of attribute to get.
Returns:
A string with result or null if the entry doesn't exists.

getClassBytes

public byte[] getClassBytes(java.lang.String classFile)
                     throws java.io.IOException
Get a byte array containg the contents of named class file from the archive.

Specified by:
getClassBytes in interface FileArchive
Parameters:
Class - File to get.
Returns:
Byte array with contents of class file or null if file doesn't exist.
Throws:
java.io.IOException - if failed to read jar entry.

findResourcesPath

public java.util.Enumeration findResourcesPath(java.lang.String path)
Specified by:
findResourcesPath in interface FileArchive

getSubArchive

public FileArchive getSubArchive(java.lang.String path)
                          throws java.io.IOException
Get an Archive handle to a named Jar file within this archive.

Specified by:
getSubArchive in interface FileArchive
Parameters:
path - Name of Jar file to get.
Returns:
An Archive object representing new archive.
Throws:
java.io.FileNotFoundException - if no such Jar file in archive.
java.io.IOException - if failed to read Jar file.

getInputStream

public java.io.InputStream getInputStream(java.lang.String component)
Description copied from interface: FileArchive
Get an InputStream to named entry inside an Archive.

Specified by:
getInputStream in interface FileArchive
Parameters:
component - Entry to get reference to.
Returns:
InputStream to entry or null if it doesn't exist.

getManifest

public java.util.jar.Manifest getManifest()
Description copied from interface: FileArchive
Get manifest for this archive.

Specified by:
getManifest in interface FileArchive
Returns:
A Manifest object representing the manifest.

saveCertificates

public void saveCertificates()
                      throws java.io.IOException
Throws:
java.io.IOException

removeCertificates

public void removeCertificates()