Package org.andromda.repositories.emf.uml2

Source Code of org.andromda.repositories.emf.uml2.EMXProxyResolvingResourceSet

package org.andromda.repositories.emf.uml2;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

/**
* Special resource set implementation that can resolve proxies
* created by Rational Software Modeler. RSM uses a special syntax
* (e.g. "resource.emx#someXmiId?someNonstandardString") that cannot
* be resolved by standard EMF resource sets.
*
* @author Matthias Bohlen
*
*/
public class EMXProxyResolvingResourceSet extends ResourceSetImpl
{
    public EObject getEObject(URI uri, boolean loadOnDemand)
    {
        EObject possiblyResolvedObject = super.getEObject(uri, loadOnDemand);
        if (possiblyResolvedObject == null)
        {
            // if it is still a proxy, try this special fix for RSM:
            String uriString = uri.toString();
            int separatorIndex = uriString.lastIndexOf('?');
            if (separatorIndex > 0)
            {
                uriString = uriString.substring(0, separatorIndex);
                possiblyResolvedObject = super.getEObject(URI.createURI(uriString), loadOnDemand);
            }
        }
        return possiblyResolvedObject;
    }

}
TOP

Related Classes of org.andromda.repositories.emf.uml2.EMXProxyResolvingResourceSet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.