Previous Table of Contents Next


11.7.5 PackageImport


   A package import is a relationship that allows the use of unqualified names to refer to package members from other namespaces.

Description

   A package import is defined as a directed relationship that identifies a package whose members are to be imported by a namespace.

Generalizations

   • “DirectedRelationship? on page 104

Attributes

   • visibility: VisibilityKind Specifies the visibility of the imported PackageableElements within the importing Namespace, i.e., whether imported elements will in turn be visible to other packages that use that importingPackage as an importedPackage. If the PackageImport is public, the imported elements will be visible outside the package, while if it is private they will not. By default, the value of visibility is public.

Associations Constraints

   [1] The visibility of a PackageImport is either public or private.

   self.visibility = #public or self.visibility = #private

Semantics

   A package import is a relationship between an importing namespace and a package, indicating that the importing namespace adds the names of the members of the package to its own namespace. Conceptually, a package import is equivalent to having an element import to each individual member of the imported namespace, unless there is already a separately-defined element import.

Notation

   A package import is shown using a dashed arrow with an open arrowhead from the importing package to the imported package. A keyword is shown near the dashed arrow to identify which kind of package import that is intended. The predefined keywords are «import» for a public package import, and «access» for a private package import.

Presentation options

   As an alternative to the dashed arrow, it is possible to show an element import by having a text that uniquely identifies the imported element within curly brackets either below or after the name of the namespace. The textual syntax is then:

   ‘{‘import ‘ <qualifiedName> ‘}’ | ‘{access ‘ <qualifiedName> ‘}’

Examples

    In Figure 11.24, a number of package imports are shown. The elements in Types are imported to ShoppingCart, and then further imported WebShop. However, the elements of Auxiliary are only accessed from ShoppingCart, and cannot be referenced using unqualified names from WebShop.

Figure 11.24 - Examples of public and private package imports