public final class ResourceUtil extends Object
Modifier and Type | Method and Description |
---|---|
static com.google.common.base.Function<IStorage,URI> |
asURI()
|
static boolean |
binaryIdentical(IStorage left,
IStorage right)
Checks whether the two given storages point to binary identical data.
|
static boolean |
binaryIdentical(IStorage left,
IStorage right,
IStorage origin)
Checks whether the three given storages point to binary identical data.
|
static URI |
createURIFor(IFile file)
Create the URI with which we'll load the given IFile as an EMF resource.
|
static URI |
createURIFor(IStorage storage)
Create the URI with which we'll load the given IStorage as an EMF resource.
|
static IContentType[] |
getContentTypes(IFile file)
Returns the whole list of content types of the given IFile, or an empty array if none.
|
static IPath |
getFixedPath(IStorage storage)
Returns a path for this storage after fixing from an
IStoragePathProvider if one exists. |
static boolean |
hasContentType(String contentTypeId,
List<IContentType> contentTypes)
This will return
true if the given contentTypeId represents a content-type
contained in the given array. |
static boolean |
hasModelType(IFile file)
Checks whether the given file has one of the content types described in
MODEL_CONTENT_TYPES . |
static Resource |
loadResource(IStorage storage,
ResourceSet resourceSet,
Map<?,?> options)
This will try and load the given file as an EMF model, and return the corresponding
Resource if
at all possible. |
static void |
saveAllResources(ResourceSet resourceSet,
Map<?,?> options)
This can be called to save all resources contained by the resource set.
|
static void |
saveResource(Resource resource,
Map<?,?> options)
This can be called to save the given resource.
|
public static Resource loadResource(IStorage storage, ResourceSet resourceSet, Map<?,?> options)
Resource
if
at all possible.storage
- The file we need to try and load as a model.resourceSet
- The resource set in which to load this Resource.options
- The options to pass to Resource.load(java.util.Map)
.file
was a model, null
otherwise.public static boolean binaryIdentical(IStorage left, IStorage right)
left
- First of the two storages which content we are testing.right
- Second of the two storages which content we are testing.true
if left
and right
are binary identical.public static boolean binaryIdentical(IStorage left, IStorage right, IStorage origin)
binaryIdentical(IStorage, IStorage)
twice, though this implementation allows us to shortcut
whenever one byte differs... and will read one less file from its input stream.left
- First of the three storages which content we are testing.right
- Second of the three storages which content we are testing.origin
- Third of the three storages which content we are testing.true
if left
, right
and origin
are binary identical.public static URI createURIFor(IFile file)
file
- The file for which we need an EMF URI.public static URI createURIFor(IStorage storage)
storage
- The storage for which we need an EMF URI.public static IPath getFixedPath(IStorage storage)
IStoragePathProvider
if one exists.storage
- The storage for which we need a fixed full path.public static void saveAllResources(ResourceSet resourceSet, Map<?,?> options)
resourceSet
- The resource set to save.options
- The options we are to pass on to Resource.save(Map)
.public static void saveResource(Resource resource, Map<?,?> options)
resource
- The resource to save.options
- The options we are to pass on to Resource.save(Map)
.public static boolean hasContentType(String contentTypeId, List<IContentType> contentTypes)
true
if the given contentTypeId represents a content-type
contained in the given array.contentTypeId
- Fully qualified identifier of the content type we seek.contentTypes
- The array of content-types to compare against.true
if the given array contains a content-type with this id.public static boolean hasModelType(IFile file)
MODEL_CONTENT_TYPES
.file
- The file which contents are to be checked.true
if this file has one of the "model" content types.public static IContentType[] getContentTypes(IFile file)
file
- The file we need the content types of.
Copyright (c) 2006, 2014 Obeo and others. All rights reserved.