use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project xtext-eclipse by eclipse.
the class Bug303200TestLanguageStandaloneSetupGenerated 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 iobserve-analysis by research-iobserve.
the class CreatePrivacyMain method save.
private static void save(final DataProtectionModel privacyModel, final URI writeModelURI) {
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(privacyModel);
try {
resource.save(null);
} catch (final IOException e) {
CreatePrivacyMain.LOGGER.error("Saving model failed {} {}", writeModelURI, e.getLocalizedMessage());
}
}
use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project iobserve-analysis by research-iobserve.
the class ECoreNeo4JTest method setUp.
/**
* Setup test.
*
* @throws Exception
* on error
*/
@Before
public void setUp() {
this.prefix = this.getClass().getCanonicalName();
this.modelOne = TestModelData.createModelOne();
this.modelTwo = TestModelData.createModelTwo();
final Registry resourceRegistry = Resource.Factory.Registry.INSTANCE;
final Map<String, Object> map = resourceRegistry.getExtensionToFactoryMap();
map.put("*", new XMIResourceFactoryImpl());
try {
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.setResourceFactoryRegistry(resourceRegistry);
final Resource resource = resourceSet.createResource(URI.createFileURI("storage-example.storage"));
resource.getContents().add(this.modelOne);
resource.save(null);
} catch (final IOException e) {
Assert.fail(e.getLocalizedMessage());
}
}
use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project InformationSystem by ObeoNetwork.
the class AbstractTransformationTest method createResource.
/**
* This will create a {@link Resource} given the model extension it is
* intended for and a ResourceSet.
*
* @param modelURI
* {@link org.eclipse.emf.common.util.URI URI} where the model is
* stored.
* @param resourceSet
* The {@link ResourceSet} to load the model in.
* @return The {@link Resource} given the model extension it is intended
* for.
*/
protected Resource createResource(URI modelURI, ResourceSet resourceSet) {
String fileExtension = modelURI.fileExtension();
if (fileExtension == null || fileExtension.length() == 0) {
fileExtension = Resource.Factory.Registry.DEFAULT_EXTENSION;
}
// First search the resource set for our resource factory
Resource.Factory.Registry registry = resourceSet.getResourceFactoryRegistry();
Object resourceFactory = registry.getExtensionToFactoryMap().get(fileExtension);
if (resourceFactory == null) {
// then the global registry
registry = Resource.Factory.Registry.INSTANCE;
resourceFactory = registry.getExtensionToFactoryMap().get(fileExtension);
if (resourceFactory != null) {
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(fileExtension, resourceFactory);
} else {
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(fileExtension, new XMIResourceFactoryImpl());
}
}
return resourceSet.createResource(modelURI);
}
use of org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl in project metalib by softlang.
the class StandaloneFSMLScenario method main.
public static void main(String[] args) {
ResourceSet rs = new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("fsml", new XMIResourceFactoryImpl());
URI uri = URI.createFileURI("path");
Resource resource = rs.createResource(uri);
FSM fsm = (FSM) resource.getContents().get(0);
}
Aggregations