XMIModelAdapter.java :  » UML » model-analysis-framework » de » uniAugsburg » MAF » core » adapter » model » Java Open Source

Java Open Source » UML » model analysis framework 
model analysis framework » de » uniAugsburg » MAF » core » adapter » model » XMIModelAdapter.java
/**
 * File: EcoreModelAdapter.java Created: 30.07.2009
 * 
 * /****************************************************************************
 * *** Copyright (c) 2009-2010 University of Augsburg, Germany <www.ds-lab.org>
 * 
 * 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: Christian Saad, Programming distributed Systems Lab, University
 * of Augsburg - initial API and implementation
 *******************************************************************************/
package de.uniAugsburg.MAF.core.adapter.model;

import java.io.IOException;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;



/**
 * A wrapper the contains a model and its metainformation. To load the model,
 * the existing metamodel resource is cloned and enriched with the model
 * elements which are loaded from the model file.
 */
public class XMIModelAdapter extends ModelAdapter
{

  /**
   * The constructor.
   * 
   * @param modelSources
   * @param modelID
   * @param metamodelID
   */
  public XMIModelAdapter(Map<URI, Object> modelSources, String modelID, String metamodelID)
  {
    super(modelSources, modelID, metamodelID);
  }


  public XMIModelAdapter(Map<URI, Object> modelSources, String modelID, String metamodelID,
      boolean autoloaded)
  {
    super(modelSources, modelID, metamodelID, autoloaded);
  }


  /*
   * (non-Javadoc)
   * 
   * @see
   * de.uniAugsburg.MAF.core.adapter.AModelAdapter#loadEMFResource(org.eclipse
   * .emf.ecore.resource.Resource)
   */
  @Override
  protected void loadIntoEMFResource(Map<Integer, EClass> metaModelClassMap,
      Resource targetResource, Map<EObject, Object> targetTraceMap, Object source)
      throws IOException
  {
    // note: don't need source since URI equals filename

    // register file extension
    targetResource.getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap()
        .put(targetResource.getURI().fileExtension(), new XMIResourceFactoryImpl());

    // load the resource from disk
    targetResource.load(null);
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.