@Override protected void setUp() throws Exception { resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put (Resource.Factory.Registry.DEFAULT_EXTENSION, new ColorResourceFactoryImpl()); resourceSet.getPackageRegistry().put (ColorPackage.eNS_URI, ColorPackage.eINSTANCE); }
@Override protected void setUp() throws Exception { resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put (Resource.Factory.Registry.DEFAULT_EXTENSION, new DroolsResourceFactoryImpl()); resourceSet.getPackageRegistry().put (DroolsPackage.eNS_URI, DroolsPackage.eINSTANCE); }
@Override protected void setUp() throws Exception { resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put (Resource.Factory.Registry.DEFAULT_EXTENSION, new BpsimResourceFactoryImpl()); resourceSet.getPackageRegistry().put (BpsimPackage.eNS_URI, BpsimPackage.eINSTANCE); }
public void writeToEcore(File file) { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); Resource resource = resourceSet.createResource(URI.createFileURI(file.getAbsolutePath())); for (EPackage ePackage : packages.values()) { resource.getContents().add(ePackage); } try { resource.save(null); } catch (IOException e) { LOGGER.error("", e); } }
public void writeEMF(String fileName) { ResourceSet metaResourceSet = new ResourceSetImpl(); metaResourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMLResourceFactoryImpl()); URI resUri = URI.createURI(fileName); Resource metaResource = metaResourceSet.createResource(resUri); metaResource.getContents().add(schemaPack); try { metaResource.save(null); } catch (Exception e) { LOGGER.error("", e); } } }
@SuppressWarnings("rawtypes") public void loadEcore(String name, InputStream inputStream) { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); Resource resource = resourceSet.createResource(URI.createURI(name)); try { resource.load(inputStream, new HashMap()); for (EObject eObject : resource.getContents()) { if (eObject instanceof EPackage) { EPackage ePackage = (EPackage)eObject; addEPackage(ePackage); } } } catch (IOException e) { LOGGER.error("", e); } }
@Override public IJvmTypeProvider findTypeProvider(ResourceSet resourceSet) { if (resourceSet == null) throw new IllegalArgumentException("resourceSet may not be null."); return (IJvmTypeProvider) resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().get(URIHelperConstants.PROTOCOL); }
public IJvmTypeProvider findTypeProvider(ResourceSet resourceSet) { if (resourceSet == null) throw new IllegalArgumentException("resourceSet may not be null."); return (IJvmTypeProvider) resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().get(URIHelperConstants.PROTOCOL); }
public static ResourceSet newResourceSet(Resource.Factory resourceFactory) { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$ return resourceSet; }
public IndexedJvmTypeAccess getIndexJvmTypeAccess() { if ((this._access == null)) { final Object provider = this.resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap().get(URIHelperConstants.PROTOCOL); if ((provider instanceof AbstractJvmTypeProvider)) { this._access = ((AbstractJvmTypeProvider)provider).getIndexedJvmTypeAccess(); } } return this._access; }
public static Resource fromString(String input, ResourceSet rs) throws IOException { rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("json", new JsonResourceFactory(customMapper)); Resource resource = customMapper .reader() .withAttribute(EMFContext.Attributes.RESOURCE_SET, rs) .withAttribute(EMFContext.Attributes.RESOURCE_URI, URI.createURI(System.currentTimeMillis() + ".json")) .forType(Resource.class) .readValue(input); return resource; }
protected ResourceSet createResourceSet() { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().putAll(getRegistrations()); return resourceSet; }
public static ResourceSet createResourceSet() { ResourceSet result = new ResourceSetImpl(); result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl()); //$NON-NLS-1$ return result; }
private ResourceSet createResourceSet() { ResourceSet resourceSet = new ResourceSetImpl(); /* * Register XML Factory implementation using DEFAULT_EXTENSION */ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() .put("xsd", new XSDResourceFactoryImpl()); return resourceSet; }
protected ResourceSet createResourceSet() { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().putAll(getRegistrations()); return resourceSet; }
private static SecurityModel read(final String modelString) throws IOException { final ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); final org.eclipse.emf.ecore.resource.Resource xmlResource = resourceSet.createResource(URI.createURI("dummy.deploy")); //$NON-NLS-1$ // Register the package -- only needed for stand-alone! resourceSet.getPackageRegistry().put(UamPackage.eNS_URI, UamPackage.eINSTANCE); resourceSet.getPackageRegistry().put(ExpressionPackage.eNS_URI, ExpressionPackage.eINSTANCE); resourceSet.getPackageRegistry().put(StdlibPackage.eNS_URI, StdlibPackage.eINSTANCE); final ByteArrayInputStream bais = new ByteArrayInputStream(modelString.getBytes()); xmlResource.load(bais, Collections.emptyMap()); return (SecurityModel) xmlResource.getContents().get(0); }
public static <T> T fromStream(InputStream input, Class<T> clz, ResourceSet rs) throws IOException { rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("json", new JsonResourceFactory(customMapper)); Resource resource = fromStream(input, rs); return (T) resource.getContents().get(0); }
public static <T> T fromFile(File file, Class<T> clz, ResourceSet rs) throws IOException { rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("json", new JsonResourceFactory(customMapper)); Resource resource = fromFile(file, rs); return (T) resource.getContents().get(0); }
ResourceSet set = new ResourceSetImpl(); set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); set.getResourceFactoryRegistry().getExtensionToFactoryMap() .put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap() .put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); Resource res = set.getResource(URI.createFileURI("/path/to/my_model.uml"), true);
protected void load () throws Exception { // register model VisualInterfacePackage.eINSTANCE.eClass (); this.symbol = null; final ResourceSet resourceSet = new ResourceSetImpl (); // set resource factory to XMI on extension map resourceSet.getResourceFactoryRegistry ().getExtensionToFactoryMap ().put ( "vi", FACTORY_INSTANCE ); //$NON-NLS-1$ final Resource resource = resourceSet.getResource ( this.uri, true ); this.symbol = (Symbol)EcoreUtil.getObjectByType ( resource.getContents (), VisualInterfacePackage.Literals.SYMBOL ); } }