UML Modeling Layer

com.ibm.xtools.uml.msl.internal.resources
Class LogicalUMLResourceAdapter

java.lang.Object
  extended by org.eclipse.emf.common.notify.impl.AdapterImpl
      extended by com.ibm.xtools.uml.msl.internal.resources.LogicalUMLResourceAdapter
All Implemented Interfaces:
ILogicalUMLResourceAdapter, Adapter, Adapter.Internal

public class LogicalUMLResourceAdapter
extends AdapterImpl
implements ILogicalUMLResourceAdapter

Represents the provider of a logical UML resource. It manages groupings of UML resources into logical resources.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
Adapter.Internal
 
Field Summary
 
Fields inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
target
 
Constructor Summary
LogicalUMLResourceAdapter()
          Public constructor
 
Method Summary
protected  ILogicalUMLResource buildLogicalResource(Resource resource)
          Builds the logical resource for the specified root resource
 void dispose()
          Disconnect this adapter
 ILogicalUMLResource findLogicalResource(Resource resource)
          Returns a logical UML resource for a resource even if no part of that logical resource is loaded.
 ILogicalUMLResource findLogicalUMLResouce(Resource resource)
          Returns a logical UML resource for a resource even if no part of that logical resource is loaded.
static List<EObject> getAllContainedLoadedFragmentRoots(EObject eObj)
          Returns the list of all fragments contained in the model branch rooted at the specified object.
static List<EObject> getContainedFragments(EObject eObj, boolean selfIncluded, boolean resolve)
          Returns the list of fragments contained in the model branch rooted at the specified object.
static Resource getContainerResource(Resource resource)
          Gets the resource referred to by a resources fragment container annotation.
static EObject getFragmentDirectContainer(EModelElement fragmentRoot)
          Returns the direct container of the fragment.
static List<EObject> getFragments(EModelElement resourceRoot)
          Returns fragments of the resource.
 ILogicalUMLResource getLogicalResource(Resource resource)
          Returns the logical UML resource of the specified resource.
 ILogicalUMLResource getLogicalResource(Resource resource, boolean trackUnknowns)
          Returns the logical UML resource of the specified resource.
static EObject getRootContainerInResource(EObject eObject)
          Finds the root container in the same resource.
 void installAdapter(ResourceSet resourceSet)
          Installs logical resource support on to the provided resource set.
static boolean isFragmentRoot(EObject eObj)
          Tests if the specified object is a fragment root.
static boolean isLogicalResourceRoot(EObject eObj)
          Tests if the specified object is a logical resource root.
 void notifyChanged(Notification msg)
           
protected  void processResourceUnloaded(Resource resource)
          Processes the RESOURCE UNLOADED event.
static void registerFragmentExtension(String fragmentExtension)
          Registers the file extension with the provider to be considered as a logical resource fragment.
static void registerRootExtension(String rootExtension)
          Registers the file extension with the provider to be considered as a logical resource root.
 void reset(ILogicalUMLResource lResource)
           
static void resolveNestedFragments(Resource fragment)
          Resolves specified fragment's first level nested fragments.
 
Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
getTarget, isAdapterForType, setTarget, unsetTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogicalUMLResourceAdapter

public LogicalUMLResourceAdapter()
Public constructor

Method Detail

dispose

public void dispose()
Disconnect this adapter


findLogicalResource

public ILogicalUMLResource findLogicalResource(Resource resource)
Description copied from interface: ILogicalUMLResourceAdapter
Returns a logical UML resource for a resource even if no part of that logical resource is loaded. Unlike other logicalResource methods the result returned here may not be canonical. If a canonical logical resource can be found it will be returned otherwise an UnloadedLogicalUMLResource is returned.

Specified by:
findLogicalResource in interface ILogicalUMLResourceAdapter
Parameters:
resource - The resource whose logical resource is returned
Returns:
The canonical logical model for as resource if it exists or an UnloadedLogicalUMLResource otherwise.

findLogicalUMLResouce

public ILogicalUMLResource findLogicalUMLResouce(Resource resource)
Returns a logical UML resource for a resource even if no part of that logical resource is loaded. Unlike other logicalResource methods the result returned here may not be canonical. If a canonical logical resource can be found it will be returned otherwise an LogicalUMLResourceProvider is returned.

Parameters:
resource - The resource whose logical resource is returned
Returns:
The canonical logical model for as resource if it exists or an UnloadedLogicalUMLResource otherwise.

getContainerResource

public static Resource getContainerResource(Resource resource)
Gets the resource referred to by a resources fragment container annotation.

Parameters:
resource -
Returns:

getLogicalResource

public ILogicalUMLResource getLogicalResource(Resource resource,
                                              boolean trackUnknowns)
Description copied from interface: ILogicalUMLResourceAdapter
Returns the logical UML resource of the specified resource.

Specified by:
getLogicalResource in interface ILogicalUMLResourceAdapter
Parameters:
resource - The resource whose logical resource is returned. If the resource is not loaded the fragment list is not built and the returned logical resource can be used only as the wrapper. Subsequent invocations for the same resource will return in that case different instance of the logical resource.
Returns:
Logical UML resource

getLogicalResource

public ILogicalUMLResource getLogicalResource(Resource resource)
Description copied from interface: ILogicalUMLResourceAdapter
Returns the logical UML resource of the specified resource.

Specified by:
getLogicalResource in interface ILogicalUMLResourceAdapter
Parameters:
resource - The resource whose logical resource is returned. If the resource is not loaded the fragment list is not built and the returned logical resource can be used only as the wrapper. Subsequent invocations for the same resource will return in that case different instance of the logical resource.
Returns:
Logical UML resource

installAdapter

public void installAdapter(ResourceSet resourceSet)
Installs logical resource support on to the provided resource set. Note that this adapter must only be installed on a single resource set.


notifyChanged

public void notifyChanged(Notification msg)
Specified by:
notifyChanged in interface Adapter
Overrides:
notifyChanged in class AdapterImpl

buildLogicalResource

protected ILogicalUMLResource buildLogicalResource(Resource resource)
Builds the logical resource for the specified root resource

Parameters:
resource - The root resource

processResourceUnloaded

protected void processResourceUnloaded(Resource resource)
Processes the RESOURCE UNLOADED event.

Parameters:
resource - The unloaded resource

reset

public void reset(ILogicalUMLResource lResource)

isLogicalResourceRoot

public static boolean isLogicalResourceRoot(EObject eObj)
Tests if the specified object is a logical resource root.

Parameters:
eObj - Object to be tested
Returns:
'true' if the object is logical resource root; 'false' otherwise

isFragmentRoot

public static boolean isFragmentRoot(EObject eObj)
Tests if the specified object is a fragment root.

Parameters:
eObj - Object to be tested
Returns:
'true' if the object is fragment root; 'false' otherwise

getFragmentDirectContainer

public static EObject getFragmentDirectContainer(EModelElement fragmentRoot)
Returns the direct container of the fragment.

Parameters:
fragmentRoot - The fragment root
Returns:
The direct container of the fragment

getFragments

public static List<EObject> getFragments(EModelElement resourceRoot)
Returns fragments of the resource. The fragments might not be resolved.

Parameters:
resourceRoot - The resource root
Returns:
The fragments of the resource

getRootContainerInResource

public static EObject getRootContainerInResource(EObject eObject)
Finds the root container in the same resource.

Parameters:
eObject - Object whose root container is returned
Returns:
The root container in the same resource

getAllContainedLoadedFragmentRoots

public static List<EObject> getAllContainedLoadedFragmentRoots(EObject eObj)
Returns the list of all fragments contained in the model branch rooted at the specified object. If those fragments are further fragmented then those additional fragments are included in the list. The objects in the list are the root objects (EObject) of the corresponding fragments.

Parameters:
eObj - The root of the model branch to be queried.
Returns:
The list of fragment roots (instances of EObject)

getContainedFragments

public static List<EObject> getContainedFragments(EObject eObj,
                                                  boolean selfIncluded,
                                                  boolean resolve)
Returns the list of fragments contained in the model branch rooted at the specified object. These are only the first level fragments; that is, the fragments of the resource owning the specified object. If those fragments are further fragmented then those additional fragments are not included in the list. The objects in the list are the root objects (EObject) of the corresponding fragments. These objects could be proxies depending on the value of the resolve flag.

Parameters:
eObj - The root of the model branch to be queried.
selfIncluded - Indicates how the specified object should be considered. If the flag is set to true and this object is a fragment root then it is considered to be the only contained fragment root - it is the only item in the returned list. If the flag is set to false then there is no special behavior when the specified element is fragment root.
resolve - Indicates if the objects in the returned list should be resolved or not. Even if it is set to 'true' the objects might still be proxies - if they cannot be resolved.
Returns:
The list of fragment roots (instances of EObject)

resolveNestedFragments

public static void resolveNestedFragments(Resource fragment)
Resolves specified fragment's first level nested fragments.

Parameters:
fragment - Fragment whose nested fragments are resolved

registerRootExtension

public static void registerRootExtension(String rootExtension)
Registers the file extension with the provider to be considered as a logical resource root.

Parameters:
rootExtension - The file extension

registerFragmentExtension

public static void registerFragmentExtension(String fragmentExtension)
Registers the file extension with the provider to be considered as a logical resource fragment.

Parameters:
fragmentExtension - The file extension

UML Modeling Layer

© Copyright IBM Corp. 2009. All rights reserved.