Skip to content

Commit

Permalink
[1301] Add support to create a JSON resource with the right scheme
Browse files Browse the repository at this point in the history
Bug: #1301
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
  • Loading branch information
lfasani committed Jul 21, 2022
1 parent 68bcebe commit 692b512
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
*/
public class EditingContext implements IEditingContext {

/**
* This scheme should be used to create an URI of a resource that corresponds to a document added in the
* EditingContext ResourceSet.
*/
public static final String RESOURCE_SCHEME = "sirius"; //$NON-NLS-1$

private final String id;

private final AdapterFactoryEditingDomain editingDomain;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@ public JsonResource createResource(URI uri) {

return new JsonResourceImpl(uri, options);
}

/**
* Create a resource which URI is made of a correct scheme and the given id as path.
*
* @param resourceId
* the id of the resource
*/
public JsonResource createResource(String resourceId) {
// There are three slashes because the URI authority is empty
URI uri = URI.createURI(EditingContext.RESOURCE_SCHEME + ":///" + resourceId); //$NON-NLS-1$

return this.createResource(uri);
}
}

0 comments on commit 692b512

Please sign in to comment.