Prev Next

Namespaces

Languages such as Java support Package structures or namespaces. In Enterprise Architect you can specify a Package as a namespace root, which denotes where the namespace structure for your Class model starts; all subordinate Packages below a namespace root will form the namespace hierarchy for contained Classes and Interfaces.

To define a Package as a namespace root, click on the Package in the Project Browser and select the  'Code > Configure > Options > Set as Namespace Root' ribbon option. The Package icon in the Project Browser changes to show a colored corner indicating this Package is a namespace root.

Generated Java source code, for example, will automatically add a Package declaration at the beginning of the generated file, indicating the location of the Class in the Package hierarchy below the namespace root.

To clear an existing namespace root, click on the namespace root Package in the Project Browser and deselect the 'Code > Configure > Options > Set as Namespace Root' ribbon option

To view a list of namespaces, select the 'Configure > Reference Data > Settings > Namespace Roots' ribbon option; the 'Namespaces' dialog displays. If you double-click on a namespace in the list, the Package is highlighted in the Project Browser; alternatively, right-click on the namespace and select the 'Locate Package in Browser' option. 

You can also clear the selected namespace root by selecting the 'Clear Namespace Attribute' option.

To omit a subordinate Package from a namespace definition, select the  'Code > Configure > Options > Suppress Namespace' ribbon option; to include the Package in the namespace again, deselect the ribbon option.

Notes

  • When performing code generation, any Package name that contains whitespace characters is automatically treated as a namespace root