javaeclipse-rcpemf

How to change the URI of an InternalEObject


I would like to change the URI of InternalEObject.

I know I can get the URI by calling:

EcoreUtil.getURI(internalEObject);

What would be the correct procedure to change the URI for the internalEObject in question? Not just getting the string. Creating a new identical InternalEObject and give it a new URI?


Solution

  • Solved it.

    It is possible to use the utility functions present in EcoreUtil wich is a part of EMF.

    The following snippet did the job:

    for (InternalEObject def: defs) {
      URI uri = EcoreUtil.getURI(def);
      def.eSetProxyURI(URI.createURI(uri.toString().replaceAll(STRING_CONSTANT1, STRING_CONSTANT2)));
    }