Class PortableURIs


  • public class PortableURIs
    extends java.lang.Object
    Portable URIs are based on names and therefore are independent of the concrete file paths and file names of the resources. A portable URI is really a resource URI to the client URI and a fragment that contains the information to retrieve the referenced element using the global scoping. That is it contains
    • the qualified name of a container of the target element
    • the type of that container
    • the path from that container to the actual target element
    Since:
    2.8
    • Field Detail

    • Constructor Detail

      • PortableURIs

        public PortableURIs()
    • Method Detail

      • isPortableURIFragment

        public boolean isPortableURIFragment​(java.lang.String uriFragment)
        Returns:
        whether the given string is a portable URI fragment
      • resolve

        public org.eclipse.emf.ecore.EObject resolve​(StorageAwareResource resource,
                                                     java.lang.String portableFragment)
        Resolves a given portable URI fragment against the given resource.
        Parameters:
        resource - the resource from which global scope to look up the EObject
        portableFragment - the portable fragment pointing to the to be resolved EObject
        Returns:
        the EObject for the given portableURIFragment
      • toPortableURI

        public org.eclipse.emf.common.util.URI toPortableURI​(StorageAwareResource sourceResource,
                                                             org.eclipse.emf.common.util.URI targetURI)
        Creates and returns a portable URI from the given resource to the targetURI. Returns null if no portable URI can be constructed, which is the case if the targetObject is not itself exported or is a child of an exported EObject.
        Parameters:
        sourceResource - the resource from which the EObject should later be resolved
        targetURI - the target URI that should be resolvable by the created portable URI
        Returns:
        a portable URI or null
      • toPortableURI

        public org.eclipse.emf.common.util.URI toPortableURI​(StorageAwareResource sourceResource,
                                                             org.eclipse.emf.ecore.EObject targetObject)
        Creates and returns a portable URI from the global scope. Returns null if no portable URI can be constructed, which is the case if the targetObject is not itself exported or is a child of an exported EObject.
        Parameters:
        sourceResource - the resource from which the EObject should later be resolved
        targetObject - the target object that should be resolvable by the created portable URI
        Returns:
        a portable URI or null
      • getPortableURIFragment

        protected java.lang.String getPortableURIFragment​(org.eclipse.emf.ecore.EObject obj)
        Returns:
        a portable URI fragment, or null if the give EObject isn't itself or is not contained in an exported EObjectDescription
      • getFragment

        public java.lang.String getFragment​(org.eclipse.emf.ecore.EObject fromContainer,
                                            org.eclipse.emf.ecore.EObject toChild)
                                     throws java.lang.IllegalArgumentException
        Computes a fragment to the child relative from the given container.
        Parameters:
        fromContainer - the container EObject from which the fragment path is computed
        toChild - the target EObject which can be found using the fromContainer and resulting fragment path
        Returns:
        a fragment path from the given container to the child, or null is fromContainer == toChild
        Throws:
        java.lang.IllegalArgumentException - if the child is not a child of the given container.
        See Also:
        getEObject(EObject,String)
      • getEObject

        public org.eclipse.emf.ecore.EObject getEObject​(org.eclipse.emf.ecore.EObject from,
                                                        java.lang.String toFragment)
        Finds an EObject for the given context EObject and fragment.
        Parameters:
        from - the EObject from which the path should be resolved
        toFragment - the fragment
        Returns:
        the resolved EObject based. If the given fragment is null, the given EObject itself will be returned.