Build 1.0_r1(from source)

java.lang
Class Package

java.lang.Object
  extended by java.lang.Package
All Implemented Interfaces:
AnnotatedElement

public class Package
extends Object
implements AnnotatedElement

This class must be implemented by the vm vendor. An instance of class Package contains information about a Java package. This includes implementation and specification versions. Typically this information is retrieved from the manifest.

Packages are managed by class loaders. All classes loaded by the same loader from the same package share a Package instance.

See Also:
ClassLoader

Constructor Summary
Package(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)
           
 
Method Summary
<T extends Annotation>
T
getAnnotation(Class<T> annotationType)
          Gets the annotation associated with the given annotation type and this package.
 Annotation[] getAnnotations()
          Gets all of the annotations associated with this package.
 Annotation[] getDeclaredAnnotations()
          Gets all of the annotations directly declared on this element.
 String getImplementationTitle()
          Return the title of the implementation of this package, or null if this is unknown.
 String getImplementationVendor()
          Return the name of the vendor or organization that provided this implementation of the package, or null if this is unknown.
 String getImplementationVersion()
          Return the version of the implementation of this package, or null if this is unknown.
 String getName()
          Return the name of this package in the standard dot notation; for example: "java.lang".
static Package getPackage(String packageName)
          Attempt to locate the requested package in the caller's class loader.
static Package[] getPackages()
          Return all the packages known to the caller's class loader.
 String getSpecificationTitle()
          Return the title of the specification this package implements, or null if this is unknown.
 String getSpecificationVendor()
          Return the name of the vendor or organization that owns and maintains the specification this package implements, or null if this is unknown.
 String getSpecificationVersion()
          Return the version of the specification this package implements, or null if this is unknown.
 int hashCode()
          Returns an integer hash code for the receiver.
 boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
          Indicates whether or not the given annotation is present.
 boolean isCompatibleWith(String version)
          Return true if this package's specification version is compatible with the specified version string.
 boolean isSealed()
          Return true if this package is sealed, false otherwise.
 boolean isSealed(URL url)
          Return true if this package is sealed with respect to the specified URL, false otherwise.
 String toString()
          Returns a string containing a concise, human-readable description of the receiver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Package

Package(String name,
        String specTitle,
        String specVersion,
        String specVendor,
        String implTitle,
        String implVersion,
        String implVendor,
        URL sealBase)
Method Detail

getAnnotation

public <T extends Annotation> T getAnnotation(Class<T> annotationType)
Gets the annotation associated with the given annotation type and this package.

Specified by:
getAnnotation in interface AnnotatedElement
Parameters:
annotationType - The Class instance of the annotation to search for.
Returns:
An instance of Annotation or null.
Since:
1.5
See Also:
AnnotatedElement.getAnnotation(java.lang.Class)

getAnnotations

public Annotation[] getAnnotations()
Gets all of the annotations associated with this package.

Specified by:
getAnnotations in interface AnnotatedElement
Returns:
An array of Annotation instances, which may be empty.
Since:
1.5
See Also:
AnnotatedElement.getAnnotations()

getDeclaredAnnotations

public Annotation[] getDeclaredAnnotations()
Gets all of the annotations directly declared on this element.

Specified by:
getDeclaredAnnotations in interface AnnotatedElement
Returns:
An array of Annotation instances, which may be empty.
Since:
1.5
See Also:
AnnotatedElement.getDeclaredAnnotations()

isAnnotationPresent

public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
Indicates whether or not the given annotation is present.

Specified by:
isAnnotationPresent in interface AnnotatedElement
Parameters:
annotationType - The class instance of the annotation to search for.
Returns:
A value of true if the annotation is present, otherwise false.
Since:
1.5
See Also:
AnnotatedElement.isAnnotationPresent(java.lang.Class)

getImplementationTitle

public String getImplementationTitle()
Return the title of the implementation of this package, or null if this is unknown. The format of this string is unspecified.

Returns:
The implementation title, or null

getImplementationVendor

public String getImplementationVendor()
Return the name of the vendor or organization that provided this implementation of the package, or null if this is unknown. The format of this string is unspecified.

Returns:
The implementation vendor name, or null

getImplementationVersion

public String getImplementationVersion()
Return the version of the implementation of this package, or null if this is unknown. The format of this string is unspecified.

Returns:
The implementation version, or null

getName

public String getName()
Return the name of this package in the standard dot notation; for example: "java.lang".

Returns:
The name of this package

getPackage

public static Package getPackage(String packageName)
Attempt to locate the requested package in the caller's class loader. If no package information can be located, null is returned.

Parameters:
packageName - The name of the package to find
Returns:
The package requested, or null
See Also:
ClassLoader.getPackage(java.lang.String)

getPackages

public static Package[] getPackages()
Return all the packages known to the caller's class loader.

Returns:
All the packages known to the caller's classloader
See Also:
ClassLoader.getPackages()

getSpecificationTitle

public String getSpecificationTitle()
Return the title of the specification this package implements, or null if this is unknown.

Returns:
The specification title, or null

getSpecificationVendor

public String getSpecificationVendor()
Return the name of the vendor or organization that owns and maintains the specification this package implements, or null if this is unknown.

Returns:
The specification vendor name, or null

getSpecificationVersion

public String getSpecificationVersion()
Return the version of the specification this package implements, or null if this is unknown. The version string is a sequence of non-negative integers separated by dots; for example: "1.2.3".

Returns:
The specification version string, or null

hashCode

public int hashCode()
Returns an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.

Overrides:
hashCode in class Object
Returns:
the receiver's hash
See Also:
Object.equals(java.lang.Object)

isCompatibleWith

public boolean isCompatibleWith(String version)
                         throws NumberFormatException
Return true if this package's specification version is compatible with the specified version string. Version strings are compared by comparing each dot separated part of the version as an integer.

Parameters:
version - The version string to compare against
Returns:
true if the package versions are compatible, false otherwise
Throws:
NumberFormatException - if the package's version string or the one provided is not in the correct format

isSealed

public boolean isSealed()
Return true if this package is sealed, false otherwise.

Returns:
true if this package is sealed, false otherwise

isSealed

public boolean isSealed(URL url)
Return true if this package is sealed with respect to the specified URL, false otherwise.

Parameters:
url - the URL to test
Returns:
true if this package is sealed, false otherwise

toString

public String toString()
Returns a string containing a concise, human-readable description of the receiver.

Overrides:
toString in class Object
Returns:
a printable representation for the receiver.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature