UML Modeling Layer

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

java.lang.Object
  extended by com.ibm.xtools.uml.msl.internal.resources.LogicalUMLResource
All Implemented Interfaces:
ILogicalUMLResource, ILogicalResource
Direct Known Subclasses:
UnknownLogicalUMLResource, UnloadedLogicalUMLResource

public class LogicalUMLResource
extends Object
implements ILogicalUMLResource

Logical UML resource, comprised of the root resource and a number of fragments. The logical resource might be composed of only one resource, in which case it has only the root resource and no fragments.


Nested Class Summary
protected  class LogicalUMLResource.ResourceSynchronizer
          We want to ensure that only one instance of LogicalUMLResource will modify the resource set at the same time so we create an object to use as a mutex
 
Field Summary
protected  List<Resource> allFragments
          A list of all the fragments in the resource at some point in time, this is effectively a synchronized resource and should only be accessed through LogicalUMLResource.getAllFragments() as it is likely to change between calls.
protected  List<Resource> loadedFragments
          Loaded fragments
protected  LogicalUMLResource.ResourceSynchronizer resourceSynchronizer
           
protected  Resource rootResource
          The root resource
 
Constructor Summary
protected LogicalUMLResource()
          Protected constructor for subclass use
  LogicalUMLResource(Resource rootResource)
          Constructor
 
Method Summary
protected  void addChildrenUnits(LogicalUMLUnit unit)
          Adds children units to the specified unit.
protected  void addFragement(Resource resource)
          Adds fragment to the logical resource.
 void addFragments(Resource resource, List<Resource> resourceList, boolean includeClosed)
          Adds fragments of the specified resource to the resource list.
 boolean contains(Resource resource)
          Tests if the specified resource is part of this logical resource.
 boolean equals(Object obj)
           
 List<Resource> getAllFragments()
          Returns list of all fragments (loaded and unloaded).
 List<Resource> getAllLoadedResources()
          Returns list of all loaded resources in the logical resource.
 List<Resource> getAllResources()
          Returns list of all resources (loaded and unloaded) in the logical resource.
 ILogicalUnit getHierarchicalStructure()
          Builds and returns hierarchical structure of the logical resource.
 ILogicalUMLUnit getInternalHierarchicalStructure()
          Builds and returns UML hierarchical structure of the logical resource.
 List<Resource> getLoadedFragments()
          Returns list of loaded fragments.
 List<Resource> getModifiedResources()
          Returns list of modified resources.
 Resource getRootResource()
          Returns the root resource.
 int hashCode()
           
 boolean isManaged()
           
 boolean isModified()
          Returns indicator if the logical resource is modified.
protected  void removeFragement(Resource resource)
          Removes fragment from the logical resource.
protected  void reset()
          Resets the list of loaded fragments of the logical resource.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceSynchronizer

protected final LogicalUMLResource.ResourceSynchronizer resourceSynchronizer

rootResource

protected Resource rootResource
The root resource


loadedFragments

protected List<Resource> loadedFragments
Loaded fragments


allFragments

protected List<Resource> allFragments
A list of all the fragments in the resource at some point in time, this is effectively a synchronized resource and should only be accessed through LogicalUMLResource.getAllFragments() as it is likely to change between calls. See LogicalUMLResource.getAllFragments() accessor for details.

Constructor Detail

LogicalUMLResource

protected LogicalUMLResource()
Protected constructor for subclass use


LogicalUMLResource

public LogicalUMLResource(Resource rootResource)
Constructor

Parameters:
rootResource - The root resource.
Method Detail

getRootResource

public Resource getRootResource()
Returns the root resource.

Specified by:
getRootResource in interface ILogicalResource
Returns:
The root resource

getLoadedFragments

public List<Resource> getLoadedFragments()
Returns list of loaded fragments.

Specified by:
getLoadedFragments in interface ILogicalResource
Returns:
List of loaded fragments. The elements in the list are of type Resource. The list is the copy of the internal structure so modifying it will not modify the structure of the logical resource.

getAllFragments

public List<Resource> getAllFragments()
Returns list of all fragments (loaded and unloaded). This method is expensive as it potentially can cause parsing of unloaded resources. It should be used with extreme care.

Specified by:
getAllFragments in interface ILogicalResource
Returns:
List of all fragments (loaded and unloaded). The elements in the list are of type Resource. The list is the copy of the internal structure so modifying it will not modify the structure of the logical resource.

getAllResources

public List<Resource> getAllResources()
Returns list of all resources (loaded and unloaded) in the logical resource. This method is expensive as it potentially can cause parsing of unloaded resources. It should be used with extreme care.

Specified by:
getAllResources in interface ILogicalResource
Returns:
List of all resources (loaded and unloaded). The elements in the list are of type Resource. The first element in the list is the root resource. The list is the copy of the internal structure so modifying it will not modify the structure of the logical resource.

getAllLoadedResources

public List<Resource> getAllLoadedResources()
Returns list of all loaded resources in the logical resource.

Specified by:
getAllLoadedResources in interface ILogicalResource
Returns:
All loaded resources. The elements in the list are of type Resource. The first element in the list is the root resource - if it is loaded. The list is the copy of the internal structure so modifying it will not modify the structure of the logical resource.

getModifiedResources

public List<Resource> getModifiedResources()
Returns list of modified resources.

Specified by:
getModifiedResources in interface ILogicalResource
Returns:
All modified resources (root resource and/or fragments). The elements in the list are of type Resource. The list is the copy of the internal structure so modifying it will not modify the structure of the logical resource.

isModified

public boolean isModified()
Returns indicator if the logical resource is modified. The logical resource is is considered modified if at least one of its resources is modified.

Specified by:
isModified in interface ILogicalResource
Returns:
'true' if the logical resource is modified; 'false' otherwise

contains

public boolean contains(Resource resource)
Tests if the specified resource is part of this logical resource. This method is expensive when invoked for a closed (unloaded) resource as it potentially can cause parsing of unloaded resources. There is no negative performance impact when used for a loaded resource. It should be used with extreme care.

Specified by:
contains in interface ILogicalResource
Parameters:
resource - The resource to be tested
Returns:
'true' if the specified resource is part of this logical resource; 'false' otherwise

addFragments

public void addFragments(Resource resource,
                         List<Resource> resourceList,
                         boolean includeClosed)
Adds fragments of the specified resource to the resource list. The includeClosed flag indicates if the closed resources should be included in the list.

Specified by:
addFragments in interface ILogicalUMLResource
Parameters:
resource - Resource whose fragments are added to the list
resourceList - The resource list
includeClosed - The indicator if the closed resources should be included in the list

addFragement

protected void addFragement(Resource resource)
Adds fragment to the logical resource.

Parameters:
resource - Fragment to be added

removeFragement

protected void removeFragement(Resource resource)
Removes fragment from the logical resource.

Parameters:
resource - Fragment to be removed

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

reset

protected void reset()
Resets the list of loaded fragments of the logical resource.


getHierarchicalStructure

public ILogicalUnit getHierarchicalStructure()
Builds and returns hierarchical structure of the logical resource. The structure is a snapshot at the time of the call and is not dynamically updated.

Specified by:
getHierarchicalStructure in interface ILogicalResource
Returns:
The logical unit of the top resource in the hierarchical structure

getInternalHierarchicalStructure

public ILogicalUMLUnit getInternalHierarchicalStructure()
Builds and returns UML hierarchical structure of the logical resource. The structure is a snapshot at the time of the call and is not dynamically updated. The root unit of a logical UML resource must be a UML logical unit. This method really returns the same unit as getHierarchicalStructure() - it only enforces the type.

Specified by:
getInternalHierarchicalStructure in interface ILogicalUMLResource
Returns:
The logical unit of the top resource in the hierarchical structure as UML unit

addChildrenUnits

protected void addChildrenUnits(LogicalUMLUnit unit)
Adds children units to the specified unit. Recursively builds the hierarchy.

Parameters:
unit - Logical unit whose children are calculated

isManaged

public boolean isManaged()
Specified by:
isManaged in interface ILogicalUMLResource
Returns:
Indicator if the logical resource is managed by the logical resources framework.
See Also:
ILogicalUMLResource.isManaged()

UML Modeling Layer

© Copyright IBM Corp. 2009. All rights reserved.