public abstract class EMFModelWriter extends Object implements ModelWriter
This class acts as a bridge between EMF Resource
and MDWorkbench ModelWriter
. Subclasses are required to implement the
createResource
method. This class will delegate the writing to the created resource.
A default implementation is available to handle XMI uris.
Clients may subclass this class.
Modifier and Type | Field and Description |
---|---|
static String |
MDW_CONNECTOR_CONTEXT
Option that gives access to the connector context.
|
Constructor and Description |
---|
EMFModelWriter() |
Modifier and Type | Method and Description |
---|---|
protected Map<String,Object> |
createOptions(ConnectorContext context)
Create options to pass to the created resource.
|
protected abstract Resource |
createResource(URI uri,
ConnectorContext context)
Creates a resource that is able to handle the specified uri.
|
protected Collection<EObject> |
getDirectContents(Model model,
ConnectorContext context)
Returns the model elements to attach to the create resource.
|
protected void |
logError(ConnectorContext context,
Resource.Diagnostic error)
Logs the specified diagnostic to the registered logger.
|
void |
write(String filepath,
Model model,
ConnectorContext context)
Writes the specified model to the specified uri.
|
public static final String MDW_CONNECTOR_CONTEXT
save
method can retrieve the connector context this way :ConnectorContext context = (ConnectorContext) options.get(EMFModelWriter.MDW_CONNECTOR_CONTEXT);
public void write(String filepath, Model model, ConnectorContext context) throws CoreException
Resource
.save
method.The context can be used to access a variery of properties and is to be used to check for cancellation.
write
in interface ModelWriter
filepath
- the location of a resource to write.model
- the model to be persisted.context
- the context in which this writer runs.CoreException
- if anything prevents the connector to write the model.ConnectorDescriptor.getKind()
protected abstract Resource createResource(URI uri, ConnectorContext context)
uri
- the URI to write.context
- the context in which the connector runsprotected Collection<EObject> getDirectContents(Model model, ConnectorContext context)
EObject
that has no container.model
- the model to be persisted.context
- the context in which this writer runs.protected Map<String,Object> createOptions(ConnectorContext context)
MDW_CONNECTOR_CONTEXT
to give access to the context.context
- the context in which the connector runsprotected void logError(ConnectorContext context, Resource.Diagnostic error)
context
- the context in which this writer runs.error
- the error to be logged.