Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.lang

Class Package

java.lang.Object
|
+--java.lang.Package


public class Package

extends Object

Everything you ever wanted to know about a package. This class makes it possible to attach specification and implementation information to a package as explained in the Package Versioning Specification section of the Product Versioning Specification. It also allows packages to be sealed with respect to the originating URL.

The most useful method is the isCompatibleWith() method that compares a desired version of a specification with the version of the specification as implemented by a package. A package is considered compatible with another version if the version of the specification is equal or higher then the requested version. Version numbers are represented as strings of positive numbers separated by dots (e.g. "1.2.0"). The first number is called the major number, the second the minor, the third the micro, etc. A version is considered higher then another version if it has a bigger major number then the another version or when the major numbers of the versions are equal if it has a bigger minor number then the other version, etc. (If a version has no minor, micro, etc numbers then they are considered the be 0.)

Since:Author:See Also:

Method Summary

java.lang.StringgetImplementationTitle()

Returns the name of the implementation, or null if unknown.
java.lang.StringgetImplementationVendor()

Returns the vendor that wrote this implementation, or null if unknown.
java.lang.StringgetImplementationVersion()

Returns the version of this implementation, or null if unknown.
java.lang.StringgetName()

Returns the Package name in dot-notation.
static java.lang.PackagegetPackage(java.lang.String name)

Returns the named package if it is known by the callers class loader.
static java.lang.Package[]getPackages()

Returns all the packages that are known to the callers class loader.
java.lang.StringgetSpecificationTitle()

Returns the name of the specification, or null if unknown.
java.lang.StringgetSpecificationVendor()

Returns the name of the specification designer, or null if unknown.
java.lang.StringgetSpecificationVersion()

Returns the version of the specification, or null if unknown.
inthashCode()

Returns the hashCode of the name of this package.
booleanisCompatibleWith(java.lang.String version)

Checks if the version of the specification is higher or at least as high as the desired version.
booleanisSealed()

Returns true if this Package is sealed.
booleanisSealed(java.net.URL url)

Returns true if this Package is sealed and the origin of the classes is the given URL.
java.lang.StringtoString()

Returns a string representation of this package.

Method Details

getImplementationTitle

public String getImplementationTitle()

Returns the name of the implementation, or null if unknown.

Returns:


getImplementationVendor

public String getImplementationVendor()

Returns the vendor that wrote this implementation, or null if unknown.

Returns:


getImplementationVersion

public String getImplementationVersion()

Returns the version of this implementation, or null if unknown.

Returns:


getName

public String getName()

Returns the Package name in dot-notation.

Returns:


getPackage

public static Package getPackage(java.lang.String name)

Returns the named package if it is known by the callers class loader. It may return null if the package is unknown, when there is no information on that particular package available or when the callers classloader is null.

Parameters:

Returns:


getPackages

public static Package[] getPackages()

Returns all the packages that are known to the callers class loader. It may return an empty array if the classloader of the caller is null.

Returns:


getSpecificationTitle

public String getSpecificationTitle()

Returns the name of the specification, or null if unknown.

Returns:


getSpecificationVendor

public String getSpecificationVendor()

Returns the name of the specification designer, or null if unknown.

Returns:


getSpecificationVersion

public String getSpecificationVersion()

Returns the version of the specification, or null if unknown.

Returns:


hashCode

public int hashCode()

Returns the hashCode of the name of this package.

Returns:


isCompatibleWith

public boolean isCompatibleWith(java.lang.String version)

Checks if the version of the specification is higher or at least as high as the desired version. Comparison is done by sequentially comparing dotted decimal numbers from the parameter and from getSpecificationVersion.

Parameters:

Throws:


isSealed

public boolean isSealed()

Returns true if this Package is sealed.

Returns:


isSealed

public boolean isSealed(java.net.URL url)

Returns true if this Package is sealed and the origin of the classes is the given URL.

Parameters:

Returns:

Throws:


toString

public String toString()

Returns a string representation of this package. It is specified to be "package " + getName() + (getSpecificationTitle() == null ? "" : ", " + getSpecificationTitle()) + (getSpecificationVersion() == null ? "" : ", version " + getSpecificationVersion()).

Returns: