Previous UML Classes Table of Contents UML Packages Next


7.3.37 Package

Kernel


   A package is used to group elements, and provides a namespace for the grouped elements.

*Generalizations

   

    Namespace (from Kernel ) on page 101

   

    PackageableElement (from Kernel ) on page 111

*Description

   A package is a namespace for its members, and may contain other packages. Only packageable elements can be owned members of a package. By virtue of being a namespace, a package can import either individual members of other packages, or all the members of other packages.

   In addition a package can be merged with other packages.

*Attributes

   No additional attributes

*Associations

   Issue 9087 - replace ‘ownedMember’ by ‘packagedElement’ and ‘ownedMember’ by ‘packagedElement’; change redefines to subsets constraint; remove ‘package’ entry

   • /nestedPackage: Package [*] References the owned members that are Packages. Subsets

   Package::packagedElement

   Package::packagedElement

   • packageMerge: Package [*] References the PackageMerge s that are owned by this Package. Subsets

   Element::ownedElement

   • nestingPackage: Package [0..1] References the Package that owns this Package. Subsets

   NamedElement ::namespace

*Constraints

   [1] If an element that is owned by a package has visibility, it is public or private.

   self.ownedElements->forAll(e | e.visibility->notEmpty() implies e.visbility = #public or e.visibility = #private)

*Additional Operations

   [1] The query mustBeOwned() indicates whether elements of this type must have an owner.

   Package::mustBeOwned() : BooleanmustBeOwned = false

   [2] The query visibleMembers() defines which members of a Package can be accessed outside it.

   Package::visibleMembers() : Set(PackageableElement );visibleMembers = member->select( m | self.makesVisible(m))

   [3] The query makesVisible() defines whether a Package makes an element visible outside itself. Elements with no visibility and elements with public visibility are made visible.

   Package::makesVisible(el: Namespace s::NamedElement ) : Boolean;pre: self.member->includes(el)makesVisible =

   -- case: the element is in the package itself (ownedMember->includes(el)) or --case: it is imported individually with public visibility (elementImport->select(ei|ei.importedElement = #public)->collect(ei|ei.importedElement)->includes(el)) or --case: it is imported in a package with public visibility (packageImport->select(pi|pi.visibility = #public)->collect(pi|pi.importedPackage.member->includes(el))->notEmpty())

*Semantics

   A package is a namespace and is also a packageable element that can be contained in other packages.

   The elements that can be referred to using non-qualified names within a package are owned elements, imported elements, and elements in enclosing (outer) namespaces. Owned and imported elements may each have a visibility that determines whether they are available outside the package.

   A package owns its owned members, with the implication that if a package is removed from a model, so are the elements owned by the package.

   The public contents of a package are always accessible outside the package through the use of qualified names.

*Notation

   A package is shown as a large rectangle with a small rectangle (a tab) attached to the left side of the top of the large rectangle. The members of the package may be shown within the large rectangle. Members may also be shown by branching lines to member elements, drawn outside the package. A plus sign (+) within a circle is drawn at the end attached to the namespace (package).

   

   If the members of the package are not shown within the large rectangle, then the name of the package should be placed within the large rectangle.

   

   If the members of the package are shown within the large rectangle, then the name of the package should be placed within the tab.

   The visibility of a package element may be indicated by preceding the name of the element by a visibility symbol (‘+’ for public and ‘-’ for private). Package elements with defined visibility may not have protected or package visibility.

*Presentation Options

   A tool may show visibility by a graphic marker, such as color or font. A tool may also show visibility by selectively displaying those elements that meet a given visibility level (e.g., only public elements). A diagram showing a package with contents must not necessarily show all its contents; it may show a subset of the contained elements according to some criterion.

   Elements that become available for use in an importing package through a package import or an element import may have a distinct color or be dimmed to indicate that they cannot be modified.

*Examples

   There are three representations of the same package T ypes in Figure 7.63. The one on the left just shows the package without revealing any of its members. The middle one shows some of the members within the borders of the package, and the one to the right shows some of the members using the alternative membership notation.

   TypesTypes

   Types

   Integer



   Time


   Shape Point

   Figure 7.63 - Examples of a package with members