org.xoe.core.packages
Class XoePackage

java.lang.Object
  |
  +--org.xoe.core.packages.XoePackage
All Implemented Interfaces:
IPackageQueryHandler

public class XoePackage
extends Object
implements IPackageQueryHandler

Represents a XOE package in memory. Used to access the file archive during installation and to store and retrieve references to runtime components (classloaders, services, resources, etc...).


Constructor Summary
XoePackage(InputStream stream)
          Creates a XoePackage from an InputStream
XoePackage(InputStream stream, String name)
          Creates a XoePackage from an InputStream and specifies the name of the file the stream was created from.
XoePackage(String file)
          Creates a XoePackage from a local file path
XoePackage(URL url)
          Creates a XoePackage from an URL
XoePackage(ZipInputStream stream)
          Creates a XoePackage from a ZipInputStream
XoePackage(ZipInputStream stream, String name)
          Creates a XoePackage from a ZipInputStream and specifies the name of the file the stream was created from.
 
Method Summary
 void forgetArchive()
          Removes all references to the original XOE archive.
 String getArchitecture()
          Get the architecture this package was built for
 PackageDescription getDescription()
          Retrieve the package description that was found in the XOE archive
 Object getExData(Object key)
          Retrieve stored data associated with the specified key
 InputStream getInputStream()
          Same as getZipInputStream but cast to InputStream
 String getName()
          Gets the package name listed in the package description
static XoePackage getPackage(Class c)
          Given a class c return the xoe package which provided it.
 String getPackageURI()
          Gets the package URI built from the name, version, and architecture listed in the package description
 Proviso[] getProvides()
          Retrieves all the provisos listed in the package description
 org.w3c.dom.Document getSpec()
          Get the DOM representation of the package description
 PackageVersion getVersion()
          Gets the package version listed in the package description
 ZipInputStream getZipInputStream()
          Retrieves a ZipInputStream that can be used to access the contents of the XOE archive
 void performQuery(IPackageQuery in_q, Vector out_res)
          Performs the specified query and adds all matching packages to out_results
 void setExData(Object key, Object value)
          Store data associated with the package.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XoePackage

public XoePackage(String file)
           throws InvalidPackageException,
                  IOException
Creates a XoePackage from a local file path
Parameters:
file - a local file path. Behavior is undefined if the path is relative.
Throws:
InvalidPackageException - if the package cannot be parsed or the description is not understood
IOException - if an IO error occurs while accessing the file

XoePackage

public XoePackage(URL url)
           throws InvalidPackageException,
                  IOException
Creates a XoePackage from an URL
Parameters:
url - The URL of a .xoe file
Throws:
InvalidPackageException - if the package cannot be parsed or the description is not understood
IOException - if an IO error occurs while accessing the file

XoePackage

public XoePackage(InputStream stream)
           throws InvalidPackageException,
                  IOException
Creates a XoePackage from an InputStream
Parameters:
stream - An input stream from which to read a ZIP file
Throws:
InvalidPackageException - if the package cannot be parsed or the description is not understood
IOException - if an IO error occurs while accessing the stream

XoePackage

public XoePackage(InputStream stream,
                  String name)
           throws InvalidPackageException,
                  IOException
Creates a XoePackage from an InputStream and specifies the name of the file the stream was created from. The filename is useful if an error occurs while loading the package.
Parameters:
stream - An input stream from which to read a ZIP file
name - A string identifying the resource from which the stream was created.
Throws:
InvalidPackageException - if the package cannot be parsed or the description is not understood
IOException - if an IO error occurs while accessing the stream

XoePackage

public XoePackage(ZipInputStream stream)
           throws InvalidPackageException
Creates a XoePackage from a ZipInputStream
Parameters:
stream - A ZipInputStream from which to access the contents of a ZIP Archive
Throws:
InvalidPackageException - if the package cannot be parsed or the description is not understood
IOException - if an IO error occurs while accessing the stream

XoePackage

public XoePackage(ZipInputStream stream,
                  String name)
Creates a XoePackage from a ZipInputStream and specifies the name of the file the stream was created from. The filename is useful if an error occurs while loading the package.
Parameters:
stream - A ZipInputStream from which to access the contents of a ZIP Archive
name - A string identifying the resource from which the stream was created.
Throws:
InvalidPackageException - if the package cannot be parsed or the description is not understood
IOException - if an IO error occurs while accessing the stream
Method Detail

toString

public String toString()
Overrides:
toString in class Object

setExData

public void setExData(Object key,
                      Object value)
Store data associated with the package. This is most useful to Installer Services that may want to store data at package installation time that is needed at uninstallation time. By publishing the key and value-type used, an Installer Service can store information here for consumption by other software components while the package is installed. If value is null any data already stored with the key is removed.
Parameters:
key - the key to be used for lookup
value - the data to store

getExData

public Object getExData(Object key)
Retrieve stored data associated with the specified key

getDescription

public PackageDescription getDescription()
Retrieve the package description that was found in the XOE archive

getArchitecture

public String getArchitecture()
Get the architecture this package was built for

getSpec

public org.w3c.dom.Document getSpec()
Get the DOM representation of the package description

forgetArchive

public void forgetArchive()
Removes all references to the original XOE archive. Used to free memory after package installation is complete.

getZipInputStream

public ZipInputStream getZipInputStream()
Retrieves a ZipInputStream that can be used to access the contents of the XOE archive

getInputStream

public InputStream getInputStream()
Same as getZipInputStream but cast to InputStream

getName

public String getName()
Gets the package name listed in the package description

getPackageURI

public String getPackageURI()
Gets the package URI built from the name, version, and architecture listed in the package description

getVersion

public PackageVersion getVersion()
Gets the package version listed in the package description

performQuery

public void performQuery(IPackageQuery in_q,
                         Vector out_res)
Description copied from interface: IPackageQueryHandler
Performs the specified query and adds all matching packages to out_results
Specified by:
performQuery in interface IPackageQueryHandler

getProvides

public Proviso[] getProvides()
Retrieves all the provisos listed in the package description

getPackage

public static XoePackage getPackage(Class c)
Given a class c return the xoe package which provided it.