org.eclipse.ocl.examples.modelregistry.environment
Class AbstractModelResolver

java.lang.Object
  extended by org.eclipse.ocl.examples.modelregistry.environment.AbstractModelResolver
All Implemented Interfaces:
ModelResolver
Direct Known Subclasses:
ModelFileResolver, ModelResourceResolver

public class AbstractModelResolver
extends java.lang.Object
implements ModelResolver


Constructor Summary
AbstractModelResolver(FileHandle handle)
           
 
Method Summary
protected  org.eclipse.emf.ecore.resource.ResourceSet createResourceSet()
          Create the ResourceSet when one is required but undefined.
 org.eclipse.emf.ecore.resource.Resource getEcoreResource(org.eclipse.emf.common.util.URI uri, boolean loadOnDemand)
          Return the Ecore Resource for uri optionally loading it if not already loaded.
 FileHandle getHandle()
           
protected  org.eclipse.emf.ecore.EPackage[] getPackagesToRegister()
          Return a list of packages to be registered for potential resolution against their URIs.
 ProjectRegistry getProjectRegistry()
          Return the project registry, creating and loading it if not already loaded.
<A extends Accessor<A>>
Registration<A>
getRegistration(A accessor)
           
 Registration<ModelNameAccessor> getRegistration(java.lang.String modelName)
           
 Registration<URIAccessor> getRegistration(java.net.URI uri)
           
<A extends Accessor<A>>
java.util.Collection<Registration<A>>
getRegistrations(Accessor.Namespace<A> namespace)
           
 org.eclipse.emf.ecore.resource.Resource getResource(Registration<ModelNameAccessor> registration)
           
 org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.common.util.URI uri, boolean loadOnDemand)
          Return the EMF Resource for uri optionally loading it if not already loaded.
 org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
          Return the ResourceSet in which loaded resources are maintained.
<A extends Accessor<A>>
org.eclipse.emf.common.util.URI
getURI(A accessor)
          Return the (Ecore) URI suitable for getting the (Ecore) resource defined by the accessor in the context of a file defined by its handle.
 org.eclipse.emf.common.util.URI getURI(java.lang.String modelName)
          Return the (Ecore) URI suitable for getting the (Ecore) resource defined by the modelName in the context of a file defined by its handle.
 org.eclipse.emf.common.util.URI getURI(java.net.URI uri)
          Return the (Ecore) URI suitable for getting the (Ecore) resource defined by the (java.net.URI) uri in the context of a file defined by its handle.
protected  void initialiseResourceFactoryRegistry(org.eclipse.emf.ecore.resource.Resource.Factory.Registry resourceFactoryRegistry)
          Initialise the resourceFactoryRegistry of the resourceSet.
protected  org.eclipse.emf.ecore.resource.ResourceSet initialiseResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Initialise the resourceSet.
 void setResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Define the
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractModelResolver

public AbstractModelResolver(FileHandle handle)
Method Detail

createResourceSet

protected org.eclipse.emf.ecore.resource.ResourceSet createResourceSet()
Create the ResourceSet when one is required but undefined. The default implementation returns a new ResourceSetImpl.

Returns:
the ResourceSet

getEcoreResource

public org.eclipse.emf.ecore.resource.Resource getEcoreResource(org.eclipse.emf.common.util.URI uri,
                                                                boolean loadOnDemand)
                                                         throws java.lang.Exception
Description copied from interface: ModelResolver
Return the Ecore Resource for uri optionally loading it if not already loaded.

Specified by:
getEcoreResource in interface ModelResolver
Returns:
Throws:
java.lang.Exception

getHandle

public FileHandle getHandle()
Specified by:
getHandle in interface ModelResolver

getPackagesToRegister

protected org.eclipse.emf.ecore.EPackage[] getPackagesToRegister()
Return a list of packages to be registered for potential resolution against their URIs. When running under Eclipse, this method may return null to limit URI resolution to the standard plug-in registrations. When running standalone, this method is invoked by the first attempt to get a resource set. It must define all URIs that are used. The default implementation provides the URI of the Model Registry.

Returns:
packages to be registered.

getProjectRegistry

public ProjectRegistry getProjectRegistry()
Description copied from interface: ModelResolver
Return the project registry, creating and loading it if not already loaded.

Specified by:
getProjectRegistry in interface ModelResolver
Returns:
the project registry

getRegistration

public <A extends Accessor<A>> Registration<A> getRegistration(A accessor)

getRegistration

public Registration<ModelNameAccessor> getRegistration(java.lang.String modelName)

getRegistration

public Registration<URIAccessor> getRegistration(java.net.URI uri)

getRegistrations

public <A extends Accessor<A>> java.util.Collection<Registration<A>> getRegistrations(Accessor.Namespace<A> namespace)

getResource

public org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.common.util.URI uri,
                                                           boolean loadOnDemand)
                                                    throws java.lang.Exception
Description copied from interface: ModelResolver
Return the EMF Resource for uri optionally loading it if not already loaded. This is equivalent to getResourceSet().getResource().

Specified by:
getResource in interface ModelResolver
Returns:
Throws:
java.lang.Exception

getResource

public org.eclipse.emf.ecore.resource.Resource getResource(Registration<ModelNameAccessor> registration)
                                                    throws java.io.IOException
Throws:
java.io.IOException

getResourceSet

public org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
Description copied from interface: ModelResolver
Return the ResourceSet in which loaded resources are maintained.

Specified by:
getResourceSet in interface ModelResolver
Returns:
the resource set.

getURI

public <A extends Accessor<A>> org.eclipse.emf.common.util.URI getURI(A accessor)
Description copied from interface: ModelResolver
Return the (Ecore) URI suitable for getting the (Ecore) resource defined by the accessor in the context of a file defined by its handle.

Specified by:
getURI in interface ModelResolver
Parameters:
accessor - the name and type of resource to be located.
Returns:
the Ecore URI

getURI

public org.eclipse.emf.common.util.URI getURI(java.lang.String modelName)
Description copied from interface: ModelResolver
Return the (Ecore) URI suitable for getting the (Ecore) resource defined by the modelName in the context of a file defined by its handle. This is just a convenience form of getURI(resource, new ModelNameAccessor(modelName)).

Specified by:
getURI in interface ModelResolver
Parameters:
modelName - the name of the model to be located.
Returns:
the Ecore URI

getURI

public org.eclipse.emf.common.util.URI getURI(java.net.URI uri)
Description copied from interface: ModelResolver
Return the (Ecore) URI suitable for getting the (Ecore) resource defined by the (java.net.URI) uri in the context of a file defined by its handle. This is just a convenience form of getURI(resource, new URIAccessor(uri)).

Specified by:
getURI in interface ModelResolver
Parameters:
uri - the URI name of the model to be located.
Returns:
the Ecore URI

initialiseResourceFactoryRegistry

protected void initialiseResourceFactoryRegistry(org.eclipse.emf.ecore.resource.Resource.Factory.Registry resourceFactoryRegistry)
Initialise the resourceFactoryRegistry of the resourceSet. The default implementation installs the XMIResourceFactory for all extensions.

Parameters:
resourceFactoryRegistry - to be initialised.

initialiseResourceSet

protected org.eclipse.emf.ecore.resource.ResourceSet initialiseResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Initialise the resourceSet. This method may be invoked directly to initialise an externally provided ResourceSet before installation via setResourceSet(). It is invoked indirectly as createResourceSet() is invoked from getResourceSet(). The default initialisation loads all packages returned by getPackagesToRegister() and then invokes initialiseResourceFactoryRegistry().

Parameters:
resourceSet -
Returns:

setResourceSet

public void setResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Define the

Parameters:
resourceSet -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object