1 *java.lang.Package* *Package* Package objects contain version information
5 extends |java.lang.Object|
6 implements |java.lang.reflect.AnnotatedElement|
8 |java.lang.Package_Description|
9 |java.lang.Package_Fields|
10 |java.lang.Package_Constructors|
11 |java.lang.Package_Methods|
13 ================================================================================
15 *java.lang.Package_Methods*
16 |java.lang.Package.getAnnotation(Class<A>)|
17 |java.lang.Package.getAnnotations()|
18 |java.lang.Package.getDeclaredAnnotations()|
19 |java.lang.Package.getImplementationTitle()|Return the title of this package.
20 |java.lang.Package.getImplementationVendor()|Returns the name of the organizati
21 |java.lang.Package.getImplementationVersion()|Return the version of this implem
22 |java.lang.Package.getName()|Return the name of this package.
23 |java.lang.Package.getPackage(String)|Find a package by name in the callers Cla
24 |java.lang.Package.getPackages()|Get all the packages currently known for the c
25 |java.lang.Package.getSpecificationTitle()|Return the title of the specificatio
26 |java.lang.Package.getSpecificationVendor()|Return the name of the organization
27 |java.lang.Package.getSpecificationVersion()|Returns the version number of the
28 |java.lang.Package.hashCode()|Return the hash code computed from the package na
29 |java.lang.Package.isAnnotationPresent(Class<?extendsAnnotation>)|
30 |java.lang.Package.isCompatibleWith(String)|Compare this package's specificatio
31 |java.lang.Package.isSealed()|Returns true if this package is sealed.
32 |java.lang.Package.isSealed(URL)|Returns true if this package is sealed with re
33 |java.lang.Package.toString()|Returns the string representation of this Package
35 *java.lang.Package_Description*
37 Package objects contain version information about the implementation and
38 specification of a Java package. This versioning information is retrieved and
39 made available by the <code>ClassLoader</code>(|java.lang.ClassLoader|)
40 instance that loaded the class(es). Typically, it is stored in the manifest
41 that is distributed with the classes.
43 The set of classes that make up the package may implement a particular
44 specification and if so the specification title, version number, and vendor
45 strings identify that specification. An application can ask if the package is
46 compatible with a particular version, see the
47 <code>isCompatibleWith</code>(|java.lang.Package|) method for details.
49 Specification version numbers use a syntax that consists of positive decimal
50 integers separated by periods ".", for example "2.0" or "1.2.3.4.5.6.7". This
51 allows an extensible number to be used to represent major, minor, micro, etc.
52 versions. The version specification is described by the following formal
55 SpecificationVersion: Digits RefinedVersionopt
57 RefinedVersion: . Digits . Digits RefinedVersion
61 Digit: any character for which (|java.lang.Character|) returns true, e.g. 0, 1,
66 The implementation title, version, and vendor strings identify an
67 implementation and are made available conveniently to enable accurate reporting
68 of the packages involved when a problem occurs. The contents all three
69 implementation strings are vendor specific. The implementation version strings
70 have no specified syntax and should only be compared for equality with desired
73 Within each ClassLoader instance all classes from the same java package have
74 the same Package object. The static methods allow a package to be found by name
75 or the set of all packages known to the current class loader to be found.
79 *java.lang.Package.getAnnotation(Class<A>)*
81 public |A| getAnnotation(java.lang.Class<A> annotationClass)
87 *java.lang.Package.getAnnotations()*
89 public |java.lang.annotation.Annotation|[] getAnnotations()
95 *java.lang.Package.getDeclaredAnnotations()*
97 public |java.lang.annotation.Annotation|[] getDeclaredAnnotations()
103 *java.lang.Package.getImplementationTitle()*
105 public |java.lang.String| getImplementationTitle()
107 Return the title of this package.
111 Returns: the title of the implementation, null is returned if it is not known.
113 *java.lang.Package.getImplementationVendor()*
115 public |java.lang.String| getImplementationVendor()
117 Returns the name of the organization, vendor or company that provided this
122 Returns: the vendor that implemented this package..
124 *java.lang.Package.getImplementationVersion()*
126 public |java.lang.String| getImplementationVersion()
128 Return the version of this implementation. It consists of any string assigned
129 by the vendor of this implementation and does not have any particular syntax
130 specified or expected by the Java runtime. It may be compared for equality with
131 other package version strings used for this implementation by this vendor for
136 Returns: the version of the implementation, null is returned if it is not known.
138 *java.lang.Package.getName()*
140 public |java.lang.String| getName()
142 Return the name of this package.
146 Returns: The fully-qualified name of this package as defined in the Java Language
147 Specification, Third Edition
149 6.5.3, for example, java.lang
151 *java.lang.Package.getPackage(String)*
153 public static |java.lang.Package| getPackage(java.lang.String name)
155 Find a package by name in the callers ClassLoader instance. The callers
156 ClassLoader instance is used to find the package instance corresponding to the
157 named class. If the callers ClassLoader instance is null then the set of
158 packages loaded by the system ClassLoader instance is searched to find the
161 Packages have attributes for versions and specifications only if the class
162 loader created the package instance with the appropriate attributes. Typically,
163 those attributes are defined in the manifests that accompany the classes.
166 name - a package name, for example, java.lang.
168 Returns: the package of the requested name. It may be null if no package information is
169 available from the archive or codebase.
171 *java.lang.Package.getPackages()*
173 public static |java.lang.Package|[] getPackages()
175 Get all the packages currently known for the caller's ClassLoader instance.
176 Those packages correspond to classes loaded via or accessible by name to that
177 ClassLoader instance. If the caller's ClassLoader instance is the bootstrap
178 ClassLoader instance, which may be represented by null in some implementations,
179 only packages corresponding to classes loaded by the bootstrap ClassLoader
180 instance will be returned.
184 Returns: a new array of packages known to the callers ClassLoader instance. An zero
185 length array is returned if none are known.
187 *java.lang.Package.getSpecificationTitle()*
189 public |java.lang.String| getSpecificationTitle()
191 Return the title of the specification that this package implements.
195 Returns: the specification title, null is returned if it is not known.
197 *java.lang.Package.getSpecificationVendor()*
199 public |java.lang.String| getSpecificationVendor()
201 Return the name of the organization, vendor, or company that owns and maintains
202 the specification of the classes that implement this package.
206 Returns: the specification vendor, null is returned if it is not known.
208 *java.lang.Package.getSpecificationVersion()*
210 public |java.lang.String| getSpecificationVersion()
212 Returns the version number of the specification that this package implements.
213 This version string must be a sequence of positive decimal integers separated
214 by "."'s and may have leading zeros. When version strings are compared the most
215 significant numbers are compared.
219 Returns: the specification version, null is returned if it is not known.
221 *java.lang.Package.hashCode()*
223 public int hashCode()
225 Return the hash code computed from the package name.
229 Returns: the hash code computed from the package name.
231 *java.lang.Package.isAnnotationPresent(Class<?extendsAnnotation>)*
233 public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
239 *java.lang.Package.isCompatibleWith(String)*
241 public boolean isCompatibleWith(java.lang.String desired)
242 throws |java.lang.NumberFormatException|
244 Compare this package's specification version with a desired version. It returns
245 true if this packages specification version number is greater than or equal to
246 the desired version number.
248 Version numbers are compared by sequentially comparing corresponding components
249 of the desired and specification strings. Each component is converted as a
250 decimal integer and the values compared. If the specification value is greater
251 than the desired value true is returned. If the value is less false is
252 returned. If the values are equal the period is skipped and the next pair of
253 components is compared.
256 desired - the version string of the desired version.
258 Returns: true if this package's version number is greater than or equal to the desired
261 *java.lang.Package.isSealed()*
263 public boolean isSealed()
265 Returns true if this package is sealed.
269 Returns: true if the package is sealed, false otherwise
271 *java.lang.Package.isSealed(URL)*
273 public boolean isSealed(java.net.URL url)
275 Returns true if this package is sealed with respect to the specified code
279 url - the code source url
281 Returns: true if this package is sealed with respect to url
283 *java.lang.Package.toString()*
285 public |java.lang.String| toString()
287 Returns the string representation of this Package. Its value is the string
288 "package " and the package name. If the package title is defined it is
289 appended. If the package version is defined it is appended.
293 Returns: the string representation of the package.