Class PortableURIs
- java.lang.Object
-
- org.eclipse.xtext.resource.persistence.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PortableURIs.PortableFragmentDescription
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PORTABLE_SCHEME
-
Constructor Summary
Constructors Constructor Description PortableURIs()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PortableURIs.PortableFragmentDescription
createPortableFragmentDescription(IEObjectDescription desc, org.eclipse.emf.ecore.EObject target)
protected PortableURIs.PortableFragmentDescription
fromFragmentString(java.lang.String fragmentString)
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.java.lang.String
getFragment(org.eclipse.emf.ecore.EObject fromContainer, org.eclipse.emf.ecore.EObject toChild)
Computes a fragment to the child relative from the given container.protected java.lang.String
getPortableURIFragment(org.eclipse.emf.ecore.EObject obj)
boolean
isPortableURIFragment(java.lang.String uriFragment)
org.eclipse.emf.ecore.EObject
resolve(StorageAwareResource resource, java.lang.String portableFragment)
Resolves a given portable URI fragment against the given resource.protected java.lang.String
toFragmentString(PortableURIs.PortableFragmentDescription desc)
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.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.
-
-
-
Field Detail
-
PORTABLE_SCHEME
public static final java.lang.String PORTABLE_SCHEME
- See Also:
- Constant Field Values
-
-
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 EObjectportableFragment
- 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. Returnsnull
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 resolvedtargetURI
- 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. Returnsnull
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 resolvedtargetObject
- 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
-
createPortableFragmentDescription
protected PortableURIs.PortableFragmentDescription createPortableFragmentDescription(IEObjectDescription desc, org.eclipse.emf.ecore.EObject target)
-
toFragmentString
protected java.lang.String toFragmentString(PortableURIs.PortableFragmentDescription desc)
-
fromFragmentString
protected PortableURIs.PortableFragmentDescription fromFragmentString(java.lang.String fragmentString)
-
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 computedtoChild
- 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 resolvedtoFragment
- the fragment- Returns:
- the resolved EObject based. If the given fragment is
null, the given EObject itself will be returned.
-
-