当前位置: 首页>>代码示例>>Java>>正文


Java EcoreResourceFactoryImpl类代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl的典型用法代码示例。如果您正苦于以下问题:Java EcoreResourceFactoryImpl类的具体用法?Java EcoreResourceFactoryImpl怎么用?Java EcoreResourceFactoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EcoreResourceFactoryImpl类属于org.eclipse.emf.ecore.xmi.impl包,在下文中一共展示了EcoreResourceFactoryImpl类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadPackage

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
 * Laods the package and any sub-packages from their serialized form.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void loadPackage() {
	if (isLoaded)
		return;
	isLoaded = true;

	URL url = getClass().getResource(packageFilename);
	if (url == null) {
		throw new RuntimeException("Missing serialized package: " + packageFilename);
	}
	URI uri = URI.createURI(url.toString());
	Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
	try {
		resource.load(null);
	} catch (IOException exception) {
		throw new WrappedException(exception);
	}
	initializeFromLoadedEPackage(this, (EPackage) resource.getContents().get(0));
	createResource(eNS_URI);
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:26,代码来源:Task2PackageImpl.java

示例2: loadPackage

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
 * Laods the package and any sub-packages from their serialized form.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void loadPackage() {
	if (isLoaded) return;
	isLoaded = true;

	URL url = getClass().getResource(packageFilename);
	if (url == null) {
		throw new RuntimeException("Missing serialized package: " + packageFilename);
	}
	URI uri = URI.createURI(url.toString());
	Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
	try {
		resource.load(null);
	}
	catch (IOException exception) {
		throw new WrappedException(exception);
	}
	initializeFromLoadedEPackage(this, (EPackage)resource.getContents().get(0));
	createResource(eNS_URI);
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:26,代码来源:GluemodelPackageImpl.java

示例3: createInjectorAndDoEMFRegistration

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Override
public Injector createInjectorAndDoEMFRegistration() {
	// register default ePackages
	if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore"))
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
			"ecore", new EcoreResourceFactoryImpl());
	if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi"))
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
			"xmi", new XMIResourceFactoryImpl());
	if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin"))
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
			"xtextbin", new BinaryGrammarResourceFactoryImpl());
	if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI))
		EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE);

	Injector injector = createInjector();
	register(injector);
	return injector;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:UnicodeStandaloneSetupGenerated.java

示例4: loadSurveyModel

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
private static Survey loadSurveyModel(String modulePath) {
	// Initialize the model
	QueryITPackage.eINSTANCE.eClass();

	Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
	Map<String, Object> m = reg.getExtensionToFactoryMap();
	m.put("xmi", new XMIResourceFactoryImpl());
	m.put("ecore", new EcoreResourceFactoryImpl());

	// Obtain a new resource set
	ResourceSet resSet = new ResourceSetImpl();

	// Get the resource
	//Resource resource = resSet.getResource(URI.createFileURI(modulePath), true);
	Resource resource = resSet.getResource(URI.createURI(modulePath), true);

	// Get the first model element and cast it to the right type, in my
	// example everything is included in this first node
	Survey s = (Survey) resource.getContents().get(0);

	return s;
}
 
开发者ID:TodorovicNikola,项目名称:SurveyDSL,代码行数:23,代码来源:SurveyGenerator.java

示例5: setUp

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
	EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
	resourceSet = new XtextResourceSet();
	resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
	resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE);
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl());
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/"));
	resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/"));
	resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this);
	resourceSet.setClasspathURIContext(getClasspathURIContext());
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:AbstractPortableURIsTest.java

示例6: setUp

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

	EcoreResourceFactoryImpl resFactory = new EcoreResourceFactoryImpl();
	set.getResourceFactoryRegistry().getExtensionToFactoryMap()
			.put("ecore", resFactory);

	aRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
			"/myProject/main/src/some/package/a.ecore", true));
	InputStream stream = new ByteArrayInputStream(
			aResContent.getBytes("US-ASCII"));
	aRes.load(stream, set.getLoadOptions());
	stream.close();

	bRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
			"/myProject/model/b.ecore", true));

	stream = new ByteArrayInputStream(
			bResContent.getBytes("US-ASCII"));
	bRes.load(stream, set.getLoadOptions());
	stream.close();

}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:24,代码来源:SrcSegmentsInUrisAreNotRemovedTests.java

示例7: loadModel

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
public static Resource loadModel(URL modelURL) {

        ResourceSet resSet = new ResourceSetImpl();
        resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION,
                new XMIResourceFactoryImpl());

        EcoreResourceFactoryImpl ecoreResFact = new EcoreResourceFactoryImpl();
        URI fileName = BasicTestCase.getURI(modelURL);
        LOGGER.info("Trying to load " + fileName);
        Resource ecoreRes = ecoreResFact.createResource(fileName);
        try {
            ecoreRes.load(null);
        } catch (IOException e) {
            fail("Could not load " + Files.EXAMPLEMODEL_ECORE.getFile() + ". Reason: " + e);
        }

        resSet.getResources().add(ecoreRes);

        return ecoreRes;
    }
 
开发者ID:vitruv-tools,项目名称:Vitruv,代码行数:21,代码来源:Models.java

示例8: createPackage

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
private List<EObject> createPackage(GeneratedMetamodel generatedMetamodel, ILeafNode text) {
	final String nsURI = getMetamodelNsURI(text);
	final URI uri = URI.createURI(nsURI);
	if (uri == null || isReferencedByUsedGrammar(generatedMetamodel, nsURI))
		return Collections.emptyList();
	EPackage pack = ((GeneratedMetamodelImpl)generatedMetamodel).basicGetEPackage();
	if (pack != null && !pack.eIsProxy())
		return singletonList((EObject)pack);
	final EPackage generatedEPackage = EcoreFactory.eINSTANCE.createEPackage();
	generatedEPackage.setName(generatedMetamodel.getName());
	generatedEPackage.setNsPrefix(generatedMetamodel.getName());
	generatedEPackage.setNsURI(nsURI);
	final Resource generatedPackageResource = new EcoreResourceFactoryImpl().createResource(uri);
	XtextResourceSet resourceSet = (XtextResourceSet) generatedMetamodel.eResource().getResourceSet();
	if (!resourceSet.getURIResourceMap().containsKey(generatedPackageResource.getURI())) {
		generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
	} else {
		generatedPackageResource.setURI(URI.createURI(nsURI+"_"+generatedMetamodel.hashCode()));
		generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
	}
	generatedPackageResource.getContents().add(generatedEPackage);
	return Collections.<EObject>singletonList(generatedEPackage);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:24,代码来源:XtextLinkingService.java

示例9: setUp

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
	EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
	EcoreResourceFactoryImpl resFactory = new EcoreResourceFactoryImpl();
	set.getResourceFactoryRegistry().getExtensionToFactoryMap()
			.put("ecore", resFactory);

	aRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
			"/myProject/main/src/some/package/a.ecore", true));
	InputStream stream = new ByteArrayInputStream(
			aResContent.getBytes("US-ASCII"));
	aRes.load(stream, set.getLoadOptions());
	stream.close();

	bRes = (XMIResource) set.createResource(URI.createPlatformResourceURI(
			"/myProject/model/b.ecore", true));

	stream = new ByteArrayInputStream(
			bResContent.getBytes("US-ASCII"));
	bRes.load(stream, set.getLoadOptions());
	stream.close();

}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:SrcSegmentsInUrisAreNotRemovedTests.java

示例10: loadPackage

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
 * Laods the package and any sub-packages from their serialized form.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void loadPackage()
{
  if (isLoaded) return;
  isLoaded = true;

  URL url = getClass().getResource(packageFilename);
  if (url == null)
  {
    throw new RuntimeException("Missing serialized package: " + packageFilename);
  }
  URI uri = URI.createURI(url.toString());
  Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
  try
  {
    resource.load(null);
  }
  catch (IOException exception)
  {
    throw new WrappedException(exception);
  }
  initializeFromLoadedEPackage(this, (EPackage)resource.getContents().get(0));
  createResource(eNS_URI);
}
 
开发者ID:umple,项目名称:umple,代码行数:30,代码来源:UmplePackageImpl.java

示例11: lazyMetamodelRegistration

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
private String lazyMetamodelRegistration(String metamodelPath){
	
	Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
  	
    ResourceSet rs = new ResourceSetImpl();
    // Enables extended meta-data, weird we have to do this but well...
    final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(EPackage.Registry.INSTANCE);
    rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

    Resource r = rs.getResource(URI.createFileURI(metamodelPath), true);
    EObject eObject = r.getContents().get(0);
    // A meta-model might have multiple packages we assume the main package is the first one listed
    if (eObject instanceof EPackage) {
        EPackage p = (EPackage)eObject;
        System.out.println(p.getNsURI());
        EPackage.Registry.INSTANCE.put(p.getNsURI(), p);
        return p.getNsURI();
    }
    return null;
}
 
开发者ID:guana,项目名称:ATLauncher,代码行数:21,代码来源:ATLLauncher.java

示例12: loadPackage

import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; //导入依赖的package包/类
/**
 * Laods the package and any sub-packages from their serialized form.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void loadPackage() {
	if (isLoaded)
		return;
	isLoaded = true;

	URL url = getClass().getResource(packageFilename);
	if (url == null) {
		throw new RuntimeException("Missing serialized package: "
				+ packageFilename);
	}
	URI uri = URI.createURI(url.toString());
	Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
	try {
		resource.load(null);
	} catch (IOException exception) {
		throw new WrappedException(exception);
	}
	initializeFromLoadedEPackage(this, (EPackage) resource.getContents()
			.get(0));
	createResource(eNS_URI);
}
 
开发者ID:logicalhacking,项目名称:SecureBPMN,代码行数:28,代码来源:Securebpmn2PackageImpl.java


注:本文中的org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。