org.eclipse.xtext.resource
Interface IFragmentProvider

All Known Subinterfaces:
IClassMirror, IMirror
All Known Implementing Classes:
AbstractClassMirror, ClassMirror, DefaultFragmentProvider, JdtTypeMirror, PrimitiveMirror, XtextFragmentProvider

public interface IFragmentProvider

Used to compute fragments (i.e. resource local IDs) for EObjects and locate EObjects by fragment. Typically used within a Resource.

Author:
Sven Efftinge - Initial contribution and API, Sebastian Zarnekow

Nested Class Summary
static interface IFragmentProvider.Fallback
          Delegate the resolution of EObject or the computation of fragments to the default implementation by invoking the respective methods on the given instance of this fall-back delegate.
 
Method Summary
 org.eclipse.emf.ecore.EObject getEObject(org.eclipse.emf.ecore.resource.Resource resource, java.lang.String fragment, IFragmentProvider.Fallback fallback)
          Locates an EObject in a resource by its fragment.
 java.lang.String getFragment(org.eclipse.emf.ecore.EObject obj, IFragmentProvider.Fallback fallback)
          Computes the URI fragment (local ID) of the given object.
 

Method Detail

getFragment

java.lang.String getFragment(org.eclipse.emf.ecore.EObject obj,
                             IFragmentProvider.Fallback fallback)
Computes the URI fragment (local ID) of the given object.

Parameters:
obj - the EObject to compute the fragment for.
fallback - if the default behavior should be used, delegate the computation of the fragment to the default implementation of Resource.getURIFragment(EObject).
Returns:
the fragment, which can be an arbitrary string but must be unique within a resource. May not return null.

getEObject

org.eclipse.emf.ecore.EObject getEObject(org.eclipse.emf.ecore.resource.Resource resource,
                                         java.lang.String fragment,
                                         IFragmentProvider.Fallback fallback)
Locates an EObject in a resource by its fragment.

Parameters:
resource - the resource serves as context instance.
fragment - the fragment of the object.
fallback - if the fragment was not created by this provider, delegate the resolution to the default implementation of Resource.getEObject(String).
Returns:
the resolved object or null if the fragment could not be resolved to an object.