use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project tdi-studio-se by Talend.
the class ImportItemUtil method computeProperty.
private void computeProperty(ResourcesManager manager, ItemRecord itemRecord) {
InputStream stream = null;
try {
stream = manager.getStream(itemRecord.getPath());
final Resource resource = createResource(itemRecord, itemRecord.getPath(), false);
URIConverter uriConverter = resource.getResourceSet().getURIConverter();
resource.getResourceSet().setURIConverter(new ExtensibleURIConverterImpl() {
/*
* (non-Javadoc)
*
* @see org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl#createInputStream(org.eclipse.
* emf.common.util.URI, java.util.Map)
*/
@Override
public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
InputStream inputStream = null;
EPackage ePackage = resource.getResourceSet().getPackageRegistry().getEPackage(uri.toString());
if (ePackage != null || !"http".equals(uri.scheme())) {
inputStream = super.createInputStream(uri, options);
} else {
inputStream = null;
}
return inputStream;
}
});
EmfHelper.loadResource(resource, stream, null);
resource.getResourceSet().setURIConverter(uriConverter);
itemRecord.setProperty((Property) EcoreUtil.getObjectByType(resource.getContents(), PropertiesPackage.eINSTANCE.getProperty()));
} catch (Exception e) {
// ignore, must be one invalid or unknown item
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
// ignore
}
}
}
}
use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project n4js by eclipse.
the class BuiltInSchemeAwareResource method createNewURIConverter.
private URIConverter createNewURIConverter() {
URIConverter result = new ExtensibleURIConverterImpl();
registrar.registerScheme(result);
return result;
}
use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project xtext-core by eclipse.
the class ExternalContentSupportTest method testConfigureConverter.
@Test
public void testConfigureConverter() {
URIConverter converter = new ExtensibleURIConverterImpl();
support.configureConverter(converter, this);
checkConverter(converter);
}
use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project xtext-eclipse by eclipse.
the class PersistableResourceDescriptionsTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
with(new BuilderTestLanguageStandaloneSetup());
SharedModule module = new SharedModule(null);
builderInjector = Guice.createInjector(module);
builderState = builderInjector.getInstance(ClusteringBuilderState.class);
uriConverter = new ExtensibleURIConverterImpl() {
@Override
public InputStream createInputStream(org.eclipse.emf.common.util.URI uri, Map<?, ?> options) throws IOException {
return new StringInputStream(fileSystem.get(uri.toString()));
}
};
}
use of org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl in project n4js by eclipse.
the class N4JSResource method createNewURIConverter.
private URIConverter createNewURIConverter() {
URIConverter result = new ExtensibleURIConverterImpl();
registrar.registerScheme(result);
return result;
}
Aggregations