Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2015 Guillaume Hillairet.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Guillaume Hillairet - initial API and implementation
*
*/
package org.emfjson.gwt.resource;
import com.google.gwt.core.shared.GWT;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.Callback;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.URIConverter;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.emfjson.common.resource.UuidResource;
import org.emfjson.gwt.map.JsonMapper;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Resource implementation meant to be used on the client side of a
* GWT application.
*
* @author ghillairet
* @since 0.4.0
*/
public class JsonResource extends ResourceImpl implements UuidResource {
protected static final Map DETACHED_EOBJECT_TO_ID_MAP = new HashMap();
private Map idToEObjectMap;
private Map eObjectToIDMap;
public JsonResource(URI uri) {
super(uri);
}
@Override
public void load(final Map, ?> options, final Callback callback) throws IOException {
if (isLoaded && callback != null) {
callback.onSuccess(this);
return;
}
Map, ?> response = options == null ? null : (Map, ?>) options.get(URIConverter.OPTION_RESPONSE);
if (response == null) {
response = new HashMap