org.xoe.core.packages
Class PackageDescription

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

public class PackageDescription
extends Object
implements IPackageQueryHandler

Encapsulation of an XML package description


Constructor Summary
PackageDescription(org.w3c.dom.Document pkgDoc)
          Builds a PackageDescription out of a DOM Document
PackageDescription(InputStream is)
          Reads an XML file from an InputStream and builds a PackageDescription out of it
 
Method Summary
 void checkCompleteInSet(IPackageQueryHandler qHandler)
          Throws an exception if any packages in the set conflict with this one, or if this package has dependencies that are not met by the set.
 boolean equals(PackageDescription desc)
          Compares objects by their unique identifier strings.
 String getArchitecture()
          Gets the architecture the described package was built for
 IPackageQuery[] getConflicts()
          Returns an array of IPackageQuery objects representing packages that conflict with this one
 Vector getConflictsInSet(IPackageQueryHandler qHandler)
          Returns a vector containing all packages that conflict with this one in the set represented by the specified IPackageQueryHandler
 String getCopyrightHolder()
          Get the copyright holder name listed in the info section of the description.
 String getCopyrightYear()
          Get returns the year that the package was copyrighted
 IPackageQuery[] getDependencies()
          Returns an array of package queries representing packages upon which this one depends
 org.w3c.dom.Document getDocument()
          Get a DOM representation of this package description.
 String getFriendlyName()
          Gets the name listed in the info section of the description.
 String getMaintainerEmail()
          Get the maintainer email listed in the info section of the description.
 String getMaintainerName()
          Get the maintainer name listed in the info section of the description.
 String getName()
          Get the unique name of this package
 String getPackageURI()
          m_arch is null for non-native packages.
static String getPackageURI(String packageName, String arch, String version)
          Determines the package URI for a package with the specified name, architecture (null if non-native), and version
 IPackageQuery[] getPredependencies()
          Returns an array of package queries representing packages upon which this one predepends
static long getQueryTime()
           
 URL getSuggestedURL()
          Returns the first URL listed from which the .xoe archive for this package can be retrieved
 String getTextDescription()
          Return the textual description of this package with no XHTML markup
 Vector getUnmetDependenciesInSet(IPackageQueryHandler qHandler)
          Returns a vector of IPackageQuery objects representing dependencies of this package that were not met in the set of packages represented by the specified IPackageQueryHandler
 IPackageQuery getUpgradeQuery()
          Builds an IPackageQuery object that will exclusively match all packages that are upgrades to this one
 String getVendor()
          Get the vendor name listed in the info section of the description.
 PackageVersion getVersion()
          Get the version of this package
 org.w3c.dom.Element getXHTMLDescription()
          Return the textual description of this package.
 String getXoeFilename()
          Generate the filename for the package based on its name, version and arch.
static String getXoeFilename(String packageName, String arch, String version)
          find out what the name of a package 'packageName', with version 'version', would be (if it were compiled for 'arch').
static PackageDescription newest(PackageDescription p1, PackageDescription p2)
          Return the newer of two packages.
static PackageDescription newest(Vector pkgs)
          Return the newest out of a Vector of PackageDescriptions.
 void performQuery(IPackageQuery in_q, Vector out_res)
          Performs the specified query and adds all matching packages to out_results
static void resetQueryTime()
           
 void setArchitecture(String arch)
          Sets the architecture flag in the package.
 void setSize(long size)
          Add a notation indicating the size of the XOE archive file for this package
 void setSuggestedURL(String url)
          Add an URL from which this package can be retrieved
 String toString()
          A more readable identifier of the package
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PackageDescription

public PackageDescription(org.w3c.dom.Document pkgDoc)
                   throws PackageDescriptionException
Builds a PackageDescription out of a DOM Document
Throws:
PackageDescriptionException - if the Document is not a valid package description

PackageDescription

public PackageDescription(InputStream is)
                   throws IOException,
                          PackageDescriptionException
Reads an XML file from an InputStream and builds a PackageDescription out of it
Throws:
PackageDescriptionException - if the stream does not contain a valid package description
Method Detail

resetQueryTime

public static void resetQueryTime()

getQueryTime

public static long getQueryTime()

getUpgradeQuery

public IPackageQuery getUpgradeQuery()
Builds an IPackageQuery object that will exclusively match all packages that are upgrades to this one

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

getConflictsInSet

public Vector getConflictsInSet(IPackageQueryHandler qHandler)
Returns a vector containing all packages that conflict with this one in the set represented by the specified IPackageQueryHandler

getUnmetDependenciesInSet

public Vector getUnmetDependenciesInSet(IPackageQueryHandler qHandler)
Returns a vector of IPackageQuery objects representing dependencies of this package that were not met in the set of packages represented by the specified IPackageQueryHandler

checkCompleteInSet

public void checkCompleteInSet(IPackageQueryHandler qHandler)
                        throws PackageIncompleteException
Throws an exception if any packages in the set conflict with this one, or if this package has dependencies that are not met by the set. The set is represented by the specified IPackageQueryHandler
Throws:
PackageIncompleteException - Thrown if this package has any conflicts or unmet dependencies in the set.

getConflicts

public IPackageQuery[] getConflicts()
Returns an array of IPackageQuery objects representing packages that conflict with this one

setSuggestedURL

public void setSuggestedURL(String url)
Add an URL from which this package can be retrieved

setSize

public void setSize(long size)
Add a notation indicating the size of the XOE archive file for this package
Parameters:
size - the size, in bytes of the XOE archive file

getPredependencies

public IPackageQuery[] getPredependencies()
Returns an array of package queries representing packages upon which this one predepends

getDependencies

public IPackageQuery[] getDependencies()
Returns an array of package queries representing packages upon which this one depends

getArchitecture

public String getArchitecture()
Gets the architecture the described package was built for

setArchitecture

public void setArchitecture(String arch)
Sets the architecture flag in the package. Should only be used at build time.

getFriendlyName

public String getFriendlyName()
Gets the name listed in the info section of the description. The friendly name is not guaranteed to be unique but has fewer restrictions on legal characters and is usually more verbose. If no friendly name is provided, returns the technical name.

getVendor

public String getVendor()
Get the vendor name listed in the info section of the description.
Returns:
null if no vendor was specified

getMaintainerName

public String getMaintainerName()
Get the maintainer name listed in the info section of the description.
Returns:
null if no maintainer was specified

getMaintainerEmail

public String getMaintainerEmail()
Get the maintainer email listed in the info section of the description.
Returns:
null if no maintainer email was specified

getCopyrightYear

public String getCopyrightYear()
Get returns the year that the package was copyrighted
Returns:
null if no copyright year was specified

getCopyrightHolder

public String getCopyrightHolder()
Get the copyright holder name listed in the info section of the description.
Returns:
null if no copyright holder was specified

getName

public String getName()
Get the unique name of this package

getVersion

public PackageVersion getVersion()
Get the version of this package

getDocument

public org.w3c.dom.Document getDocument()
Get a DOM representation of this package description.

getTextDescription

public String getTextDescription()
Return the textual description of this package with no XHTML markup

getXHTMLDescription

public org.w3c.dom.Element getXHTMLDescription()
Return the textual description of this package. It may contain XHTML markup.

getSuggestedURL

public URL getSuggestedURL()
Returns the first URL listed from which the .xoe archive for this package can be retrieved

toString

public String toString()
A more readable identifier of the package
Overrides:
toString in class Object

getXoeFilename

public String getXoeFilename()
Generate the filename for the package based on its name, version and arch.

getPackageURI

public String getPackageURI()
m_arch is null for non-native packages.

equals

public boolean equals(PackageDescription desc)
Compares objects by their unique identifier strings.

newest

public static PackageDescription newest(PackageDescription p1,
                                        PackageDescription p2)
Return the newer of two packages.

newest

public static PackageDescription newest(Vector pkgs)
Return the newest out of a Vector of PackageDescriptions.

getXoeFilename

public static String getXoeFilename(String packageName,
                                    String arch,
                                    String version)
find out what the name of a package 'packageName', with version 'version', would be (if it were compiled for 'arch'). Arch is ignored for non-native packages.

getPackageURI

public static String getPackageURI(String packageName,
                                   String arch,
                                   String version)
Determines the package URI for a package with the specified name, architecture (null if non-native), and version