edu.rice.cs.cunit.subAnnot
Class PackageEx

java.lang.Object
  extended by edu.rice.cs.cunit.subAnnot.AAnnotatedElementEx
      extended by edu.rice.cs.cunit.subAnnot.PackageEx
All Implemented Interfaces:
AnnotatedElementEx

public class PackageEx
extends AAnnotatedElementEx

Extended Package class to support annotations with subclassing.

Author:
Mathias Ricken

Field Summary
 java.lang.Package java
          The java.lang.reflect.Package object that represents the package.
 
Fields inherited from class edu.rice.cs.cunit.subAnnot.AAnnotatedElementEx
_ai, _classFileNotFound, _classLoader, _classPath
 
Constructor Summary
PackageEx(java.lang.Package p)
          Create an extended Package instance for the specified package.
PackageEx(java.lang.Package p, java.lang.ClassLoader c)
          Create an extended Package instance for the specified package.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares this Constructor against the specified object.
protected  java.lang.reflect.AnnotatedElement getAnnotatedElement()
          Return the annotated element.
 java.lang.String getImplementationTitle()
          Return the title of this package.
 java.lang.String getImplementationVendor()
          Returns the name of the organization, vendor or company that provided this implementation.
 java.lang.String getImplementationVersion()
          Return the version of this implementation.
 java.lang.String getName()
          Return the name of this package.
static PackageEx getPackage(java.lang.String s)
          Return an extended Package instance for the class with the specified package name.
static PackageEx[] getPackages()
          Return an array of all extended Package instances known to the caller's ClassLoader instance.
 java.lang.String getSpecificationTitle()
          Return the title of the specification that this package implements.
 java.lang.String getSpecificationVendor()
          Return the name of the organization, vendor, or company that owns and maintains the specification of the classes that implement this package.
 java.lang.String getSpecificationVersion()
          Returns the version number of the specification that this package implements.
 int hashCode()
          Return the hash code computed from the package name.
 boolean isCompatibleWith(java.lang.String desired)
          Compare this package's specification version with a desired version.
 boolean isSealed()
          Returns true if this package is sealed.
 boolean isSealed(java.net.URL url)
          Returns true if this package is sealed with respect to the specified code source url.
 java.lang.String toString()
          Returns the string representation of this Package.
 
Methods inherited from class edu.rice.cs.cunit.subAnnot.AAnnotatedElementEx
findMethodAnnotationsAttributeInfo, getAnnotations, getAnnotations, getAnnotations, getClassLoader, getDeclaredAnnotations, getDeclaredAnnotations, getDeclaredAnnotations, getLocalVarAnnotationsAttributeInfo, getParameterAnnotationsAttributeInfo, isAnnotationPresent, isAnnotationPresent, isAvailable, isDeclaredAnnotationPresent, isDeclaredAnnotationPresent, setClassFileNotFound
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

java

public final java.lang.Package java
The java.lang.reflect.Package object that represents the package.

Constructor Detail

PackageEx

public PackageEx(java.lang.Package p)
Create an extended Package instance for the specified package.

Parameters:
p - package

PackageEx

public PackageEx(java.lang.Package p,
                 java.lang.ClassLoader c)
Create an extended Package instance for the specified package.

Parameters:
p - package
c - class loader
Method Detail

getPackage

public static PackageEx getPackage(java.lang.String s)
Return an extended Package instance for the class with the specified package name.

Parameters:
s - package name
Returns:
package

getPackages

public static PackageEx[] getPackages()
Return an array of all extended Package instances known to the caller's ClassLoader instance.

Returns:
array of packages

getAnnotatedElement

protected java.lang.reflect.AnnotatedElement getAnnotatedElement()
Return the annotated element.

Specified by:
getAnnotatedElement in class AAnnotatedElementEx
Returns:
annotated element

getName

public java.lang.String getName()
Return the name of this package.

Returns:
The name of this package using the Java language dot notation for the package. i.e java.lang

getSpecificationTitle

public java.lang.String getSpecificationTitle()
Return the title of the specification that this package implements.

Returns:
the specification title, null is returned if it is not known.

getSpecificationVersion

public java.lang.String getSpecificationVersion()
Returns the version number of the specification that this package implements. This version string must be a sequence of positive decimal integers separated by "."'s and may have leading zeros. When version strings are compared the most significant numbers are compared.

Returns:
the specification version, null is returned if it is not known.

getSpecificationVendor

public java.lang.String getSpecificationVendor()
Return the name of the organization, vendor, or company that owns and maintains the specification of the classes that implement this package.

Returns:
the specification vendor, null is returned if it is not known.

getImplementationTitle

public java.lang.String getImplementationTitle()
Return the title of this package.

Returns:
the title of the implementation, null is returned if it is not known.

getImplementationVersion

public java.lang.String getImplementationVersion()
Return the version of this implementation. It consists of any string assigned by the vendor of this implementation and does not have any particular syntax specified or expected by the Java runtime. It may be compared for equality with other package version strings used for this implementation by this vendor for this package.

Returns:
the version of the implementation, null is returned if it is not known.

getImplementationVendor

public java.lang.String getImplementationVendor()
Returns the name of the organization, vendor or company that provided this implementation.

Returns:
the vendor that implemented this package..

isSealed

public boolean isSealed()
Returns true if this package is sealed.

Returns:
true if the package is sealed, false otherwise

isSealed

public boolean isSealed(java.net.URL url)
Returns true if this package is sealed with respect to the specified code source url.

Parameters:
url - the code source url
Returns:
true if this package is sealed with respect to url

isCompatibleWith

public boolean isCompatibleWith(java.lang.String desired)
                         throws java.lang.NumberFormatException
Compare this package's specification version with a desired version. It returns true if this packages specification version number is greater than or equal to the desired version number.

Version numbers are compared by sequentially comparing corresponding components of the desired and specification strings. Each component is converted as a decimal integer and the values compared. If the specification value is greater than the desired value true is returned. If the value is less false is returned. If the values are equal the period is skipped and the next pair of components is compared.

Parameters:
desired - the version string of the desired version.
Returns:
true if this package's version number is greater than or equal to the desired version number
Throws:
java.lang.NumberFormatException - if the desired or current version is not of the correct dotted form.

hashCode

public int hashCode()
Return the hash code computed from the package name.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code computed from the package name.

toString

public java.lang.String toString()
Returns the string representation of this Package. Its value is the string "package " and the package name. If the package title is defined it is appended. If the package version is defined it is appended.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of the package.

equals

public boolean equals(java.lang.Object obj)
Compares this Constructor against the specified object. Returns true if the objects are the same. Two Constructor objects are the same if they were declared by the same class and have the same formal parameter types.

Overrides:
equals in class java.lang.Object