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 Browser window and select the 'Develop > Source Code > Options > Set as Namespace Root' ribbon option. The Package icon in the Browser window 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 Browser window and deselect the 'Develop > Source Code > Options > Set as Namespace Root' ribbon option
To view a list of namespaces, select the 'Settings > 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 Browser window; 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 'Develop > Source Code > 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