org.eclipse.emf.ecore.util
Class EcoreUtil.CrossReferencer

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byorg.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer
All Implemented Interfaces:
Cloneable, Map, Serializable
Direct Known Subclasses:
EcoreUtil.ExternalCrossReferencer, EcoreUtil.ProxyCrossReferencer, EcoreUtil.UnresolvedProxyCrossReferencer, EcoreUtil.UsageCrossReferencer, ECrossReferenceAdapter.InverseCrossReferencer
Enclosing class:
EcoreUtil

public static class EcoreUtil.CrossReferencer
extends HashMap

A mapping building traverser of a collection of content trees; the map is from target object to a collection of EStructuralFeature.Setting. Since this implementation extends a Map implementation, it can yield itself as the result for most operations. The traverser considers each EObject in the EObject.eCrossReferences() of each EObject in the content tree, and creates a setting for each positive match. This default implementation creates a map of all cross references.

See Also:
Serialized Form

Field Summary
protected  Collection emfObjects
          The collection of objects being cross referenced.
 
Constructor Summary
protected EcoreUtil.CrossReferencer(Collection emfObjects)
          Creates an instance for the given collection of objects.
protected EcoreUtil.CrossReferencer(EObject eObject)
          Creates an instance for the given object.
protected EcoreUtil.CrossReferencer(Resource resource)
          Creates an instance for the given resource.
protected EcoreUtil.CrossReferencer(ResourceSet resourceSet)
          Creates an instance for the given resource set.
 
Method Summary
protected  void add(InternalEObject eObject, EReference eReference, EObject crossReferencedEObject)
           
protected  boolean containment(EObject eObject)
          Return true if the cross referencer should include references from children of the specified object.
protected  void crossReference()
          Compute the map of cross references.
protected  boolean crossReference(EObject eObject, EReference eReference, EObject crossReferencedEObject)
          Return true if the specified eReference from eObject to crossReferencedEObject should be considiered a cross reference by this cross referencer.
protected  void done()
          Reset this cross referencer's object set.
static Map find(Collection emfObjects)
          Returns a map of all cross references in the content tree.
protected  Collection getCollection(Object key)
          Return the collection of cross reference settings for the specified key (target object).
protected  EContentsEList.FeatureIterator getCrossReferences(EObject eObject)
           
protected  void handleCrossReference(EObject eObject)
           
protected  Collection newCollection()
          Return a collection to use for storing settings.
protected  TreeIterator newContentsIterator()
          Return a tree iterator over the content trees of this cross referencer's objects.
static void print(PrintStream out, Collection settings)
          Print the specified collection of settings to the specified stream.
static void print(PrintStream out, Map crossReferenceMap)
          Print the specified cross reference map to the specified stream.
protected  boolean resolve()
          Return true if cross references that are proxies should be resolved.
 String toString()
          Returns a string representation of this cross referencer.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

emfObjects

protected Collection emfObjects
The collection of objects being cross referenced.

Constructor Detail

EcoreUtil.CrossReferencer

protected EcoreUtil.CrossReferencer(EObject eObject)
Creates an instance for the given object.

Parameters:
eObject - the object to cross reference.

EcoreUtil.CrossReferencer

protected EcoreUtil.CrossReferencer(Resource resource)
Creates an instance for the given resource.

Parameters:
resource - the resource to cross reference.

EcoreUtil.CrossReferencer

protected EcoreUtil.CrossReferencer(ResourceSet resourceSet)
Creates an instance for the given resource set.

Parameters:
resourceSet - the resource set to cross reference.

EcoreUtil.CrossReferencer

protected EcoreUtil.CrossReferencer(Collection emfObjects)
Creates an instance for the given collection of objects.

Parameters:
emfObjects - the collection of objects to cross reference.
Method Detail

containment

protected boolean containment(EObject eObject)
Return true if the cross referencer should include references from children of the specified object.

Parameters:
eObject - an object in the cross referencer's content tree.
Returns:
if the cross referencer should include references from children of the object.

crossReference

protected boolean crossReference(EObject eObject,
                                 EReference eReference,
                                 EObject crossReferencedEObject)
Return true if the specified eReference from eObject to crossReferencedEObject should be considiered a cross reference by this cross referencer.

Parameters:
eObject - an object in the cross referencer's content tree.
eReference - a reference from the object.
crossReferencedEObject - the target of the specified reference.
Returns:
if the cross referencer should consider the specified reference a cross reference.

resolve

protected boolean resolve()
Return true if cross references that are proxies should be resolved.

Returns:
if the cross referencer should resolve proxies.

newCollection

protected Collection newCollection()
Return a collection to use for storing settings.

Returns:
a collection for settings.

getCollection

protected Collection getCollection(Object key)
Return the collection of cross reference settings for the specified key (target object).

Parameters:
key - the key for the cross referencer's map.
Returns:
the collection of settings.

newContentsIterator

protected TreeIterator newContentsIterator()
Return a tree iterator over the content trees of this cross referencer's objects.

Returns:
a tree iterator over content trees.

crossReference

protected void crossReference()
Compute the map of cross references.


getCrossReferences

protected EContentsEList.FeatureIterator getCrossReferences(EObject eObject)

handleCrossReference

protected void handleCrossReference(EObject eObject)

add

protected void add(InternalEObject eObject,
                   EReference eReference,
                   EObject crossReferencedEObject)

done

protected void done()
Reset this cross referencer's object set.


find

public static Map find(Collection emfObjects)
Returns a map of all cross references in the content tree.

Parameters:
emfObjects - a collection of objects whose combined content trees should be considered.
Returns:
a map of cross references.

toString

public String toString()
Returns a string representation of this cross referencer.

Returns:
the string representation.

print

public static void print(PrintStream out,
                         Map crossReferenceMap)
Print the specified cross reference map to the specified stream.

Parameters:
out - the stream to print to.
crossReferenceMap - a map (cross referencer) to print.

print

public static void print(PrintStream out,
                         Collection settings)
Print the specified collection of settings to the specified stream.

Parameters:
out - the stream to print to.
settings - a collection of settings.

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.