public interface Model
Model
holds MDWObject
instances.
A model can be:
read(String, String)
write(String, String)
getInstances(String)
This interface is not intended to be implemented by clients.
Modifier and Type | Method and Description |
---|---|
void |
add(MDWObject object)
Register this model element to the model.
|
void |
applyMetamodelExtensions(Collection<MetamodelExtension> extensions)
Applies the specified metamodel extensions on this model.
|
void |
clear()
Clears the contents of this model.
|
<T extends MDWObject> |
create(EClass type)
Creates a new instance of a
MDWObject based on the specified type. |
<T extends MDWObject> |
create(String typeName)
Creates a new instance of a
MDWObject based on the specified type. |
Collection<MetamodelExtension> |
getApplicableMetamodelExtensions()
Returns all metamodel extensions that can be applied on this model.
|
Collection<MetamodelExtension> |
getAppliedMetamodelExtensions()
Returns the metamodel extensions currently applied on this model.
|
DiagramImage |
getDiagram(MDWObject object,
DiagramOptions options)
Get the diagram image for a specific model element.
|
<T extends MDWObject> |
getInstances()
Returns all model elements attached to this model.
|
<T extends MDWObject> |
getInstances(EClass type)
Returns all model elements of the specified type attached to this model.
|
<T extends MDWObject> |
getInstances(EClass type,
boolean includeSubTypes)
Returns all model elements of the specified type, or one of its sub types, attached to this model.
|
<T extends MDWObject> |
getInstances(String typeName)
Returns all model elements of the specified type attached to this model.
|
<T extends MDWObject> |
getInstances(String typeName,
boolean includeSubTypes)
Returns all model elements of the specified type, or one of its sub types, attached to this model.
|
Metamodel |
getMetamodel()
Returns the metamodel this model is based on.
|
<T extends MDWObject> |
getProfiledInstances(EClass type,
String profileName)
Returns model elements of the specified type attached to this model, which match the specified profile name.
|
<T extends MDWObject> |
getProfiledInstances(EClass type,
String profileName,
boolean includeSubTypes)
Returns all model elements of the specified type, or one of its sub types, attached to this model,
which match the specified profile name.
|
<T extends MDWObject> |
getProfiledInstances(String typeName,
String profileName)
Returns model elements of the specified type attached to this model, which match the specified profile name.
|
<T extends MDWObject> |
getProfiledInstances(String typeName,
String profileName,
boolean includeSubTypes)
Returns all model elements of the specified type, or one of its sub types, attached to this model,
which match the specified profile name.
|
ConnectorDescriptor |
getReader()
Returns the last connector used to read this model.
|
String |
getReadURI()
Returns the last uri used to read this model.
|
ConnectorDescriptor |
getWriter()
Returns the last connector used to write this model.
|
String |
getWriteURI()
Returns the last uri used to write this model.
|
void |
read(String readerName,
String uri)
Clear this model and then populates its contents using the specified connector information.
|
void |
read(String readerName,
String uri,
Map<String,?> options)
Clear this model and then populates its contents using the specified connector information.
|
void |
remove(MDWObject object)
Unregister this model element from the model.
|
void |
write(String writerName,
String uri)
Writes the model contents using the specified connector information.
|
void |
write(String writerName,
String uri,
Map<String,?> options)
Writes the model contents using the specified connector information.
|
Metamodel getMetamodel()
Collection<MetamodelExtension> getAppliedMetamodelExtensions()
Collection<MetamodelExtension> getApplicableMetamodelExtensions()
void applyMetamodelExtensions(Collection<MetamodelExtension> extensions)
extensions
- the metamodel extensions to apply on the model.void read(String readerName, String uri) throws CoreException
The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector
should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific
resource locator, including null
when the connector does not expect any uri.
readerName
- the connector name to be used.uri
- an additional resource locator used by the connector to read the model (can be null
)CoreException
- if the model could not be loaded. Reasons include:
Metamodel.getModelReaderDescriptors()
,
ConnectorDescriptor.getKind()
void read(String readerName, String uri, Map<String,?> options) throws CoreException
The reader name must match a connector registered on the related metamodel. The uri is used to locate a resource from where the connector
should read information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific
resource locator, including null
when the connector does not expect any uri.
readerName
- the connector name to be used.uri
- an additional resource locator used by the connector to read the model (can be null
)options
- properties to configure the model reader.CoreException
- if the model could not be loaded. Reasons include:
Metamodel.getModelReaderDescriptors()
,
ConnectorDescriptor.getKind()
ConnectorDescriptor getReader()
null
if the model has never been loaded from a resource.String getReadURI()
null
if the model has never been loaded from a resource or if the uri used was
null
.void write(String writerName, String uri) throws CoreException
The writer name must match a connector registered on the related metamodel. The uri is used to locate a resource where the connector should
write information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource
locator, including null
when the connector does not expect any uri.
writerName
- the connector name to be used.uri
- an additional resource locator used by the connector to write the model (can be null
)CoreException
- if the model could not be written. Reasons include:
Metamodel.getModelWriterDescriptors()
,
ConnectorDescriptor.getKind()
void write(String writerName, String uri, Map<String,?> options) throws CoreException
The writer name must match a connector registered on the related metamodel. The uri is used to locate a resource where the connector should
write information. If the connector expects a file, the uri must be a valid file path. Otherwise, it can be any connector specific resource
locator, including null
when the connector does not expect any uri.
writerName
- the connector name to be used.uri
- an additional resource locator used by the connector to write the model (can be null
)options
- properties to configure the model writer.CoreException
- if the model could not be written. Reasons include:
Metamodel.getModelWriterDescriptors()
,
ConnectorDescriptor.getKind()
ConnectorDescriptor getWriter()
null
if the model has never been written to a resource.String getWriteURI()
null
if the model has never been written to a resource or if the uri used was
null
.<T extends MDWObject> MDWList<T> getInstances()
The returned list is a MDWList
so you can directly invoke scripts on the model elements. This list has no predictable order.
T
- the type of the instance to retrieve.MDWObject
contained in this model.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
<T extends MDWObject> MDWList<T> getInstances(String typeName)
The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class"
for example), or a simple name (
"Class"
), if this name is unique in the metamodel.
The returned list is a MDWList
so you can directly invoke scripts on the model elements. These elements are ordered the way they
were created and added to this model.
T
- the type of the instance to retrieve.typeName
- the type name of model elements to retrieve.MDWObject
contained in this model that matches the specified type.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getInstances(String, boolean)
<T extends MDWObject> MDWList<T> getInstances(String typeName, boolean includeSubTypes)
The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Classifier"
for example), or a simple name
("Classifier"
), if this name is unique in the metamodel.
The returned list is a MDWList
so you can directly invoke scripts on the model elements. This list has no predictable order.
T
- the type of the instance to retrieve.typeName
- the type name of model elements to retrieve.includeSubTypes
- determines whether to retrieve elements based on sub types.MDWObject
contained in this model that matches the specified type, or one of its sub types.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getInstances(String)
<T extends MDWObject> MDWList<T> getInstances(EClass type)
The returned list is a MDWList
so you can directly invoke scripts on the model elements. These elements are ordered the way they
were created and added to this model.
T
- the type of the instance to retrieve.type
- the type of model elements to retrieve.MDWObject
contained in this model that matches the specified type.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getInstances(EClass, boolean)
<T extends MDWObject> MDWList<T> getInstances(EClass type, boolean includeSubTypes)
The returned list is a MDWList
so you can directly invoke scripts on the model elements. This list has no predictable order.
T
- the type of the instance to retrieve.type
- the type of model elements to retrieve.includeSubTypes
- determines whether to retrieve elements based on sub types.MDWObject
contained in this model that matches the specified type, or one of its sub types.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getInstances(String)
<T extends MDWObject> MDWList<T> getProfiledInstances(String typeName, String profileName)
The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class"
for example), or a simple name (
"Class"
), if this name is unique in the metamodel.
The returned list is a MDWList
so you can directly invoke scripts on the model elements. These elements are ordered the way they
were created and added to this model.
T
- the type of the instance to retrieve.typeName
- the type name of model elements to retrieve.profileName
- the name of the profile type the instances must match.MDWObject
contained in this model that matches the specified type.InvalidCallException
- if this API is not called during an MDWorkbench evaluation.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getProfiledInstances(String, String, boolean)
<T extends MDWObject> MDWList<T> getProfiledInstances(String typeName, String profileName, boolean includeSubTypes)
The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Classifier"
for example), or a simple name
("Classifier"
), if this name is unique in the metamodel.
The returned list is a MDWList
so you can directly invoke scripts on the model elements. This list has no predictable order.
T
- the type of the instance to retrieve.typeName
- the type name of model elements to retrieve.profileName
- the name of the profile type the instances must match.includeSubTypes
- determines whether to retrieve elements based on sub types.MDWObject
contained in this model that matches the specified type, or one of its sub types.InvalidCallException
- if this API is not called during an MDWorkbench evaluation.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getProfiledInstances(String, String)
<T extends MDWObject> MDWList<T> getProfiledInstances(EClass type, String profileName)
The returned list is a MDWList
so you can directly invoke scripts on the model elements. These elements are ordered the way they
were created and added to this model.
T
- the type of the instance to retrieve.type
- the type of model elements to retrieve.profileName
- the name of the profile type the instances must match.MDWObject
contained in this model that matches the specified type.InvalidCallException
- if this API is not called during an MDWorkbench evaluation.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getProfiledInstances(EClass, String, boolean)
<T extends MDWObject> MDWList<T> getProfiledInstances(EClass type, String profileName, boolean includeSubTypes)
The returned list is a MDWList
so you can directly invoke scripts on the model elements. This list has no predictable order.
T
- the type of the instance to retrieve.type
- the type of model elements to retrieve.profileName
- the name of the profile type the instances must match.includeSubTypes
- determines whether to retrieve elements based on sub types.MDWObject
contained in this model that matches the specified type, or one of its sub types.InvalidCallException
- if this API is not called during an MDWorkbench evaluation.UnsupportedOperationException
- if this method is not supported by a particular model implementationMDWObject
,
getProfiledInstances(EClass, String)
<T extends MDWObject> T create(String typeName)
MDWObject
based on the specified type.
The created element is automatically registered to this model, there's no need to call the add(MDWObject)
method.
The specified type name can be a fully qualified class ("com.sodius.mdw.metamodel.uml21.Class"
for example), or a simple name (
"Class"
), if this name is unique in the metamodel. This must be a concrete (i.e. non abstract) type.
If this model is based on EMF, the EMF factory registered to the EPackage
of the related metamodel is used to instantiate the
model element.
T
- the type of the instance to create.typeName
- the type name of the instance to create.UnsupportedOperationException
- if this method is not supported by a particular model implementation<T extends MDWObject> T create(EClass type)
MDWObject
based on the specified type.
The created element is automatically registered to this model, there's no need to call the add(MDWObject)
method.
If this model is based on EMF, the EMF factory registered to the EPackage
of the related metamodel is used to instantiate the
model element.
T
- the type of the instance to create.type
- the type of the instance to create.UnsupportedOperationException
- if this method is not supported by a particular model implementationvoid add(MDWObject object)
This method is only to be used if the element has been created outside of a Model
, for example using an EMF factory directly. If
the model element has been created using the create(String)
method, the element is already part of the model.
object
- the model element to be registered.void remove(MDWObject object)
This method only detach the model element from this model. To completely destroy the object and ensure it's not accessible from other elements,
you should rather use the eRemove()
method on this object.
object
- the object to unregister.MDWObject.eRemove()
void clear()
DiagramImage getDiagram(MDWObject object, DiagramOptions options) throws CoreException
This method uses the diagram provider of the model reader that loaded this model. If this model is not loaded by a model reader, or if the
model reader does not define a diagram provider, this method throws a CoreException
.
Please note that many model readers won't be able to support diagrams (XMI reader for example). To support diagrams, a model reader should generally have a live connection with a CASE tool, through COM APIs for example, to be able to dynamically retrieve images.
object
- a model element which is a logical diagram, or which has an attached diagram.options
- some options used to retrieve the diagram image (may be null
).CoreException
- if no diagram image could be retrieved.DiagramProvider