org.eclipse.ocl.examples.pivot.manager
Interface MetaModelManager.Factory

All Known Implementing Classes:
MetaModelManager.AbstractFactory
Enclosing class:
MetaModelManager

public static interface MetaModelManager.Factory

An OrphanClient adapts an EObject with an eReference to an OrphanServer within the domina of a TypeCache. Changes to eContainer and eReference cause the eReference to be activated and deactivated accordingly so that the OrphanServer is aware of how many active clients there are. public static class OrphanClient implements Adapter { protected final TypeCaches typeCache; protected final EObject target; protected final EReference eReference; private OrphanServer orphanServer; public OrphanClient(TypeCaches typeCache, EObject target, EReference eReference) { this.typeCache = typeCache; this.target = target; this.eReference = eReference; this.orphanServer = null; target.eAdapters().add(this); } protected void activate(NamedElement pivotElement) { orphanServer = null; // W I P typeCache.getOrphanServer(pivotElement); if (orphanServer != null) { orphanServer.addClient(this); } } protected void deActivate() { if (orphanServer != null) { orphanServer.removeClient(this); orphanServer = null; } } public Notifier getTarget() { return target; } public boolean isAdapterForType(Object type) { return type == OrphanClient.class; } public void notifyChanged(Notification notification) { if (notification.getNotifier() == target) { int eventType = notification.getEventType(); switch (eventType) { case Notification.SET: { Object oldValue = notification.getOldValue(); Object newValue = notification.getNewValue(); if (newValue != oldValue) { Object feature = notification.getFeature(); if (feature == eReference) { if (oldValue != null) { deActivate(); } if (newValue instanceof NamedElement) { activate((NamedElement) newValue); } } else if (feature == target.eContainmentFeature()) { if (oldValue != null) { deActivate(); } if (newValue != null) { assert target == newValue; Object orphan = target.eGet(eReference); if (orphan instanceof NamedElement) { activate((NamedElement) orphan); } } } } } } } } public void setTarget(Notifier newTarget) { assert (newTarget == null) || (newTarget == target); } }


Field Summary
static int CAN_HANDLE
           
static int CANNOT_HANDLE
           
static int MAY_HANDLE
           
 
Method Summary
 void configure(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
          Configure the MetaModelManager's external ResourceSet.
 int getHandlerPriority(org.eclipse.emf.ecore.EObject eObject)
          Return a positive handler priority if this factory can handle creation of a Pivot type from the available object, negative if it cannot.
 int getHandlerPriority(org.eclipse.emf.ecore.resource.Resource resource)
          Return a positive handler priority if this factory can handle creation of a Pivot resource from the available resource, negative if it cannot.
 org.eclipse.emf.common.util.URI getPackageURI(org.eclipse.emf.ecore.EObject eObject)
          Return the URI of an eObject if it can be treated as a Package.
<T extends Element>
T
getPivotOf(MetaModelManager metaModelManager, java.lang.Class<T> pivotClass, org.eclipse.emf.ecore.EObject eObject)
           
 Element importFromResource(MetaModelManager metaModelManager, org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.emf.common.util.URI uri)
          Return the root element in the Pivot resource resulting from import of the available resource.
 

Field Detail

CANNOT_HANDLE

static final int CANNOT_HANDLE
See Also:
Constant Field Values

MAY_HANDLE

static final int MAY_HANDLE
See Also:
Constant Field Values

CAN_HANDLE

static final int CAN_HANDLE
See Also:
Constant Field Values
Method Detail

configure

void configure(@NonNull
               org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Configure the MetaModelManager's external ResourceSet. Implementations may install any required extension or content to factory mappinmgs in the resource factory registry.

Parameters:
resourceSet -

getHandlerPriority

int getHandlerPriority(@NonNull
                       org.eclipse.emf.ecore.EObject eObject)
Return a positive handler priority if this factory can handle creation of a Pivot type from the available object, negative if it cannot. Generic handlers such as ECore return a low priority.


getHandlerPriority

int getHandlerPriority(@NonNull
                       org.eclipse.emf.ecore.resource.Resource resource)
Return a positive handler priority if this factory can handle creation of a Pivot resource from the available resource, negative if it cannot. Generic handlers such as ECore return a low priority.


getPackageURI

@Nullable
org.eclipse.emf.common.util.URI getPackageURI(@NonNull
                                                       org.eclipse.emf.ecore.EObject eObject)
Return the URI of an eObject if it can be treated as a Package.


getPivotOf

<T extends Element> T getPivotOf(@NonNull
                                 MetaModelManager metaModelManager,
                                 @NonNull
                                 java.lang.Class<T> pivotClass,
                                 @NonNull
                                 org.eclipse.emf.ecore.EObject eObject)
                             throws ParserException
Throws:
ParserException

importFromResource

@Nullable
Element importFromResource(@NonNull
                                    MetaModelManager metaModelManager,
                                    @NonNull
                                    org.eclipse.emf.ecore.resource.Resource resource,
                                    @Nullable
                                    org.eclipse.emf.common.util.URI uri)
                           throws ParserException
Return the root element in the Pivot resource resulting from import of the available resource.

Parameters:
uriFragment -
Throws:
ParserException