UML Modeling Layer

com.ibm.xtools.uml.msl.internal.resources.parsers
Class ContainerParser

java.lang.Object
  extended by com.ibm.xtools.uml.msl.internal.resources.parsers.ContainerParser
Direct Known Subclasses:
FragmentParser

public class ContainerParser
extends Object

Parser specialized for fast extracting of the parent fragment data for the specified resource. If the resource is loaded the parser uses EMF to extract the data. If the resource is not loaded the parser does not cause it to be loaded; rather it uses SAX parser with fast break out algorithm to extract the data.


Field Summary
protected  Resource containerResource
          The container resource.
protected  URI containerUri
          The URI of the containing element if there is one
protected  Resource resource
          The resource whose fragment data are collected.
protected  ResourceHealth resourceHealth
          Resource health for the resource being parsed.
 
Constructor Summary
ContainerParser(Resource resource)
          Constructor
 
Method Summary
protected  FragmentHandler buildFragmentHandler()
           
protected  void checkClosedParentReference(URI uri, String rootId, URI fragmentUri)
          Checks the validity of the parent reference in a closed resource
protected  void checkLoadedParentReference(EModelElement resourceRoot, EObject eObj, URI uri)
          Checks the validity of the parent reference in a loaded resource
protected  void closedContainerParse(FragmentHandler fh, ResourceSet resSet, URI fragmentUri)
          Container parsing of closed resources
protected  void closedFragmentsParse(FragmentHandler fh, ResourceSet resSet, URI fragmentUri)
          Stub implementation of fragment parsing for subclasses
protected  void closedResourceParse()
          Uses SAX parser to parse the resource.
 Resource getContainerResource()
           
 URI getContainerUri()
           
 ResourceHealth getResourceHealth()
           
protected  void loadedContainerParse(EModelElement resourceRoot, ResourceSet resSet, EAnnotation fragmentAnnotation)
          Container parsing of loaded resources
protected  void loadedFragmentsParse(EModelElement resourceRoot, ResourceSet resSet)
          Stub implementation of fragment parsing for subclasses
protected  void loadedResourceParse()
          Uses EMF to parse the resource.
 void parse()
          Parses the specified resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resource

protected Resource resource
The resource whose fragment data are collected. The resource does not have to be loaded.


containerResource

protected Resource containerResource
The container resource. It may be null if the parsed resource does not have a container resource.


containerUri

protected URI containerUri
The URI of the containing element if there is one


resourceHealth

protected ResourceHealth resourceHealth
Resource health for the resource being parsed.

Constructor Detail

ContainerParser

public ContainerParser(Resource resource)
Constructor

Parameters:
resource - The resource whose fragment data are collected. The resource does not have to be loaded.
Method Detail

parse

public void parse()
Parses the specified resource.


loadedResourceParse

protected void loadedResourceParse()
Uses EMF to parse the resource. The resource has to be loaded.


closedResourceParse

protected void closedResourceParse()
Uses SAX parser to parse the resource. The resource should be closed (unloaded).


closedContainerParse

protected void closedContainerParse(FragmentHandler fh,
                                    ResourceSet resSet,
                                    URI fragmentUri)
Container parsing of closed resources

Parameters:
fh - XML sax element handler for fragmented resources
resSet - active resource set
fragmentUri - uri of the current resource

loadedContainerParse

protected void loadedContainerParse(EModelElement resourceRoot,
                                    ResourceSet resSet,
                                    EAnnotation fragmentAnnotation)
Container parsing of loaded resources

Parameters:
resourceRoot - root element of the current resource
resSet - active resource set
fragmentAnnotation - fragment annotation of the current resource

checkLoadedParentReference

protected void checkLoadedParentReference(EModelElement resourceRoot,
                                          EObject eObj,
                                          URI uri)
Checks the validity of the parent reference in a loaded resource

Parameters:
resourceRoot - root element of the current resource
eObj - container element
uri - uri of the current resource

checkClosedParentReference

protected void checkClosedParentReference(URI uri,
                                          String rootId,
                                          URI fragmentUri)
Checks the validity of the parent reference in a closed resource

Parameters:
uri - container resource uri
rootId - id of the root element of the current resource
fragmentUri - uri of the current resource

loadedFragmentsParse

protected void loadedFragmentsParse(EModelElement resourceRoot,
                                    ResourceSet resSet)
Stub implementation of fragment parsing for subclasses

Parameters:
resourceRoot - root element of the current resource
resSet - active resource set

closedFragmentsParse

protected void closedFragmentsParse(FragmentHandler fh,
                                    ResourceSet resSet,
                                    URI fragmentUri)
Stub implementation of fragment parsing for subclasses

Parameters:
fh - XML sax element handler for fragmented resources
resSet - active resource set
fragmentUri - uri of the current resource

buildFragmentHandler

protected FragmentHandler buildFragmentHandler()
Returns:
The fragment handler for SAX parser. The default implementation instantiates FragmentHandler. If subclass needs to provide additional parsing functionality (for closed resource) then this method should be overridden and an instance of a FragmentHandler subclass returned.

getContainerResource

public Resource getContainerResource()
Returns:
The container resource. It may be null if the parsed resource does not have a container resource.

getResourceHealth

public ResourceHealth getResourceHealth()
Returns:
Resource health for the resource being parsed.
See Also:
ResourceHealth

getContainerUri

public URI getContainerUri()
Returns:
the containerUri

UML Modeling Layer

© Copyright IBM Corp. 2009. All rights reserved.