|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.emf.compare.util.ModelUtils
public final class ModelUtils
Utility class for model loading/saving and serialization.
Method Summary | |
---|---|
static org.eclipse.emf.ecore.resource.Resource |
attachResource(org.eclipse.emf.common.util.URI resourceURI,
org.eclipse.emf.ecore.EObject root)
Attaches the given EObject to a new resource created in a new ResourceSet with the
given URI. |
static org.eclipse.emf.ecore.resource.Resource |
attachResource(org.eclipse.emf.common.util.URI resourceURI,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.ecore.EObject root)
Attaches the given EObject to a new resource created in the given ResourceSet with the
given URI. |
static boolean |
contains(org.eclipse.emf.ecore.resource.Resource resource,
org.eclipse.emf.ecore.EObject eObject)
Checks whether the given resource contains the given object by searching its complete contents ( Resource.getAllContents() ). |
static org.eclipse.emf.ecore.resource.Resource |
createResource(org.eclipse.emf.common.util.URI modelURI)
This will create a Resource given the model extension it is intended for. |
static org.eclipse.emf.ecore.resource.Resource |
createResource(org.eclipse.emf.common.util.URI modelURI,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
This will create a Resource given the model extension it is intended for and a ResourceSet. |
static java.lang.String |
getCommonExtension(org.eclipse.emf.common.util.URI... uris)
This will try and find the common file extension for the compared models. |
static java.lang.String |
getCommonNamespace(org.eclipse.emf.ecore.resource.Resource... resources)
This will try to find the common namespace of the given resources. |
static java.util.List<org.eclipse.emf.ecore.EObject> |
getModelsFrom(java.io.File directory,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Loads the models contained by the given directory in the given ResourceSet. |
static java.util.List<org.eclipse.emf.ecore.EObject> |
getModelsFrom(java.io.File directory,
java.lang.String extension,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Loads the files with the given extension contained by the given directory as EObjects in the given ResourceSet. |
static org.eclipse.emf.ecore.EObject |
load(java.io.File file,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Loads a model from a File in a given ResourceSet . |
static org.eclipse.emf.ecore.EObject |
load(java.io.InputStream stream,
java.lang.String fileName,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Load a model from an InputStream in a given ResourceSet . |
static org.eclipse.emf.ecore.EObject |
load(java.lang.String path,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Loads a model from the String representing the location of a model. |
static org.eclipse.emf.ecore.EObject |
load(org.eclipse.emf.common.util.URI modelURI,
org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Loads a model from an URI in a given ResourceSet . |
static void |
save(org.eclipse.emf.ecore.EObject root,
java.lang.String path)
Saves a model as a file to the given path. |
static java.lang.String |
serialize(org.eclipse.emf.ecore.EObject root)
Serializes the given EObjet as a String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static org.eclipse.emf.ecore.resource.Resource attachResource(org.eclipse.emf.common.util.URI resourceURI, org.eclipse.emf.ecore.EObject root)
EObject
to a new resource created in a new ResourceSet
with the
given URI.
resourceURI
- URI of the new resource to create.root
- EObject to attach to a new resource.
public static org.eclipse.emf.ecore.resource.Resource attachResource(org.eclipse.emf.common.util.URI resourceURI, org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.ecore.EObject root)
EObject
to a new resource created in the given ResourceSet
with the
given URI.
resourceURI
- URI of the new resource to create.resourceSet
- ResourceSet in which to create the resource.root
- EObject to attach to a new resource.
public static org.eclipse.emf.ecore.resource.Resource createResource(org.eclipse.emf.common.util.URI modelURI)
Resource
given the model extension it is intended for.
modelURI
- URI
where the model is stored.
Resource
given the model extension it is intended for.public static org.eclipse.emf.ecore.resource.Resource createResource(org.eclipse.emf.common.util.URI modelURI, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Resource
given the model extension it is intended for and a ResourceSet.
modelURI
- URI
where the model is stored.resourceSet
- The ResourceSet
to load the model in.
Resource
given the model extension it is intended for.public static java.lang.String getCommonExtension(org.eclipse.emf.common.util.URI... uris)
uris
- The resource URIs that will be compared.
null
if file
extensions are distinct.public static java.lang.String getCommonNamespace(org.eclipse.emf.ecore.resource.Resource... resources)
resources
- The resources that will be compared.
null
if namespaces
are distinct.public static java.util.List<org.eclipse.emf.ecore.EObject> getModelsFrom(java.io.File directory, org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.io.IOException
If resourceSet
is null
, all models will be loaded in a new resourceSet.
directory
- The directory from which to load the models.resourceSet
- The ResourceSet
to load the model in. If null
, all models will be
loaded in a new resourceSet.
java.io.IOException
- Thrown if an I/O operation has failed or been interrupted.public static java.util.List<org.eclipse.emf.ecore.EObject> getModelsFrom(java.io.File directory, java.lang.String extension, org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.io.IOException
If resourceSet
is null
, all models will be loaded in a new resourceSet.
The argument extension
is in fact the needed suffix for its name in order for a file to be
loaded. If it is equal to "rd", a file named "model.aird" will be loaded, but so
would be a file named "Shepherd".
The empty String or null
will result in all the files of the given directory to be loaded,
and would then be equivalent to #getModelsFrom(File)
.
directory
- The directory from which to load the models.extension
- File extension of the files to load. If null
, will consider all extensions.resourceSet
- The ResourceSet
to load the model in. If null
, all models will be
loaded in a new resourceSet.
java.io.IOException
- Thrown if an I/O operation has failed or been interrupted.public static org.eclipse.emf.ecore.EObject load(java.io.File file, org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.io.IOException
File
in a given ResourceSet
.
This will return the first root of the loaded model, other roots can be accessed via the resource's content.
file
- File
containing the model to be loaded.resourceSet
- The ResourceSet
to load the model in.
java.io.IOException
- If the given file does not exist.public static org.eclipse.emf.ecore.EObject load(java.io.InputStream stream, java.lang.String fileName, org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.io.IOException
InputStream
in a given ResourceSet
.
This will return the first root of the loaded model, other roots can be accessed via the resource's content.
stream
- The inputstream to load fromfileName
- The original filenameresourceSet
- The ResourceSet
to load the model in.
java.io.IOException
- If the given file does not exist.public static org.eclipse.emf.ecore.EObject load(java.lang.String path, org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.io.IOException
This can be called with pathes of the form
/pluginID/path
platform:/plugin/pluginID/path
platform:/resource/pluginID/path
This will return the first root of the loaded model, other roots can be accessed via the resource's content.
path
- Location of the model.resourceSet
- The ResourceSet
to load the model in.
java.io.IOException
- If the path doesn't resolve to a reachable location.public static org.eclipse.emf.ecore.EObject load(org.eclipse.emf.common.util.URI modelURI, org.eclipse.emf.ecore.resource.ResourceSet resourceSet) throws java.io.IOException
URI
in a given ResourceSet
.
This will return the first root of the loaded model, other roots can be accessed via the resource's content.
modelURI
- URI
where the model is stored.resourceSet
- The ResourceSet
to load the model in.
java.io.IOException
- If the given file does not exist.public static void save(org.eclipse.emf.ecore.EObject root, java.lang.String path) throws java.io.IOException
root
- Root of the objects to be serialized in a file.path
- File where the objects have to be saved.
java.io.IOException
- Thrown if an I/O operation has failed or been interrupted during the saving process.public static java.lang.String serialize(org.eclipse.emf.ecore.EObject root) throws java.io.IOException
root
- Root of the objects to be serialized.
java.io.IOException
- Thrown if an I/O operation has failed or been interrupted during the saving process.public static boolean contains(org.eclipse.emf.ecore.resource.Resource resource, org.eclipse.emf.ecore.EObject eObject)
Resource.getAllContents()
).
resource
- The resource whose contents is to be processed.eObject
- The object to be evaluated.
true
if the resource contains the eObject, false
otherwise.
|
Copyright 2006 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |