Class ResourceUtils
- java.lang.Object
-
- org.eclipse.emf.edapt.internal.common.ResourceUtils
-
public final class ResourceUtils extends Object
Helper methods to load and save EMF resources.- Version:
- $Rev$
- Author:
- herrmama, $Author$
-
-
Field Summary
Fields Modifier and Type Field Description static String
ECORE_FILE_EXTENSION
File extension for Ecore model.static String
PLATFORM_SCHEME
Scheme for platform resources.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
exists(org.eclipse.emf.common.util.URI uri)
Check whether a file exists for a certain URI.static <E extends org.eclipse.emf.ecore.EObject>
List<E>getRootElements(org.eclipse.emf.ecore.resource.Resource resource, Class<E> type)
Get the root model elements.static <E extends org.eclipse.emf.ecore.EObject>
List<E>getRootElements(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, Class<E> type)
Get the root model elements.static boolean
isPathmap(org.eclipse.emf.common.util.URI uri)
Determines whether this URI is a path map URI.static boolean
isPlatformResource(org.eclipse.emf.ecore.resource.Resource resource)
Decide whether a resource is a platform resource.static <V extends org.eclipse.emf.ecore.EObject>
VloadElement(org.eclipse.emf.common.util.URI uri)
Load a resource based on aURI
and return its root element.static org.eclipse.emf.ecore.resource.Resource
loadResource(org.eclipse.emf.common.util.URI uri)
Load a resource based on aURI
.static org.eclipse.emf.ecore.resource.ResourceSet
loadResourceSet(String fileName)
Load EMF model based on file name (use the packages already added to the registry).static org.eclipse.emf.ecore.resource.ResourceSet
loadResourceSet(String fileName, List<org.eclipse.emf.ecore.EPackage> ePackages)
Load EMF model based on file name and root packages.static org.eclipse.emf.ecore.resource.ResourceSet
loadResourceSet(List<org.eclipse.emf.common.util.URI> modelURIs, List<org.eclipse.emf.ecore.EPackage> ePackages)
Load EMF model based on a set ofURI
and root packages.static org.eclipse.emf.ecore.resource.ResourceSet
loadResourceSet(List<org.eclipse.emf.common.util.URI> modelURIs, List<org.eclipse.emf.ecore.EPackage> ePackages, IResourceSetFactory resourceSetFactory)
Load EMF model based on a set ofURI
and root packages.static void
loadResourceSet(List<org.eclipse.emf.common.util.URI> modelURIs, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
static org.eclipse.emf.ecore.resource.ResourceSet
loadResourceSet(org.eclipse.emf.common.util.URI modelURI)
Load EMF model based onURI
.static org.eclipse.emf.ecore.resource.ResourceSet
loadResourceSet(org.eclipse.emf.common.util.URI modelURI, List<org.eclipse.emf.ecore.EPackage> ePackages)
Load EMF model based onURI
and root packages.static Map<String,org.eclipse.emf.ecore.EPackage>
register(List<org.eclipse.emf.ecore.EPackage> ePackages, org.eclipse.emf.ecore.EPackage.Registry registry)
Recursively register packages to a registry.static void
resolveAll(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Resolve all referenced resources within aResourceSet
.static org.eclipse.emf.ecore.resource.Resource
saveElement(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.EObject element)
Save an element to aURI
and return the resource.static void
saveResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, Map<String,Object> options)
Save model based onResourceSet
.
-
-
-
Field Detail
-
PLATFORM_SCHEME
public static final String PLATFORM_SCHEME
Scheme for platform resources.- See Also:
- Constant Field Values
-
ECORE_FILE_EXTENSION
public static final String ECORE_FILE_EXTENSION
File extension for Ecore model.- See Also:
- Constant Field Values
-
-
Method Detail
-
loadResourceSet
public static org.eclipse.emf.ecore.resource.ResourceSet loadResourceSet(org.eclipse.emf.common.util.URI modelURI, List<org.eclipse.emf.ecore.EPackage> ePackages) throws IOException
Load EMF model based onURI
and root packages.- Throws:
IOException
-
loadResourceSet
public static org.eclipse.emf.ecore.resource.ResourceSet loadResourceSet(List<org.eclipse.emf.common.util.URI> modelURIs, List<org.eclipse.emf.ecore.EPackage> ePackages) throws IOException
Load EMF model based on a set ofURI
and root packages.- Throws:
IOException
-
loadResourceSet
public static void loadResourceSet(List<org.eclipse.emf.common.util.URI> modelURIs, org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws IOException
- Throws:
IOException
-
loadResourceSet
public static org.eclipse.emf.ecore.resource.ResourceSet loadResourceSet(List<org.eclipse.emf.common.util.URI> modelURIs, List<org.eclipse.emf.ecore.EPackage> ePackages, IResourceSetFactory resourceSetFactory) throws IOException
Load EMF model based on a set ofURI
and root packages.- Throws:
IOException
-
loadResourceSet
public static org.eclipse.emf.ecore.resource.ResourceSet loadResourceSet(org.eclipse.emf.common.util.URI modelURI) throws IOException
Load EMF model based onURI
.- Throws:
IOException
-
register
public static Map<String,org.eclipse.emf.ecore.EPackage> register(List<org.eclipse.emf.ecore.EPackage> ePackages, org.eclipse.emf.ecore.EPackage.Registry registry)
Recursively register packages to a registry.
-
loadResourceSet
public static org.eclipse.emf.ecore.resource.ResourceSet loadResourceSet(String fileName, List<org.eclipse.emf.ecore.EPackage> ePackages) throws IOException
Load EMF model based on file name and root packages.- Throws:
IOException
-
loadResourceSet
public static org.eclipse.emf.ecore.resource.ResourceSet loadResourceSet(String fileName) throws IOException
Load EMF model based on file name (use the packages already added to the registry).- Throws:
IOException
-
saveResourceSet
public static void saveResourceSet(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, Map<String,Object> options) throws IOException
Save model based onResourceSet
.- Throws:
IOException
-
isPathmap
public static boolean isPathmap(org.eclipse.emf.common.util.URI uri)
Determines whether this URI is a path map URI.
-
loadResource
public static org.eclipse.emf.ecore.resource.Resource loadResource(org.eclipse.emf.common.util.URI uri) throws IOException
Load a resource based on aURI
.- Throws:
IOException
-
loadElement
public static <V extends org.eclipse.emf.ecore.EObject> V loadElement(org.eclipse.emf.common.util.URI uri) throws IOException
Load a resource based on aURI
and return its root element.- Throws:
IOException
-
saveElement
public static org.eclipse.emf.ecore.resource.Resource saveElement(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.EObject element) throws IOException
Save an element to aURI
and return the resource.- Throws:
IOException
-
exists
public static boolean exists(org.eclipse.emf.common.util.URI uri) throws IOException
Check whether a file exists for a certain URI.- Throws:
IOException
-
getRootElements
public static <E extends org.eclipse.emf.ecore.EObject> List<E> getRootElements(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, Class<E> type)
Get the root model elements.
-
getRootElements
public static <E extends org.eclipse.emf.ecore.EObject> List<E> getRootElements(org.eclipse.emf.ecore.resource.Resource resource, Class<E> type)
Get the root model elements.
-
isPlatformResource
public static boolean isPlatformResource(org.eclipse.emf.ecore.resource.Resource resource)
Decide whether a resource is a platform resource.
-
resolveAll
public static void resolveAll(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Resolve all referenced resources within aResourceSet
.
-
-