public final class EcoreResourceUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.ecore.resource.Resource resource)
The
Resource provided as argument will be added to the given ResourceSet if it is not already inside. |
static org.eclipse.emf.ecore.resource.Resource |
addNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
java.lang.String contentTypeId,
org.eclipse.emf.ecore.EObject content)
Create the new model given by the
content object parameter. |
static org.eclipse.emf.ecore.resource.Resource |
addNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
java.lang.String contentTypeId,
java.util.List<org.eclipse.emf.ecore.EObject> contents)
Create the new model given by the list of
content objects parameter. |
static org.eclipse.emf.common.util.URI |
convertToAbsoluteFileURI(org.eclipse.emf.common.util.URI uri)
Converts given
URI into an absolute file URI . |
static org.eclipse.emf.common.util.URI |
convertToPlatformResourceURI(org.eclipse.emf.common.util.URI uri)
Converts given URI into a platform resource URI.
|
static boolean |
exists(org.eclipse.emf.common.util.URI uri)
Proves if resource specified by an URI exists.
|
static java.lang.String |
getContentTypeId(org.eclipse.emf.common.util.URI uri)
Returns the id of the content type of the file behind given
URI . |
static java.util.Map<?,?> |
getDefaultLoadOptions()
Returns a set of default options which can be used for loading a Resource.
|
static java.util.Map<?,?> |
getDefaultSaveOptions()
Returns a map with the default options for resource saving.
|
static org.eclipse.emf.ecore.EObject |
getEObject(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri)
Retrieves the model
object referenced by provided URI from given resource set . |
static org.eclipse.emf.ecore.EObject |
getModelFragment(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri)
Deprecated.
Use
getEObject(ResourceSet, URI) instead. |
static org.eclipse.emf.ecore.EObject |
getModelFragment(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
boolean loadOnDemand)
Deprecated.
Use
loadEObject(ResourceSet, URI) for loading model fragments or
getEObject(ResourceSet, URI) for accessing already loaded model fragments instead. |
static java.lang.String |
getModelName(org.eclipse.emf.common.notify.Notifier notifier)
Returns the name of the model behind provided model object.
|
static org.eclipse.emf.ecore.EObject |
getModelRoot(org.eclipse.emf.ecore.resource.Resource resource)
Deprecated.
Inline this method in client code and adapt it as needed.
|
static org.eclipse.emf.ecore.EObject |
getModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri)
Deprecated.
Use
ResourceSet.getResource(URI, boolean) or getEObject(ResourceSet, URI) instead. |
static org.eclipse.emf.ecore.EObject |
getModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
boolean loadOnDemand)
Deprecated.
Use
loadModelRoot(ResourceSet, URI, Map) for loading models or
getModelRoot(ResourceSet, URI) for accessing already loaded models instead. |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.ecore.EObject eObject)
Retrieves the resource corresponding to the given
object . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
Retrieves the resource matching the given
entry . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(org.eclipse.emf.edit.provider.IWrapperItemProvider provider)
Retrieves the resource owning the given
provider . |
static org.eclipse.emf.ecore.resource.Resource |
getResource(java.lang.Object object)
Returns the resource corresponding to the specified object.
|
static org.eclipse.emf.ecore.resource.Resource |
getResource(TransientItemProvider provider)
Retrieves the resource owning the given
provider . |
static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> |
getResourceContents(org.eclipse.emf.ecore.resource.Resource resource)
Returns the contents of given Resource.
|
static org.eclipse.emf.common.util.URI |
getURI(org.eclipse.emf.ecore.EObject eObject)
Returns the URI of the provided model object.
|
static org.eclipse.emf.common.util.URI |
getURI(org.eclipse.emf.ecore.EObject eObject,
boolean resolve)
Returns the URI of the provided model object.
|
static org.eclipse.emf.ecore.resource.URIConverter |
getURIConverter()
Returns an instance of
ExtensibleURIConverterImpl where the URI mappings are initialized in such a way
that normalization of non-platform:/resource URI s which reference resources inside the workspace yields
the corresponding platform:/resource URI s. |
static org.eclipse.emf.ecore.resource.URIConverter |
getURIConverter(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
Returns the
URI converter of given resource set . |
static boolean |
isEMFModelURI(org.eclipse.emf.common.util.URI uri)
Check if provided URI representing a file or object is an EMF model or not.
|
static boolean |
isReadOnly(org.eclipse.emf.common.util.URI uri)
Determines if
resource behind specified URI is read-only. |
static boolean |
isResourceLoaded(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri)
Proves if the model with the specified
uri is already loaded into the given resourceSet . |
static org.eclipse.emf.ecore.EObject |
loadEObject(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri)
Retrieves the model
object referenced by provided URI from given resource set . |
static org.eclipse.emf.ecore.EObject |
loadModelFragment(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri)
Deprecated.
Use
loadEObject(ResourceSet, URI) instead. |
static org.eclipse.emf.ecore.EObject |
loadModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.io.File file,
java.util.Map<?,?> options)
Deprecated.
Use
loadResource(ResourceSet, File, Map) or loadEObject(ResourceSet, URI) instead. |
static org.eclipse.emf.ecore.EObject |
loadModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
java.util.Map<?,?> options)
Deprecated.
Use
loadResource(ResourceSet, URI, Map) or loadEObject(ResourceSet, URI) instead. |
static org.eclipse.emf.ecore.resource.Resource |
loadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
java.io.File file,
java.util.Map<?,?> options)
Loads the
resource referred to by given file . |
static org.eclipse.emf.ecore.resource.Resource |
loadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
java.util.Map<?,?> options)
Loads the
resource referred to by given URI . |
static java.lang.String |
readModelNamespace(org.eclipse.emf.ecore.resource.Resource resource)
Reads the model namespace (i.e.
|
static java.lang.String |
readModelNamespace(org.eclipse.emf.ecore.resource.URIConverter uriConverter,
org.eclipse.emf.common.util.URI uri)
Reads the model namespace (i.e.
|
static java.util.Collection<java.lang.String> |
readRootElementComments(org.eclipse.emf.ecore.resource.Resource resource)
Retrieves the XML comments located above the root element in given
resource . |
static java.util.Collection<java.lang.String> |
readRootElementComments(org.eclipse.emf.ecore.resource.URIConverter uriConverter,
org.eclipse.emf.common.util.URI uri)
Retrieves the XML comments located above the root element in resource behind given
URI . |
static java.util.Map<java.lang.String,java.lang.String> |
readSchemaLocationEntries(org.eclipse.emf.ecore.resource.Resource resource)
Reads the XSI schema location of given
resource and extracts pairs of namespace and schema URIs
from it (see http://www.w3.org/TR/xmlschema-0/#schemaLocation for details). |
static java.util.Map<java.lang.String,java.lang.String> |
readSchemaLocationEntries(org.eclipse.emf.ecore.resource.URIConverter uriConverter,
org.eclipse.emf.common.util.URI uri)
Reads the XSI schema location of the resource behind given
URI and extracts pairs of namespace and schema
URIs from it (see http://www.w3.org/TR/xmlschema-0/#schemaLocation for details). |
static java.lang.String |
readTargetNamespace(org.eclipse.emf.ecore.resource.Resource resource)
Reads the target namespace of given
resource . |
static java.lang.String |
readTargetNamespace(org.eclipse.emf.ecore.resource.Resource resource,
java.lang.String... targetNamespaceExcludePatterns) |
static java.lang.String |
readTargetNamespace(org.eclipse.emf.ecore.resource.URIConverter uriConverter,
org.eclipse.emf.common.util.URI uri)
Reads the target namespace of the resource behind given
URI . |
static java.lang.String |
readTargetNamespace(org.eclipse.emf.ecore.resource.URIConverter uriConverter,
org.eclipse.emf.common.util.URI uri,
java.lang.String... targetNamespaceExcludePatterns) |
static void |
saveModelResource(org.eclipse.emf.ecore.resource.Resource resource,
java.util.Map<?,?> options)
Saves the specified
resource . |
static void |
saveNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
java.lang.String contentTypeId,
org.eclipse.emf.ecore.EObject content,
java.util.Map<?,?> options)
Saves the new model given by the
content object parameter. |
static void |
saveNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
java.lang.String contentTypeId,
java.util.List<org.eclipse.emf.ecore.EObject> contents,
java.util.Map<?,?> options)
Saves the new model given by the list of
content objects parameter. |
static void |
unloadResource(org.eclipse.emf.ecore.resource.Resource resource)
Unloads given
resource and removes it from underlying resourceSet . |
static void |
unloadResource(org.eclipse.emf.ecore.resource.Resource resource,
boolean memoryOptimized)
Unloads given
resource and removes it from underlying resourceSet . |
static void |
unloadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri)
Unloads the resource with the specified URI from the given resource set.
|
static void |
unloadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
org.eclipse.emf.common.util.URI uri,
boolean memoryOptimized)
Unloads the resource with the specified URI from the given resource set.
|
static void |
validate(org.eclipse.emf.common.util.URI uri,
java.net.URL schemaURL)
Parses
resource with given uri and validates it against XSD schema with specified
url . |
public static org.eclipse.emf.ecore.resource.URIConverter getURIConverter()
ExtensibleURIConverterImpl
where the URI mappings are initialized in such a way
that normalization of non-platform:/resource URI
s which reference resources inside the workspace yields
the corresponding platform:/resource URI
s.ExtensibleURIConverterImpl
containing URI mappings for normalizing
non-platform:/resource URI
s referencing workspace resources to corresponding platform:/resource
URI
s.public static org.eclipse.emf.ecore.resource.URIConverter getURIConverter(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
URI converter
of given resource set
. If no
resource set
is provided an instance of ExtensibleURIConverterImpl
is returned
instead. In both cases, the URI converter
's URI mappings are initialized in such a way that
normalization of non-platform:/resource URI
s which reference resources inside the workspace yields the
corresponding platform:/resource URI
s.resourceSet
- The resource set
whose URI converter
is to be retrieved.URI converter
of given resource set
, or an instance of
ExtensibleURIConverterImpl
if no such is provided, containing URI mappings for normalizing
non-platform:/resource URI
s referencing workspace resources to corresponding platform:/resource
URI
s.public static org.eclipse.emf.common.util.URI convertToAbsoluteFileURI(org.eclipse.emf.common.util.URI uri)
URI
into an absolute file URI
.uri
- The URI
to be converted.URI
for the given URI
or given URI
if no conversion is possible.public static org.eclipse.emf.common.util.URI convertToPlatformResourceURI(org.eclipse.emf.common.util.URI uri)
uri
- The URI
to be converted.public static boolean exists(org.eclipse.emf.common.util.URI uri)
uri
- The URI to prove Returns true only if the URI represents a file and if this file exists.public static boolean isEMFModelURI(org.eclipse.emf.common.util.URI uri)
uri
- the URI representing a model file or model object.true
if provided URI correspond to an EMF model. Otherwise false
.public static org.eclipse.emf.common.util.URI getURI(org.eclipse.emf.ecore.EObject eObject)
eObject
- a model object.public static org.eclipse.emf.common.util.URI getURI(org.eclipse.emf.ecore.EObject eObject, boolean resolve)
eObject
- a model object.resolve
- indicates whether the URI should be resolved against the URI of the resource which contains the
provided model object. This is useful is cases where the native model object URI evaluates in some
sort of fragment-based URI which does not contain any information about the resource that contains the
model object (e.g., hb:/#//MyComponent/MyParameterValue). By setting resolve to true, such
fragment-based URIs will be automatically expanded to a URI that starts with the URI of the model
object's resource and is followed by the fragment of the model object's native URI (e.g.,
platform:/resource/MyProject/MyResource/#//MyComponent/MyParameterValue).public static java.lang.String getContentTypeId(org.eclipse.emf.common.util.URI uri)
URI
.uri
- The URI
whose content type id is to be established.URI
, or null
if given
URI
references a resource which is no file (e.g., a folder or project), or a file that does not
exist or has no content type.public static boolean isReadOnly(org.eclipse.emf.common.util.URI uri)
resource
behind specified URI
is read-only. Returns false
if
this resource does not exist.uri
- The URI
identifying the resource
to be investigated.true
if resource
behind specified URI
is read-only, and
false
otherwise.public static java.lang.String readModelNamespace(org.eclipse.emf.ecore.resource.Resource resource)
resource
. Returns a meaningful result
only if given resource
is an XML document.resource
- The resource
to investigate.resource
or null
if the
resource
is either a non-XML file or an XML file which is not well-formed or has no
model namespace.public static java.lang.String readModelNamespace(org.eclipse.emf.ecore.resource.URIConverter uriConverter, org.eclipse.emf.common.util.URI uri)
URI
. Returns a meaningful result
only if the resource in question is an XML document.uriConverter
- The uriConverter
used to create inputstream
. May be
null
.uri
- The uri
of the resource to investigate.URI
or null
if the resource in
question is either a non-XML file or an XML file which is not well-formed or has no model namespace.public static java.lang.String readTargetNamespace(org.eclipse.emf.ecore.resource.Resource resource)
resource
. Returns a meaningful result only if given
resource
is an XML document.resource
- The resource
to investigate.resource
or null
if the
resource
is either a not an XML file or an XML file which is not well-formed or has no
target namespace.public static java.lang.String readTargetNamespace(org.eclipse.emf.ecore.resource.Resource resource, java.lang.String... targetNamespaceExcludePatterns)
public static java.lang.String readTargetNamespace(org.eclipse.emf.ecore.resource.URIConverter uriConverter, org.eclipse.emf.common.util.URI uri)
URI
. Returns a meaningful result only if the
resource in question is an XML document.uriConverter
- The uriConverter
used to create input stream
. May be
null
.uri
- The uri
of the resource to investigate.URI
or null
if the resource in
question is either a not an XML file or an XML file which is not well-formed or has no target namespace.public static java.lang.String readTargetNamespace(org.eclipse.emf.ecore.resource.URIConverter uriConverter, org.eclipse.emf.common.util.URI uri, java.lang.String... targetNamespaceExcludePatterns)
public static java.util.Collection<java.lang.String> readRootElementComments(org.eclipse.emf.ecore.resource.Resource resource)
resource
. Returns a
meaningful result only if given resource
is an XML document.resource
- The resource
to investigate.public static java.util.Collection<java.lang.String> readRootElementComments(org.eclipse.emf.ecore.resource.URIConverter uriConverter, org.eclipse.emf.common.util.URI uri)
URI
. Returns a
meaningful result only if the resource in question is an XML document.uriConverter
- The uriConverter
used to create input stream
. May be
null
.uri
- The uri
of the resource to investigate.public static java.util.Map<java.lang.String,java.lang.String> readSchemaLocationEntries(org.eclipse.emf.ecore.resource.Resource resource)
resource
and extracts pairs of namespace and schema URIs
from it (see http://www.w3.org/TR/xmlschema-0/#schemaLocation for details). Returns a meaningful result only if
given resource
is an XML document.resource
- The resource
to investigate.resource
or an empty map if the
resource
is either a non-XML file or an XML file which is not well-formed or has no XSI
schema location.public static java.util.Map<java.lang.String,java.lang.String> readSchemaLocationEntries(org.eclipse.emf.ecore.resource.URIConverter uriConverter, org.eclipse.emf.common.util.URI uri)
URI
and extracts pairs of namespace and schema
URIs from it (see http://www.w3.org/TR/xmlschema-0/#schemaLocation for details). Returns a meaningful result only
if the resource in question is an XML document.uriConverter
- The uriConverter
used to create input stream
. May be
null
.uri
- The uri
of the resource
to investigate.URI
or an empty map if the resource
in question is either a non-XML file or an XML file which is not well-formed or has no XSI schema
location.public static java.util.Map<?,?> getDefaultLoadOptions()
public static java.util.Map<?,?> getDefaultSaveOptions()
@Deprecated public static org.eclipse.emf.ecore.EObject getModelRoot(org.eclipse.emf.ecore.resource.Resource resource)
object
contained by given resource.resource
- Some model resourcenull
if the resource has not been loaded yet
or contains no or multiple root objects.@Deprecated public static org.eclipse.emf.ecore.EObject getModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)
resourceSet
- The resource set into which model resource must be loaded.uri
- The URI to resolve; i.e. the URI of the model resource to load.null
if the resource has not been loaded
yet or contains no or multiple root objects.@Deprecated public static org.eclipse.emf.ecore.EObject getModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, boolean loadOnDemand)
loadModelRoot(ResourceSet, URI, Map)
for loading models or
getModelRoot(ResourceSet, URI)
for accessing already loaded models instead.resourceSet
- The resource set into which model resource must be loaded.uri
- The URI to resolve; i.e. the URI of the model resource to load.loadOnDemand
- If true
, creates and loads the resource if it does not already exist.loadOnDemand
is true
;
null
if underlying resource has not been loaded and loadOnDemand
is false.@Deprecated public static org.eclipse.emf.ecore.EObject loadModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, java.util.Map<?,?> options)
resourceSet
- The resource set into which model resource must be loaded.uri
- The URI to resolve; i.e. the URI of the model resource to load.options
- The load options. If null
, default load options are used.null
if resource has not been
loaded yet or contains no or multiple root objects.@Deprecated public static org.eclipse.emf.ecore.EObject loadModelRoot(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.io.File file, java.util.Map<?,?> options) 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.
resourceSet
- The ResourceSet
to load the model in.file
- File
containing the model to be loaded.options
- Optional custom load options to be used for loading the resource. May be set to null
if
not such are needed.null
if the file has not been loaded yet or
contains no or multiple root objects.java.io.IOException
@Deprecated public static org.eclipse.emf.ecore.EObject getModelFragment(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)
getEObject(ResourceSet, URI)
instead.@Deprecated public static org.eclipse.emf.ecore.EObject getModelFragment(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, boolean loadOnDemand)
loadEObject(ResourceSet, URI)
for loading model fragments or
getEObject(ResourceSet, URI)
for accessing already loaded model fragments instead.resourceSet
- The resource set into which model resource must be loaded.uri
- The URI to resolve; i.e. the URI of the model resource to load.loadOnDemand
- If true
, creates and loads the resource if it does not already exist.true
; null
if underlying resource has not been loaded and
loadOnDemand
is false
.@Deprecated public static org.eclipse.emf.ecore.EObject loadModelFragment(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)
loadEObject(ResourceSet, URI)
instead.public static org.eclipse.emf.ecore.EObject getEObject(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)
object
referenced by provided URI
from given resource set
. Returns null
if the resource
containing the model object referenced
by the URI has not yet been loaded into the resource set.resourceSet
- The resource set from which the model object is to be retrieved.uri
- The URI that identifies the model object to be retrieved.null
if the
referenced model object does not exist in underlying resource or the latter has not yet been loaded into
the resource set.public static org.eclipse.emf.ecore.EObject loadEObject(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)
object
referenced by provided URI
from given resource set
. Loads the resource
containing the model object referenced by the URI into the
resource set if this has not yet been done.resourceSet
- The resource set from which the model object is to be retrieved.uri
- The URI that identifies the model object to be retrieved.null
if referenced
model object does not exist in underlying resource.public static org.eclipse.emf.ecore.resource.Resource getResource(java.lang.Object object)
The supported object types are:
If the type of the specified object does not belongs to that list of supported types, null
is
returned.
object
- The object from which a resource must be returned.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.ecore.EObject eObject)
object
.eObject
- The object whose resource
is to be returned.object
.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.edit.provider.IWrapperItemProvider provider)
provider
.
First retrieves the owner of the provider
; then, if owner is an EObject
returns its resource, else delegates to getResource(Object).
provider
- The IWrapperItemProvider whose resource must be returned.provider
; null
if that
provider is null
.public static org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.ecore.util.FeatureMap.Entry entry)
entry
.
First unwraps the entry
; then, delegates to getResource(Object).
entry
- The FeatureMap.Entry whose underlying resource must be returned.entry
.public static org.eclipse.emf.ecore.resource.Resource getResource(TransientItemProvider provider)
provider
.
First retrieves the owner of the provider
; then, if owner is an
EObject returns its resource, else delegates to getResource(Object).
provider
- The TransientItemProvider whose resource must be returned.provider
; null
if that
provider is null
.public static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getResourceContents(org.eclipse.emf.ecore.resource.Resource resource)
resource
- resource
or an empty list if no Resource is provided.public static org.eclipse.emf.ecore.resource.Resource loadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, java.util.Map<?,?> options)
resource
referred to by given URI
.resourceSet
- The resource set
that will contain the resource when it has been loaded.uri
- The URI of the resource to be loaded.options
- Optional custom load options to be used for loading the resource. May be set to null
if
not such are needed.loadResource(ResourceSet, File, Map)
public static org.eclipse.emf.ecore.resource.Resource loadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, java.io.File file, java.util.Map<?,?> options) throws java.io.IOException
resource
referred to by given file
.resourceSet
- The resource set
that will contain the resource when it has been loaded.file
- The file representing the resource to be loaded.options
- Custom load options. If null
, default load options are used.java.io.IOException
loadResource(ResourceSet, URI, Map)
public static boolean isResourceLoaded(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)
uri
is already loaded into the given resourceSet
.resourceSet
- The resource set to search resource in.uri
- The URI of the concerned resource.public static java.lang.String getModelName(org.eclipse.emf.common.notify.Notifier notifier)
notifier
- Can either be an EObject or a Resource.notifier
.public static org.eclipse.emf.ecore.resource.Resource addNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, java.lang.String contentTypeId, org.eclipse.emf.ecore.EObject content)
content
object parameter. The method will create a new Resource
specified by a given URI and content type id. The new created resource will be added to a given ResourceSet.resourceSet
- The ResourceSet to which the new Resource is added.uri
- The URI specifying the location to which the Resource is to be saved to.contentTypeId
- The id of the content type of which new created Resource shall be of.content
- Can either be an EObject or a Resource.public static org.eclipse.emf.ecore.resource.Resource addNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, java.lang.String contentTypeId, java.util.List<org.eclipse.emf.ecore.EObject> contents)
content
objects parameter. The method will create a new
Resource specified by a given URI and content type id. The new created resource will be added to a given
ResourceSet.resourceSet
- The ResourceSet to which the new Resource is added.uri
- The URI specifying the location to which the Resource is to be saved to.contentTypeId
- The id of the content type of which new created Resource shall be of.contents
- The set of EObjects to be use as model root objects.public static void addModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.ecore.resource.Resource resource)
Resource
provided as argument will be added to the given ResourceSet if it is not already inside.resourceSet
- The resourceSet where to add resourcesresource
- The resource to addpublic static void saveNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, java.lang.String contentTypeId, org.eclipse.emf.ecore.EObject content, java.util.Map<?,?> options)
content
object parameter. The method will create a new Resource
specified by a given URI and content type id. The new created resource will be added to a given ResourceSet and
saved.resourceSet
- The ResourceSet to which the new Resource is added.uri
- The URI specifying the location to which the Resource is to be saved to.contentTypeId
- The id of the content type of which new created Resource shall be of.content
- Can either be an EObject or a Resource.options
- The save options.getDefaultSaveOptions()
public static void saveNewModelResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, java.lang.String contentTypeId, java.util.List<org.eclipse.emf.ecore.EObject> contents, java.util.Map<?,?> options)
content
objects parameter. The method will create a new
Resource specified by a given URI and content type id. The new created resource will be added to a given
ResourceSet and saved.resourceSet
- The ResourceSet to which the new Resource is added.uri
- The URI specifying the location to which the Resource is to be saved to.contentTypeId
- The id of the content type of which new created Resource shall be of.contents
- The set of EObjects to be use as model root objects.options
- The save options.getDefaultSaveOptions()
public static void saveModelResource(org.eclipse.emf.ecore.resource.Resource resource, java.util.Map<?,?> options)
resource
.resource
- The resource
to be saved.options
- The save options.getDefaultSaveOptions()
public static void unloadResource(org.eclipse.emf.ecore.resource.Resource resource)
resource
and removes it from underlying resourceSet
.resource
- The resource to be unloaded.public static void unloadResource(org.eclipse.emf.ecore.resource.Resource resource, boolean memoryOptimized)
resource
and removes it from underlying resourceSet
.resource
- The resource to be unloaded.memoryOptimized
- Will activate the memory optimization option for unloading the resource. This is only available if the
resource is an XMLResource.public static void unloadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri)
resourceSet
- A resource set from which the model's resource should be unloaded.uri
- The URI of the resource to unload.public static void unloadResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uri, boolean memoryOptimized)
It is recommended to call this method inside a write-transaction (see
EcorePlatformUtil#unloadFile(ResourceSet, IPath)
).
resourceSet
- A resource set from which the model's resource should be unloaded.uri
- The URI of the resource to unload.memoryOptimized
- Will activate the memory optimization option for unloading the resource. This is only available if the
resource is an XMLResource.public static void validate(org.eclipse.emf.common.util.URI uri, java.net.URL schemaURL) throws org.xml.sax.SAXException, java.io.IOException
resource
with given uri
and validates it against XSD schema with specified
url
. Raises an exception if the resource
's content is not compliant with respect to
XSD schema.uri
- The uri
of the resource
to be validated.schemaURL
- The url
of the XSD schema to be used for validation.org.xml.sax.SAXException
java.io.IOException