亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? marte2cheddarxml.java

?? papyrus插件MARTE例子,uml建模
?? JAVA
字號:
package com.thalesgroup.cheddar.MARTE2cheddar;

import java.io.FileInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.atl.engine.repositories.emf4atl.ASMEMFModel;
import org.atl.engine.repositories.emf4atl.ASMEMFModelElement;
import org.atl.engine.vm.StackFrame;
import org.atl.engine.vm.nativelib.ASMString;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.util.EList;
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.ResourceSet;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.NamedElement;

import com.thalesgroup.atl.ExtendedATLProblemsManager;
import com.thalesgroup.atl.ExtendedATLTransform;
import com.thalesgroup.atl.exception.ATLException;
import com.thalesgroup.atl.marte.rsa.MARTEImplementation_RSA;
import com.thalesgroup.java.log.Log;

/**
 * This class provides all the tools to :
 * - check compatibility of a MARTE model for MARTE to Cheddar transformation
 * - run the transformations : 
 * 		- MARTE to Cheddar XML (full transform)
 * 		- MARTE to Cheddar (first step)
 * 		- Cheddar to CheddarXML (second step)
 * This transformation can handle multiple input analysis contexts.
 * (design pattern : Singleton)
 * 
 * <copyright>
 * Thales MARTE to Cheddar (Copyright (c) THALES 2007 All rights reserved) is free software; you can redistribute itand/or modify
 * it under the terms of the Eclipse Public License as published in http://www.eclipse.org/legal/epl-v10.html
 *
 * Thales MARTE to Cheddar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Eclipse Public License for more details.
 * </copyright>
 * 
 * @author Nicolas Vienne
 * @version 0.0.3, 09/2007
 *
 */
public class MARTE2CheddarXML extends ExtendedATLTransform implements IRunnableWithProgress {

	public static final String COPYRIGHT = "Copyright 2007 Thales Research and Technology";
	
	// Paths
	protected static final String BASE_PATH = "/ATL/";
	protected static final String DTD_PATH = BASE_PATH+"cheddardtdheader.xml";
	protected static final String C2X_PATH = BASE_PATH+"cheddar2XML.asm";
	protected static final String M2C_PATH = BASE_PATH+"MARTE2cheddar.asm";
	protected static final String CHECK_PATH = BASE_PATH+"CheckMARTE4cheddar.asm";
	protected static final URL transfo_m2c = MARTE2CheddarXML.class.getResource(M2C_PATH);
	protected static final URL transfo_c2x = MARTE2CheddarXML.class.getResource(C2X_PATH);
	protected static final URL transfo_check = MARTE2CheddarXML.class.getResource(CHECK_PATH);
	
	protected ExtendedATLProblemsManager apm = new ExtendedATLProblemsManager();
	
	protected static MARTE2CheddarXML instance = null;
	

	protected boolean export = true;
	protected IFile inputFile;
	protected String qualifiedName;
	protected IFile outputFile;
	
	/**
	 * Retrieves the singleton instance.
	 * @return the instance of MARTE2CheddarXML
	 */
	public static MARTE2CheddarXML getInstance() {
		
		if(instance != null) {
			return instance;
		} else {
			try {
				instance = new MARTE2CheddarXML();
			} catch (Exception exception) {
				Log.errorMessage(Activator.PLUGIN_ID, "Error while creating MARTE2CheddarXML", exception);
			}
			return instance;
		}
	}
	/**
	 * Constructeur.
	 * (Singleton - for internal use only).
	 * @throws IOException
	 * @throws ATLException 
	 */
	protected MARTE2CheddarXML() throws IOException, ATLException {
		super(null);
		enableLOG();
		enableUML();
		enableMARTE(new MARTEImplementation_RSA()); // should enable UML in the same movement
		enablePROBLEM();
		enableXMLParameters(); // should enable XML in the same movement
		addMetamodelByURI("CHEDDAR", "http:///cheddar.ecore");
		addLibrary("MARTE4CHEDDAR", MARTE2CheddarXML.class.getResource(BASE_PATH+"MARTE4CHEDDAR.asm"));
		
		addCustomOperationToVM(MARTE2CheddarXML.class, "getQName");		
	}
	
	private static Map<EObject, String> object_names = new HashMap<EObject, String>();
	private static Map<String, Integer> next_name = new HashMap<String, Integer>();
	
	public static void reset_names() {
		object_names.clear();
		next_name.clear();
	}
	
	public static ASMString getQName(StackFrame frame, ASMEMFModelElement self) {
		EObject s = self.getObject();

		if(object_names.containsKey(s)) {
			return new ASMString(object_names.get(s));
		} else {
			if(s instanceof NamedElement) {
				NamedElement ne = (NamedElement) s;
				String name = ne.getName();
				String r = name;
				if(next_name.containsKey(name)) {
					int current_id = next_name.get(name);
					r += "_"+current_id;
					next_name.put(name, current_id+1);
					
				} else {
					next_name.put(name, 2); // next id
				}
				object_names.put(s, r);
				return new ASMString(r);
			}
			else {
				return new ASMString("");
			}
		}
	}
	
	/*
	 * MARTE2Cheddar tranformation interface
	 * WARNING : 1 MARTE model to * CHEDDAR model(s)
	 */
	
	/**
	 * Inserts the Cheddar DTD in a XML String model.
	 * @return XML String model with the cheddar DTD inserted after the first ligne
	 * @param xmlstr Model as XML string
	 * @throws IOException
	 */
	protected String AddCheddarDTD(String xmlstr){
		
		String cheddarxmldtd = "";
		
		URL dtd_url = MARTE2CheddarXML.class.getResource(DTD_PATH);
		
		FileInputStream fis = null;
		
		try {
			fis = (FileInputStream) dtd_url.openStream();
			
			int c;
			do {
				c = fis.read();
				if(c != -1) {
				//if(c != 1) {
					cheddarxmldtd += (char)c;
				}
			} while( c != -1);
			
			//cheddarxmldtd = cheddarxmldtd.substring(0, cheddarxmldtd.length()-1);
			
		} catch (Exception exception) {
			Log.errorMessage(Activator.PLUGIN_ID,exception.getMessage(),exception);
		}

		int split = xmlstr.indexOf("\n");
		String cheddarxmlheader = xmlstr.substring(0, split);
		String cheddarxmlmodel = xmlstr.substring(split);
		String xmlcopy = "\n\n<!-- " + COPYRIGHT + "-->\n";
		String xmlgenerationinfo = "<!-- Generated " + new Date().toString() + "-->\n";
		String result = cheddarxmlheader.concat(xmlcopy).concat(xmlgenerationinfo).concat(cheddarxmldtd).concat(cheddarxmlmodel);
		
		return result;
	}
	
	
	protected List<String> getAnalysisContexts(IFile infile) {
		List<String> AnaCont = new ArrayList<String>();
		
		ResourceSet rs = ASMEMFModel.getResourceSet();
		Resource r = rs.getResource(URI.createPlatformResourceURI(infile.getFullPath().toString()), true);
		EList ol = r.getContents();
		for(Object o : ol ) {
			if (o instanceof Model) {
				Model m = (Model) o;
				EList moel = m.allOwnedElements();
				for(Object obj : moel) {
					if (obj instanceof NamedElement) {
						NamedElement elem = (NamedElement) obj;
						if(elem.getAppliedStereotype("GQAM::GaAnalysisContext") != null  ||
								elem.getAppliedStereotype("SAM::SaAnalysisContext") != null) {
							AnaCont.add(elem.getQualifiedName());
						}
					}
				}
			}	
		}
		
		return AnaCont;
	}


	/**
	 * Runs the MARTE 2 Cheddar transformation and export the result as an IFile
	 * @param infile IFile containing the input model
	 * @param outfile Destination IFile
	 * @return true if only one context was exported, false otherwise
	 * @throws IOException
	 * @throws URISyntaxException
	 * @throws CoreException
	 * @throws ATLTransformException
	 */
	public int MARTE2Cheddar(IFile infile) throws IOException, CoreException, ATLTransformException{

		List<String> ac = getAnalysisContexts(infile);
		for(String s : ac) {
			_MARTE2Cheddar(infile, s);
			
			String[] p = s.split("::");
			IFile outfile = MyEclipseSwissTools.ChangeFileExtension(infile, p[p.length-1]+".cheddar");
			
			exportModel("OUT", outfile);
			removeModel("OUT");
		}
		
		return ac.size();
	}

	/**
	 * Runs the MARTE 2 Cheddar transformation
	 * @param infile IFile containing the input model
	 * @return the number of resulting Cheddar models
	 * @throws IOException
	 * @throws CoreException
	 * @throws ATLTransformException
	 */
	protected void _MARTE2Cheddar(IFile infile, String qualifiedname) throws IOException, CoreException, ATLTransformException{
		addUMLInputModel("IN", infile);
		createModel("OUT", "CHEDDAR");
		
		reset_names();
		addXMLParameter("targetElement", qualifiedname);
		
		//addXMLParameter("enableVERBOSE", "true");
		//addXMLParameter("enableDEBUG", "true");
		run(transfo_m2c);
		removeModel("IN");
		
		clearXMLParameters();
		
		// The result is left in the model OUT which MUST be handled
	}
	
	/*
	 * Cheddar2XML
	 * 1 Cheddar model to 1 Cheddar XML model
	 */
	/**
	 * Runs the Cheddar 2 CheddarXML transformation and export the result as an IFile
	 * @param infile Source IFile
	 * @param outfile Destination IFile
	 */
	public void Cheddar2XML(IFile infile, IFile outfile) throws IOException, CoreException, ATLTransformException {
		addInputModel("IN", "CHEDDAR", infile);
		Cheddar2XML(outfile);
	}
	
	/**
	 * Runs the Cheddar 2 CheddarXML transformation on an existing "IN" model
	 * @param outfile Destination IFile
	 * @throws IOException
	 * @throws CoreException
	 * @throws ATLTransformException
	 */
	protected void Cheddar2XML(IFile outfile) throws IOException, CoreException, ATLTransformException {
		
		if(!models.containsKey("IN")) throw new UndefinedException("IN");
		
		createXMLModel("OUT");
		run(transfo_c2x);
		
		String xmlxmlstr = exportModelAsXMLToString("OUT");
		removeModel("OUT");
		removeModel("IN");
		
		String xmlstr = AddCheddarDTD(xmlxmlstr);
		
		exportStringToIFile(xmlstr, outfile);
	}
	
	protected void init(IFile infile, boolean export) {
		this.export = export;
		this.inputFile = infile;
	}
	protected void init(IFile infile, String qualifiedName, boolean export) {
		this.export = export;
		this.inputFile = infile;
		this.qualifiedName = qualifiedName;
	}
	/**
	 * Initialisation for Exporting the infile
	 * @param infile
	 */
	public void initExport(IFile infile) {
		init(infile,true);
	}
	/**
	 * Initialisation for Exporting the qualifiedName Analysis Context of infile
	 * @param infile
	 * @param qualifiedName
	 */
	public void initExport(IFile infile, String qualifiedName) {
		init(infile,qualifiedName,true);
	}
	/**
	 * Initialisation for Checking the infile
	 * @param infile
	 */
	public void initCheck(IFile infile) {
		init(infile,false);
	}
	/**
	 * Initialisation for Exporting the qualifiedName Analysis Context of infile
	 * @param infile
	 * @param qualifiedName
	 */
	public void initCheck(IFile infile, String qualifiedName) {
		init(infile,qualifiedName,false);
	}
	/**
	 * Get back the generated output file
	 * @return
	 */
	public IFile result() {
		return this.outputFile;
	}
	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
		try {
			String message;
			if (export) {
				message = "Transformation of a UML-MARTE model in cheddar XML format files";
			} else {
				message = "UML-MARTE Model checking for an export to cheddar XML format";
			}
			monitor.beginTask(message, IProgressMonitor.UNKNOWN);
			this.outputFile = null;
			if (inputFile!=null) {
				// Export
				if (export) {
					if (qualifiedName==null) {
						this.outputFile=run(this.inputFile);
					} else {
						this.outputFile=run(this.inputFile, this.qualifiedName);
					}
				}
				// Check
				else {
					if (qualifiedName==null) {
						check(this.inputFile);
					} else {
						check(this.inputFile, this.qualifiedName);
					}
				}
			}
			this.inputFile = null;
			this.qualifiedName = null;
			monitor.done();
			if (monitor.isCanceled())
				throw new InterruptedException("Cancelled");
		}
		catch (Exception exception) {
			String message = "Error during the transformation process";
			Log.errorMessage(Activator.PLUGIN_ID, message, exception);
		}
	}
	
	/*
	 * MARTE2CheddarXML
	 */
	public IFile run(IFile infile) throws IOException, CoreException, ATLTransformException {
		List<String> ac = getAnalysisContexts(infile);
		
		IFile outfile = null;
		for(String s : ac) {
			outfile = run(infile, s);
		}
		
		if(ac.size() == 1) 	return outfile;
		else return null;
	
	}
	public IFile run(IFile infile, String qualifiedname) throws IOException, CoreException, ATLTransformException {
		String[] p = qualifiedname.split("::");
		IFile outfile = MyEclipseSwissTools.ChangeFileExtension(infile, p[p.length-1]+".xml");
		_MARTE2Cheddar(infile, qualifiedname);
		Resource res = getResourceModel("OUT");
		CheddarImprover.improve(res);
		renameModel("OUT", "IN");
		Cheddar2XML(outfile);
		return outfile;
	}
	
	/*
	 * Check
	 */
	/**
	 * Clean the error markers attached to the input IFile resource
	 * @param infile IFile
	 */
	public void cleanErrors(IFile infile) throws IOException, CoreException, ATLTransformException {
		ExtendedATLProblemsManager.cleanProblems(infile, true);
	}
	
	/**
	 * Check is the input model is valid for MARTE 2 Cheddar transformation
	 * @param file IFile containing the input model
	 * @throws IOException
	 * @throws CoreException
	 * @throws ATLTransformException
	 */
	public void check(IFile file) throws IOException, CoreException, ATLTransformException {
		apm.cleanProblems(file);
		
		for(String s : getAnalysisContexts(file)) {
			Log.verboseMessage(Activator.PLUGIN_ID,"Analyzing : " + s);
			_check(file, s);
		}
	}
	
	public void check(IFile file, String qualifiedname) throws IOException, CoreException, ATLTransformException {
		apm.cleanProblems(file);
		_check(file, qualifiedname);
	}
	
	protected void _check(IFile file, String qualifiedname) throws IOException, CoreException, ATLTransformException {
		
		addUMLInputModel("IN", file);
		createProblemModel("OUT");
		
		reset_names();
		
		addXMLParameter("targetElement", qualifiedname);
		
		//addXMLParameter("enableVERBOSE", "true");
		//addXMLParameter("enableDEBUG", "true");
		run(transfo_check);
		clearXMLParameters();
		
		apm.importModel(getResourceModel("OUT"));
		
		Log.verboseMessage(Activator.PLUGIN_ID, "[" + new Date().toString() + "] " + file.getFullPath().toString() + " :");
		
		Log.verboseMessage(Activator.PLUGIN_ID, (apm.getCritic_count()+ apm.getError_count()) + " error(s)"
				+ " and " + apm.getWarning_count() + "warning(s)/info(s)");
		
		
		apm.signalProblems(file);
		
		removeModel("IN");
		removeModel("OUT");
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99综合影院在线| 亚洲国产精品视频| 乱一区二区av| 26uuu亚洲| 国产成人av一区二区三区在线观看| 亚洲精品一区二区三区在线观看| 激情伊人五月天久久综合| 精品日韩在线观看| 国产成人av影院| 亚洲摸摸操操av| 日韩一区和二区| 国产成人av一区二区三区在线观看| 中文字幕在线观看不卡视频| 日本道免费精品一区二区三区| 一区二区在线观看视频在线观看| 欧美精品乱码久久久久久| 久久99精品国产麻豆婷婷| 国产亚洲视频系列| 91精品福利在线| 美女网站色91| 国产精品久久久久毛片软件| 欧美性极品少妇| 久久99国产精品久久99果冻传媒| 国产精品全国免费观看高清| 欧美剧在线免费观看网站 | 91成人在线免费观看| 亚洲成人av在线电影| 久久综合999| 日本韩国一区二区三区视频| 精品一区二区在线看| 最好看的中文字幕久久| 91麻豆精品国产| 成人精品电影在线观看| 午夜影院久久久| 欧美国产欧美综合| 欧美一级高清大全免费观看| a级高清视频欧美日韩| 欧美a一区二区| 樱花草国产18久久久久| 久久一夜天堂av一区二区三区| 91激情五月电影| 国产精品一区免费在线观看| 亚洲国产精品视频| 亚洲欧洲三级电影| 久久伊人中文字幕| 91精品蜜臀在线一区尤物| 91社区在线播放| 国产成人免费在线观看不卡| 日韩不卡一区二区| 亚洲一区二区中文在线| 国产欧美一区二区精品性色| 欧美一区二区免费观在线| 色综合久久88色综合天天6 | 天堂av在线一区| 一区二区中文视频| 国产欧美日韩精品a在线观看| 欧美顶级少妇做爰| 欧美系列日韩一区| 91久久精品一区二区三| 岛国精品在线播放| 国产精品系列在线播放| 久久国产精品99久久久久久老狼| 亚洲成a人在线观看| 亚洲裸体xxx| 中文字幕在线一区| 日本一区二区电影| 久久精品视频一区| 久久久精品国产免费观看同学| 日韩精品一区二区三区视频| 欧美一区二区国产| 91精品在线麻豆| 91精品在线观看入口| 欧美一区二区视频观看视频| 欧美精品在线一区二区三区| 欧美另类高清zo欧美| 在线播放日韩导航| 欧美日韩国产一二三| 欧美日韩国产一二三| 在线播放一区二区三区| 欧美一级片在线观看| 欧美电影免费观看高清完整版| 日韩亚洲欧美成人一区| 日韩欧美亚洲一区二区| 精品美女被调教视频大全网站| 精品国产一区二区三区不卡| 2020国产精品自拍| 欧美激情一区二区三区在线| 国产精品高清亚洲| 亚洲特级片在线| 亚洲综合色成人| 免费成人美女在线观看| 精品无人区卡一卡二卡三乱码免费卡| 韩国在线一区二区| 丁香婷婷深情五月亚洲| 99国产麻豆精品| 91久久奴性调教| 欧美一区二区大片| 中文久久乱码一区二区| 伊人色综合久久天天人手人婷| 午夜精品久久久久久久99水蜜桃| 秋霞国产午夜精品免费视频| 国内精品国产三级国产a久久| 国产福利电影一区二区三区| 99久久国产综合精品麻豆| 欧美色偷偷大香| 日韩视频永久免费| 一区免费观看视频| 日产国产欧美视频一区精品| 国产做a爰片久久毛片| 94-欧美-setu| 3751色影院一区二区三区| 久久久久久**毛片大全| 亚洲精品你懂的| 激情综合网av| 欧美性猛交xxxxxx富婆| 久久久久国产精品厨房| 亚洲一区在线播放| 国产一区二区在线影院| 色94色欧美sute亚洲线路二| 精品精品欲导航| 亚洲精品久久久蜜桃| 激情文学综合插| 色欧美88888久久久久久影院| 日韩一级片网址| 亚洲日穴在线视频| 精品一区二区三区免费| 欧美性一区二区| 国产日韩欧美在线一区| 日韩精品国产精品| 99视频一区二区| 2021国产精品久久精品| 香港成人在线视频| 91丝袜美腿高跟国产极品老师| 日韩一级完整毛片| 亚洲6080在线| 97se亚洲国产综合自在线| 精品99一区二区三区| 婷婷开心激情综合| 色综合天天在线| 久久久久久久久久久久久久久99 | 日韩视频永久免费| 亚洲午夜久久久久久久久电影网| 国产福利精品导航| 精品少妇一区二区三区| 五月婷婷综合激情| 色www精品视频在线观看| 国产精品天天看| 国产又黄又大久久| 日韩一级在线观看| 日本免费新一区视频| 欧美日韩和欧美的一区二区| 一级特黄大欧美久久久| www.日韩大片| 中文字幕免费在线观看视频一区| 久久99精品久久久久久久久久久久| 7777精品伊人久久久大香线蕉的 | 中文无字幕一区二区三区| 久久99精品国产.久久久久| 欧美另类高清zo欧美| 天天射综合影视| 欧美网站大全在线观看| 亚洲午夜免费福利视频| 欧美日韩在线亚洲一区蜜芽| 一区二区三区欧美视频| 一本一道久久a久久精品| 亚洲欧洲成人精品av97| 不卡的看片网站| 国产精品国产三级国产| 成人av电影在线网| 1000部国产精品成人观看| heyzo一本久久综合| 最近日韩中文字幕| 色妞www精品视频| 亚洲美女免费在线| 精品视频一区三区九区| 亚洲一区二区三区四区五区中文| 91国偷自产一区二区开放时间 | 蜜桃在线一区二区三区| 精品少妇一区二区三区| 国产高清不卡一区二区| 国产精品久久久久久久久免费桃花 | 精品日韩一区二区三区免费视频| 麻豆成人免费电影| 久久日韩粉嫩一区二区三区| 国产九九视频一区二区三区| 国产日韩欧美一区二区三区乱码| 波多野结衣亚洲| 亚洲亚洲人成综合网络| 日韩欧美国产精品| 国产成a人无v码亚洲福利| 亚洲欧美另类综合偷拍| 一本一道久久a久久精品| 亚洲6080在线| 国产亚洲污的网站| 91久久精品一区二区三区| 蜜臀av国产精品久久久久| 国产精品视频免费看| 在线欧美一区二区| 久久精品999| 亚洲欧洲制服丝袜|