@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 Map<?, ?> getContentDescriptionOptions() { return new ExtensibleURIConverterImpl.OptionsMap(ContentHandler.OPTION_REQUESTED_PROPERTIES, CONTENT_TYPE_REQUESTED_PROPERTIES, getLoadOptions()); } };
@Override public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) { return createArchive(uri, options).getAttributes(); }
/** * 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 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>(); genModel.initialize(schema.getEPackages()); Resource resource = resourceSet.createResource(URI.createURI(ePackage.getName() + ".ecore")); resource.getContents().add(ePackage); VirtualFile ecoreFile = basedir.createFile(MODEL_PACKAGE.replace(".", "/") + ePackage.getName() + "/impl/" + ePackage.getName() + ".ecore");
/** * Creates an {@link MappingEntryImpl}. */ @Override protected Entry<URI, URI> newEntry(int hash, URI key, URI value) { validateKey(key); validateValue(value); return new MappingEntryImpl(hash, key, value); }
/** * Checks for folder mappings to update the {@link #prefixMaps prefix maps}. */ @Override protected void didModify(Entry<URI, URI> entry, URI oldValue) { didRemove(entry); ((MappingEntryImpl)entry).determineEntryType(); didAdd(entry); }
/** * Creates an input stream for the archive paths and returns it. * It uses {@link Archive} to implement read access. * </p> * @return an open input stream. * @exception IOException if there is a problem obtaining an open input stream. */ protected InputStream createArchiveInputStream(URI archiveURI) throws IOException { return createArchive(archiveURI).getInputStream(); }
@Override public void setAttributes(URI uri, Map<String, ?> attributes, Map<?, ?> options) throws IOException { createArchive(uri, options).setAttributes(attributes); }
@Override public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException { return createArchive(uri, options).getInputStream(); }
@Override public void delete(URI uri, Map<?, ?> options) throws IOException { createArchive(uri, options).delete(); }
/** * Creates an output stream for the archive access. * </p> * @return an open output stream. * @exception IOException if there is a problem obtaining an open output stream. */ protected OutputStream createArchiveOutputStream(URI archiveURI) throws IOException { return createArchive(archiveURI).getOutputStream(); }
@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 public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) { return createArchive(uri, options).getAttributes(); }
@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 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); } } }
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); } }
String location, List locators, List resolvers, List<URIHandler> uriHandlers) throws IOException { ResourceSet resourceSet = new ResourceSetImpl();
@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); } }
Resource resource = schema.eResource(); if (resource == null) { final ResourceSet resourceSet = new ResourceSetImpl(); resource = (XSDResourceImpl) resourceSet.createResource(URI.createURI(".xsd")); resource.getContents().add(schema);