Analysis of the strategy of EMF Model __ Extension

Source: Internet
Author: User

Today we see two strategies for using EMF to parse. XML as an EMF model:
One is through the following code:
Word-break:break-all; padding-top:4px; Border-bottom: #cccccc 1px solid; Background-color: #eeeeee "> Ifileeditorinput modelfile = (ifileeditorinput) geteditorinput ();
URI ResourceURI = Uri.createplatformresourceuri (Modelfile.getfile (). GetFullPath (). toString ())
Resource = Editingdomain.getresourceset (). GetResource (ResourceURI, true); The above approach refers to a adapterfactoryeditingdomain class, but sometimes we do not need to use this class, such as GEF, to have its own editordomain, based on the Model Editor.

Another way is to use a process that is automatically generated by using the EMF model, which is typically under the util package of the model, and the reference code is as follows:
Ifileeditorinput modelfile = (ifileeditorinput) geteditorinput ();
Xmlprocessor processor = new Designxmlprocessor ();
Resource = Processor.load (new InputSource (Modelfile.getfile (). getcontents (), "GBK")), null);

In fact, for EMF, the above two explanations, in the final analysis, need EMF to obtain business model-related parser, for the first way, EMF is how to obtain the business model of the parser. The extension is defined in the plugin.xml of the model, mainly by extension, as shown in the following illustration of the code fragment:
<extension point= "Org.eclipse.emf.ecore.extension_parser" >
<parser
Type= "Design"
class= "Com.neusoft.report.design.util.DesignResourceFactoryImpl"/>
</extension>
In this way, when parsing an. xml file, EMF obtains the parser (Designresourcefactoryimpl) from the Resourcefactory registry and completes the parsing according to the corresponding type. Enter the discussion group discussion.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.