Structure
EPackage
A package in the Ecore metamodel.
struct EPackage
Overview
EPackage is a container for classifiers (classes, data types, enums) and provides a namespace for metamodel elements. Packages are the top-level organisational unit in Ecore, similar to packages in Java or modules in Swift.
Each package has:
-
Namespace URI (nsURI): Unique identifier for the package across systems
-
Namespace Prefix (nsPrefix): Short prefix used in XML serialisation
-
Classifiers: The types (classes, data types, enums) defined in this package
-
Subpackages: Nested packages for hierarchical organisation
Example
let companyPackage = EPackage(
name: "company",
nsURI: "http://example.org/company",
nsPrefix: "company",
classifiers: [
EClass(name: "Employee"),
EClass(name: "Department")
]
)
// Look up a classifier
if let employee = companyPackage.getClassifier("Employee") as? EClass {
print("Found class: \(employee.name)")
}
Namespace URIs
The namespace URI uniquely identifies the package across different systems and versions. By convention, it uses a reverse domain name format:
-
http://www.eclipse.org/emf/2002/Ecore- The Ecore metamodel itself -
http://example.org/mymodel- Custom metamodel
XML Namespace Prefixes
The namespace prefix is used in XMI serialisation to abbreviate element names:
<company:Employee xmlns:company="http://example.org/company" name="Alice"/>
Topics
Operators
Compares two packages for equality.
Initializers
Creates a new package.
Initialise an EPackage from a DynamicEObject (without resource context).
Loads an EPackage from a .ecore file.
Instance Properties
Annotations attached to this package.
The metaclass describing this package.
The classifiers (types) defined in this package.
The factory instance for creating objects of this package’s classes.
Nested subpackages within this package.
Unique identifier for this package.
The name of this package.
The namespace prefix for this package.
The namespace URI for this package.
Instance Methods
Reflectively retrieves the value of a feature.
Checks whether a feature has been explicitly set.
Reflectively sets the value of a feature.
Unsets a feature, returning it to its default value.
Retrieves a classifier by its name.
Retrieves a class by its name.
Retrieves a data type by its name.
Retrieves an enumeration by its name.
Retrieves a subpackage by its name.
Hashes the essential components of this package.
Type Aliases
The type of classifier for this package.
Default Implementations
Relationships
Conforms To
See Also
Core Types
Base protocol for all Ecore model elements.
A dynamic implementation of EObject that stores feature values generically.
A class in the Ecore metamodel.