|
|||||||||
| Home >> All >> java >> [ lang overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang
Class Package

java.lang.Objectjava.lang.Package
- All Implemented Interfaces:
- java.lang.reflect.AnnotatedElement
- public class Package
- extends Object
- implements java.lang.reflect.AnnotatedElement
- 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:
- 1.2
| Field Summary | |
private String |
implTitle
The name if the implementation |
private String |
implVendor
The vendor that wrote this implementation |
private String |
implVersion
The version of this implementation |
private ClassLoader |
loader
The class loader that defined this package |
private String |
name
The name of the Package |
private java.net.URL |
sealed
If sealed the origin of the package classes, otherwise null |
private String |
specTitle
The name of the specification |
private String |
specVendor
The name of the specification designer |
private String |
specVersion
The version of this specification |
| Constructor Summary | |
(package private) |
Package(String name,
String specTitle,
String specVendor,
String specVersion,
String implTitle,
String implVendor,
String implVersion,
java.net.URL sealed)
Deprecated. Please use the other constructor that takes the class loader that defines the Package. |
(package private) |
Package(String name,
String specTitle,
String specVendor,
String specVersion,
String implTitle,
String implVendor,
String implVersion,
java.net.URL sealed,
ClassLoader loader)
A package local constructor for the Package class. |
| Method Summary | |
java.lang.annotation.Annotation |
getAnnotation(Class annotationClass)
Returns this package's annotation for the specified annotation type, or null if no such annotation exists. |
java.lang.annotation.Annotation[] |
getAnnotations()
Returns all annotations associated with this package. |
java.lang.annotation.Annotation[] |
getDeclaredAnnotations()
Returns all annotations directly defined by this package. |
String |
getImplementationTitle()
Returns the name of the implementation, or null if unknown. |
String |
getImplementationVendor()
Returns the vendor that wrote this implementation, or null if unknown. |
String |
getImplementationVersion()
Returns the version of this implementation, or null if unknown. |
String |
getName()
Returns the Package name in dot-notation. |
static Package |
getPackage(String name)
Returns the named package if it is known by the callers class loader. |
static Package[] |
getPackages()
Returns all the packages that are known to the callers class loader. |
String |
getSpecificationTitle()
Returns the name of the specification, or null if unknown. |
String |
getSpecificationVendor()
Returns the name of the specification designer, or null if unknown. |
String |
getSpecificationVersion()
Returns the version of the specification, or null if unknown. |
int |
hashCode()
Returns the hashCode of the name of this package. |
boolean |
isAnnotationPresent(Class annotationClass)
Returns true if an annotation for the specified type is associated with this package. |
boolean |
isCompatibleWith(String version)
Checks if the version of the specification is higher or at least as high as the desired version. |
boolean |
isSealed()
Returns true if this Package is sealed. |
boolean |
isSealed(java.net.URL url)
Returns true if this Package is sealed and the origin of the classes is the given URL. |
String |
toString()
Returns a string representation of this package. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
name
private final String name
- The name of the Package
implTitle
private final String implTitle
- The name if the implementation
implVendor
private final String implVendor
- The vendor that wrote this implementation
implVersion
private final String implVersion
- The version of this implementation
specTitle
private final String specTitle
- The name of the specification
specVendor
private final String specVendor
- The name of the specification designer
specVersion
private final String specVersion
- The version of this specification
sealed
private final java.net.URL sealed
- If sealed the origin of the package classes, otherwise null
loader
private ClassLoader loader
- The class loader that defined this package
| Constructor Detail |
Package
Package(String name, String specTitle, String specVendor, String specVersion, String implTitle, String implVendor, String implVersion, java.net.URL sealed)
- Deprecated. Please use the other constructor that takes the class loader
that defines the Package.
Package
Package(String name, String specTitle, String specVendor, String specVersion, String implTitle, String implVendor, String implVersion, java.net.URL sealed, ClassLoader loader)
- A package local constructor for the Package class. All parameters except
the
nameof the package may benull. There are no public constructors defined for Package; this is a package local constructor that is used by java.lang.Classloader.definePackage().
| Method Detail |
getName
public String getName()
- Returns the Package name in dot-notation.
getSpecificationTitle
public String getSpecificationTitle()
- Returns the name of the specification, or null if unknown.
getSpecificationVersion
public String getSpecificationVersion()
- Returns the version of the specification, or null if unknown.
getSpecificationVendor
public String getSpecificationVendor()
- Returns the name of the specification designer, or null if unknown.
getImplementationTitle
public String getImplementationTitle()
- Returns the name of the implementation, or null if unknown.
getImplementationVersion
public String getImplementationVersion()
- Returns the version of this implementation, or null if unknown.
getImplementationVendor
public String getImplementationVendor()
- Returns the vendor that wrote this implementation, or null if unknown.
isSealed
public boolean isSealed()
- Returns true if this Package is sealed.
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.
isCompatibleWith
public boolean isCompatibleWith(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.
getPackage
public static Package getPackage(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.
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.
hashCode
public int hashCode()
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()).
getAnnotation
public java.lang.annotation.Annotation getAnnotation(Class annotationClass)
- Returns this package's annotation for the specified annotation type,
or
nullif no such annotation exists.- Specified by:
getAnnotationin interfacejava.lang.reflect.AnnotatedElement
- Since:
- 1.5
getAnnotations
public java.lang.annotation.Annotation[] getAnnotations()
- Returns all annotations associated with this package. If there are
no annotations associated with this package, then a zero-length array
will be returned. The returned array may be modified by the client
code, but this will have no effect on the annotation content of this
package, and hence no effect on the return value of this method for
future callers.
- Specified by:
getAnnotationsin interfacejava.lang.reflect.AnnotatedElement
- Since:
- 1.5
getDeclaredAnnotations
public java.lang.annotation.Annotation[] getDeclaredAnnotations()
- Returns all annotations directly defined by this package. If there are
no annotations associated with this package, then a zero-length array
will be returned. The returned array may be modified by the client
code, but this will have no effect on the annotation content of this
package, and hence no effect on the return value of this method for
future callers.
- Specified by:
getDeclaredAnnotationsin interfacejava.lang.reflect.AnnotatedElement
- Since:
- 1.5
isAnnotationPresent
public boolean isAnnotationPresent(Class annotationClass)
- Returns true if an annotation for the specified type is associated
with this package. This is primarily a short-hand for using marker
annotations.
- Specified by:
isAnnotationPresentin interfacejava.lang.reflect.AnnotatedElement
- Since:
- 1.5
|
|||||||||
| Home >> All >> java >> [ lang overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
java.lang.Package