Section 24.98. JavaPackage: JavaScript representation of a Java package


24.98. JavaPackage: JavaScript representation of a Java package

LiveConnect

24.98.1. Synopsis

 package.package_name  // Refers to another JavaPackage package.class_name    // Refers to a JavaClass object 

24.98.2. Properties

The properties of a JavaPackage object are the names of the JavaPackage objects and JavaClass objects that it contains. These properties are different for each individual JavaPackage. Note that it is not possible to use the JavaScript for/in loop to iterate over the list of property names of a Package object. Consult a Java reference manual to determine the packages and classes contained within any given package.

24.98.3. Description

The JavaPackage object is a JavaScript representation of a Java package. A package in Java is a collection of related classes. In JavaScript, a JavaPackage can contain classes (represented by the JavaClass object) and other JavaPackage objects.

The global object has a JavaPackage property named java that represents the java.* package hierarchy. This JavaPackage object defines properties that refer to other JavaPackage objects. For example, java.lang and java.net refer to the java.lang and java.net packages. The java.awt JavaPackage contains properties named Frame and Button, which are references to JavaClass objects and represent the classes java.awt.Frame and java.awt.Button.

The global object also defines a property named Packages, which is the root JavaPackage whose properties refer to the roots of all known package hierarchies. For example, the expression Packages.javax.swing refers to the Java package javax.swing.

It is not possible to use the for/in loop to determine the names of the packages and classes contained within a JavaPackage. You must have this information in advance. You can find it in any Java reference manual or by examining the Java class hierarchy.

See Chapter 12 for further details on working with Java packages, classes, and objects.

24.98.4. See Also

java, JavaArray, JavaClass, JavaObject, Packages; Chapter 12




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net