@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); } }
String location, List locators, List resolvers, List<URIHandler> uriHandlers) throws IOException { ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = schema.eResource(); if (resource == null) { final ResourceSet resourceSet = new ResourceSetImpl(); resource = (XSDResourceImpl) resourceSet.createResource(URI.createURI(".xsd")); resource.getContents().add(schema);
public List<GenPackage> createGenPackages(GenModel genModel, VirtualFile basedir) throws DatabaseException { ResourceSetImpl resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); Map<VirtualFile, Resource> resources = new HashMap<VirtualFile, Resource>();
/** * Test ensures no deadlock occurs when a remote schema is loaded, which resolves to the same * JVM. Deadlock used to occur in GeoServer, when schema was loaded from same GeoServer * instance, because schema consumer and schema server both synchronized on same {@link * org.geotools.xsd.Schemas} class instance. * * @throws IOException */ public void testParseRemoteDoesNotBlock() throws IOException { URIConverter converter = new ExtensibleURIConverterImpl( Collections.singletonList(new MockServerBehaviour()), Collections.emptyList()); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.setURIConverter(converter); XSDSchema schema = Schemas.parse("http://www.foo.bar/remoteSchemaLocation.xsd", resourceSet); assertNotNull(schema); } }
public static Resource readFromUri(URI uri) throws IOException { ResourceSet resourceSet = new ResourceSetImpl(); Resource resource = resourceSet.createResource(uri); read(resource, null); return resource; }
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);
protected ResourceSet createResourceSet() { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().putAll(getRegistrations()); return resourceSet; }
protected ZenModel doLoad(URI modelLocation) { validateFile(modelLocation); ResourceSet resourceSet = new ResourceSetImpl(); org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(modelLocation, true); ZenModel model = (ZenModel) resource.getContents().get(0); return model; }
public static ResourceSet createResourceSet() { ResourceSet result = new ResourceSetImpl(); result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl()); //$NON-NLS-1$ return result; }
private void processProfile ( final File output ) throws IOException { final Profile profile = makeProfile ( this.app ); final File profileFile = new File ( output, this.app.getName () + ".profile.xml" ); //$NON-NLS-1$ final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createFileURI ( profileFile.toString () ) ); r.getContents ().add ( EcoreUtil.copy ( profile ) ); final Map<Object, Object> options = new HashMap<> (); options.put ( XMLResource.OPTION_ENCODING, "UTF-8" ); //$NON-NLS-1$ r.save ( options ); }
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);
public static void save(final SecurityModel model, final String fileName) throws IOException { final File file = new File(fileName); final URI fileURI = URI.createFileURI(file.getAbsolutePath()); final ResourceSet resourceSet = new ResourceSetImpl(); final Resource secResource = resourceSet.createResource(fileURI); model.setName(getModelName(fileURI)); secResource.getContents().add(model); save(secResource); }
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; Map<String, Object> m = reg.getExtensionToFactoryMap(); m.put("key", new XMIResourceFactoryImpl()); ResourceSet resSet = new ResourceSetImpl(); Resource resource = resSet.createResource(URI.createFileURI(fileName)); resource.getContents().add(data); resource.save(Collections.EMPTY_MAP);
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 ); } }