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

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--org.eclipse.emf.ecore.util.EcoreUtil.Copier
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Enclosing class:
EcoreUtil

public static class EcoreUtil.Copier
extends java.util.HashMap

A mapping building traverser of a collection of content trees; the map is from EObject to EObject, i.e., from original to copy; use EcoreUtil.copy or EcoreUtil.copyAll to do routine copies. Since this implementation extends a Map implementation, it acts as the result of the over all copy. The client can call copy and copyAll repeatedly. When all the objects have been copied, the client should call copyReferences to copy the appropriate cross references.

  Copier copier = new Copier();
  Collection result = copier.copy(eObject);
  Collection results = copier.copyAll(eObjects);
  copier.copyReferences();
The copier delegates to copyContainment, copyAttribute during the copy phase and to copyReference, during the cross reference phase. This allows tailored handling through derivation.

See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
EcoreUtil.Copier()
           
 
Method Summary
 EObject copy(EObject eObject)
          Returns a copy of the given eObject.
 java.util.Collection copyAll(java.util.Collection eObjects)
          Returns a collection containing a copy of each EObject in the given collection.
protected  void copyAttribute(EAttribute eAttribute, EObject eObject, EObject copiedEObject)
          Called to handle the copying of an attribute; this adds a list of values or sets a single value as appropriate for the multiplicity.
protected  void copyContainment(EReference eReference, EObject eObject, EObject copiedEObject)
          Called to handle the copying of a containment feature; this adds a list of copies or sets a single copy as appropriate for the multiplicity.
protected  void copyReference(EReference eReference, EObject eObject, EObject copiedEObject)
          Called to handle the copying of a cross reference; this adds values or sets a single value as appropriate for the multiplicity while omitting any bidirectional reference that isn't in the copy map.
 void copyReferences()
          Hooks up cross references; it delegates to copyReference.
 
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, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

EcoreUtil.Copier

public EcoreUtil.Copier()
Method Detail

copyAll

public java.util.Collection copyAll(java.util.Collection eObjects)
Returns a collection containing a copy of each EObject in the given collection.
Parameters:
eObjects - the collection of objects to copy.
Returns:
the collection of copies.

copy

public EObject copy(EObject eObject)
Returns a copy of the given eObject.
Parameters:
eObject - the object to copy.
Returns:
the copy.

copyContainment

protected void copyContainment(EReference eReference,
                               EObject eObject,
                               EObject copiedEObject)
Called to handle the copying of a containment feature; this adds a list of copies or sets a single copy as appropriate for the multiplicity.
Parameters:
eReference - the feature to copy.
eObject - the object from which to copy.
copiedEObject - the object to copy to.

copyAttribute

protected void copyAttribute(EAttribute eAttribute,
                             EObject eObject,
                             EObject copiedEObject)
Called to handle the copying of an attribute; this adds a list of values or sets a single value as appropriate for the multiplicity.
Parameters:
eAttribute - the attribute to copy.
eObject - the object from which to copy.
copiedEObject - the object to copy to.

copyReferences

public void copyReferences()
Hooks up cross references; it delegates to copyReference.

copyReference

protected void copyReference(EReference eReference,
                             EObject eObject,
                             EObject copiedEObject)
Called to handle the copying of a cross reference; this adds values or sets a single value as appropriate for the multiplicity while omitting any bidirectional reference that isn't in the copy map.
Parameters:
eReference - the reference to copy.
eObject - the object from which to copy.
copiedEObject - the object to copy to.

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