1. gzyueqian
      18529173453
      首頁 > 新聞中心 > > 正文

      EMF模型解析的策略分析

      更新時間: 2007-06-04 10:01:27來源: 粵嵌教育瀏覽量:610


        今天看到兩種使用EMF解析.xml為EMF模型的策略:
        一種是通過如下代碼:

      IFileEditorInput modelFile = (IFileEditorInput)getEditorInput();
      URI resourceURI = URI.createPlatformResourceURI(modelFile.getFile().getFullPath().toString());;
      resource = editingDomain.getResourceSet().getResource(resourceURI, true ); 上面這種方式會引用一個AdapterFactoryEditingDomain類,但我們基于模型做編輯器時,有時并不需要用這個類,例如GEF,它具有自身的EditorDomain。

      另外一種方式是使用EMF模型自動生成的Process,該類一般在模型的Util包下面,引用代碼如下:
      IFileEditorInput modelFile = (IFileEditorInput)getEditorInput();
      XMLProcessor processor = new DesignXMLProcessor();
      resource = processor.load(new InputSource(new InputStreamReader(modelFile.getFile().getContents(), "GBK")), null);

        其實,對于EMF而言,上面兩種解釋方式,歸根到底都需要EMF獲得 業(yè)務(wù)模型相關(guān)的解析器,對于種方式,EMF是如何獲取到業(yè)務(wù)模型的解析器呢?主要是通過擴展的方式,擴展定義在模型的plugin.xml中,代碼片斷如下圖所示:
      <extension point="org.eclipse.emf.ecore.extension_parser">
      <parser
      type="design"
      class="com.neusoft.report.design.util.DesignResourceFactoryImpl" />
      </extension>
      這樣,解析.xml文件時,EMF從ResourceFactory注冊中,根據(jù)相應(yīng)的type,獲取解析器(DesignResourceFactoryImpl),完成解析。

      免費預(yù)約試聽課

      亚洲另类欧美综合久久图片区_亚洲中文字幕日产无码2020_欧美日本一区二区三区桃色视频_亚洲AⅤ天堂一区二区三区

      
      

      1. 久久国产精选AV免费 | 亚洲国产精品综合色区 | 在线看片免费不卡人成视频 | 日本亚洲五月天在线观看视频 | 久久国产精品-国产十精品 中文字幕视频综合网 | 在线观看精品综合一区 |