use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project xtext-core by eclipse.
the class TerminalRulesTestLanguageStandaloneSetupGenerated method createInjectorAndDoEMFRegistration.
@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;
}
use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project xtext-core by eclipse.
the class EcoreUtil2Test method testClone.
@Test
public void testClone() throws Exception {
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE);
ResourceSetImpl rs = new ResourceSetImpl();
Resource r1 = rs.createResource(URI.createURI("foo.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
Resource r2 = rs.createResource(URI.createURI("bar.xmi"), ContentHandler.UNSPECIFIED_CONTENT_TYPE);
EClass a = EcoreFactory.eINSTANCE.createEClass();
a.setName("a");
EClass b = EcoreFactory.eINSTANCE.createEClass();
r1.getContents().add(a);
b.setName("b");
b.getESuperTypes().add(a);
r2.getContents().add(b);
ResourceSetImpl clone = EcoreUtil2.clone(new ResourceSetImpl(), rs);
EList<Resource> list = clone.getResources();
Resource resA = list.get(0);
assertEquals(URI.createURI("foo.xmi"), resA.getURI());
assertNotSame(resA, r1);
Resource resB = list.get(1);
assertEquals(URI.createURI("bar.xmi"), resB.getURI());
assertNotSame(resB, r2);
EClass a1 = (EClass) resA.getContents().get(0);
EClass b1 = (EClass) resB.getContents().get(0);
assertEquals("a", a1.getName());
assertNotSame(a, a1);
assertEquals("b", b1.getName());
assertNotSame(b, b1);
assertSame(b1.getESuperTypes().get(0), a1);
assertSame(b.getESuperTypes().get(0), a);
}
use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project vorto by eclipse.
the class LWM2MMappingParseTest method createMappingModel.
private MappingModel createMappingModel(String mappingFileName) throws IOException {
ResourceSet rset = new ResourceSetImpl();
rset.getPackageRegistry().put(MappingPackage.eNS_URI, MappingPackage.eINSTANCE);
rset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
Resource resource = rset.getResource(URI.createFileURI(EXAMPLES_DIRECTORY + mappingFileName), true);
resource.load(null);
MappingModel mappingModel = (MappingModel) resource.getContents().get(0);
return mappingModel;
}
use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project vorto by eclipse.
the class MappingModelSyntaxTest method createMappingModel.
private MappingModel createMappingModel(String mappingFileName) throws IOException {
ResourceSet rset = new ResourceSetImpl();
rset.getPackageRegistry().put(MappingPackage.eNS_URI, MappingPackage.eINSTANCE);
rset.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
String exampleSmarthomeMappingFile = EXAMPLES_DIRECTORY + mappingFileName;
Resource resource = rset.getResource(URI.createFileURI(exampleSmarthomeMappingFile), true);
resource.load(null);
MappingModel mappingModel = (MappingModel) resource.getContents().get(0);
return mappingModel;
}
use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project iobserve-analysis by research-iobserve.
the class AbstractModelHandler method save.
/**
* Save the internal model. This will override the existing.
*
* @param writeModelURI
* URI refering where to store the model
* @param model
* is the model to be stored
*/
public final void save(final URI writeModelURI, final T model) {
final Resource.Factory.Registry resourceRegistry = Resource.Factory.Registry.INSTANCE;
final Map<String, Object> map = resourceRegistry.getExtensionToFactoryMap();
map.put("*", new XMIResourceFactoryImpl());
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.setResourceFactoryRegistry(resourceRegistry);
final Resource resource = resourceSet.createResource(writeModelURI);
resource.getContents().add(model);
try {
resource.save(null);
} catch (final IOException e) {
e.printStackTrace();
}
}
Aggregations