capint
4/27/2016 - 8:40 AM

EMF >> get URI from Notifier

EMF >> get URI from Notifier

>> org.eclipse.emf.ecore.util.EcoreUtil.getURI(EObject eObject) returns a URI for the eObject either:
  >> the eProxyURI (e.g. <resource-uri>#<fragment-of-object-in-that-resource>)
  >> the URI of the eResource with the fragment produced by the eResource
  >> or the URI consisting of just the fragment that would be produced by a default Resource with the eObject as its only contents. (e.g. #container1/container2/object)
public static URI getURI(Notifier original) {
	if (original instanceof Resource) {
		return ((Resource) original).getURI();
		}
	}
	if (original instanceof EObject) {
		return EcoreUtil.getURI((EObject) original);
		}
	}
	return null;
}