/** * Fetches the contents of the URI into a byte[]. * * @param uri * @param options * @param response * @return The resource data * @throws IOException */ private static byte[] readUriResource(URI uri, ResourceSet resourceSet, Map<?, ?> response) throws IOException { Map<Object, Object> options = resourceSet.getLoadOptions(); URIConverter uriConverter = getUriConverter(resourceSet); Map<Object, Object> loadMap = new HashMap<>(options); loadMap.put(URIConverter.OPTION_RESPONSE, response); ByteArrayOutputStream out = new ByteArrayOutputStream(); try (InputStream inputStream = uriConverter.createInputStream(uri, loadMap)) { IOUtils.copy(inputStream, out); } return out.toByteArray(); }
@Override public InputStream createInputStream(URI uri) throws IOException { return existing.createInputStream(uri); }
@Override public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException { return existing.createInputStream(uri, options); }
@Override protected InputStream createInputStream(String nestedURL) throws IOException { return getURIConverter(options).createInputStream(URI.createURI(nestedURL), options); }
@Override protected InputStream createInputStream(String nestedURL) throws IOException { return getURIConverter(options).createInputStream(URI.createURI(nestedURL), options); }
public InputStream getResourceInputStream(String uri) throws IOException { return getResourceSet().getURIConverter().createInputStream(URI.createURI(uri)); }
@Override protected InputStream createInputStream(URI workspacePath) throws Exception { if (EMFPlugin.IS_ECLIPSE_RUNNING) { return super.createInputStream(workspacePath); } else { return URIConverter.INSTANCE.createInputStream(toPlatformResourceURI(workspacePath)); } }
/** * Creates an <code>InputStream</code> for the file identified by the given workspace path URI. */ protected InputStream createInputStream(URI workspacePath) throws Exception { if (EMFPlugin.IS_ECLIPSE_RUNNING) { return EclipseHelper.createInputStream(workspacePath.toString()); } return getURIConverter().createInputStream(toPlatformResourceURI(workspacePath), null); }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException { try { Map<Object, Object> options = new HashMap<Object, Object>(); options.put("publicId", publicId); options.put("systemId", systemId); options.put("baseLocation", resourceURI == null ? null : resourceURI.toString()); URI uri = URI.createURI(systemId); if (resolve && uri.isRelative() && uri.hasRelativePath()) { uri = helper.resolve(uri, resourceURI); } InputStream inputStream = getURIConverter().createInputStream(uri, options); InputSource result = new InputSource(inputStream); result.setPublicId(publicId); result.setSystemId(systemId); return result; } catch (IOException exception) { throw new SAXException(exception); } }
@Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException { try { Map<Object, Object> options = new HashMap<Object, Object>(); options.put("publicId", publicId); options.put("systemId", systemId); options.put("baseLocation", resourceURI == null ? null : resourceURI.toString()); URI uri = URI.createURI(systemId); if (resolve && uri.isRelative() && uri.hasRelativePath()) { uri = helper.resolve(uri, resourceURI); } InputStream inputStream = getURIConverter().createInputStream(uri, options); InputSource result = new InputSource(inputStream); result.setPublicId(publicId); result.setSystemId(systemId); return result; } catch (IOException exception) { throw new SAXException(exception); } }
@Override public InputStream getContentsAsStream(final Path path) { final URI uri = this.getURI(path); if ((((uri == null) || (!this.exists(uri))) || (!this.isFile(uri)))) { throw new IllegalArgumentException(("The file cannot be found: " + path)); } try { return this.getURIConverter().createInputStream(uri); } catch (final Throwable _t) { if (_t instanceof IOException) { final IOException exc = (IOException)_t; String _message = exc.getMessage(); throw new IllegalArgumentException(_message, exc); } else { throw Exceptions.sneakyThrow(_t); } } }
/** * This returns whether something has been persisted to the URI of the specified resource. * The implementation uses the URI converter from the editor's resource set to try to open an input stream. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected boolean isPersisted(Resource resource) { boolean result = false; try { InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); if (stream != null) { result = true; stream.close(); } } catch (IOException e) { // Ignore } return result; }
/** * @deprecated In EMF 2.2, a {@link org.eclipse.emf.codegen.ecore.generator.GeneratorAdapter GeneratorAdapter} should be used to * implement code generation. {@link org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter AbstractGeneratorAdapter} provides * an equivalent to this method. This method will be removed after 2.2. */ @Deprecated public InputStream createInputStream(URI uri) throws Exception { if (EMFPlugin.IS_ECLIPSE_RUNNING) { URI workspacePath = uri.replacePrefix(PLATFORM_RESOURCE_URI, EMPTY_URI); if (workspacePath != null) { return EclipseUtil.createInputStream(workspacePath.toString()); } } URIConverter uriConverter = eResource().getResourceSet().getURIConverter(); return uriConverter.createInputStream(uri); }
/** * Creates an <code>InputStream</code> for the file identified by the given workspace path URI. */ protected InputStream createInputStream(URI workspacePath) throws Exception { if (EMFPlugin.IS_ECLIPSE_RUNNING) { return EclipseHelper.createInputStream(workspacePath.toString()); } return getURIConverter().createInputStream(toPlatformResourceURI(workspacePath)); }
public static InputStream getBodyStream(ExternalExample example) throws IOException { URI externalExampleUri = getResolvedImportUri(example.eResource(), URI.createURI(example.getPath())); URIConverter uriConverter = example.eResource().getResourceSet().getURIConverter(); return uriConverter.createInputStream(externalExampleUri); }
if (resolvedLocation != null) return getURIConverter(options).createInputStream(resolvedLocation, options);
/** * Determines whether a given workspace path URI represents a file that already exists. */ protected boolean exists(URI workspacePath) { if (EMFPlugin.IS_ECLIPSE_RUNNING) { return EclipseHelper.exists(workspacePath.toString()); } URI uri = getURIConverter().normalize(toPlatformResourceURI(workspacePath)); if ("file".equalsIgnoreCase(uri.scheme())) { return new File(uri.toFileString()).exists(); } else { try { InputStream inputStream = getURIConverter().createInputStream(uri); inputStream.close(); return true; } catch (IOException exception) { return false; } } }
/** * @deprecated In EMF 2.2, a {@link org.eclipse.emf.codegen.ecore.generator.GeneratorAdapter GeneratorAdapter} should be used to * implement code generation. {@link org.eclipse.emf.codegen.ecore.generator.AbstractGeneratorAdapter AbstractGeneratorAdapter} provides * an equivalent to this method. This method will be removed after 2.2. */ @Deprecated public InputStream createInputStream(URI uri) throws Exception { if (EMFPlugin.IS_ECLIPSE_RUNNING) { URI workspacePath = uri.replacePrefix(PLATFORM_RESOURCE_URI, EMPTY_URI); if (workspacePath != null) { return EclipseUtil.createInputStream(workspacePath.toString()); } } URIConverter uriConverter = eResource().getResourceSet().getURIConverter(); return uriConverter.createInputStream(uri); }
public static String getCompleteContent(XtextResource xr) throws IOException, UnsupportedEncodingException { XtextResourceSet resourceSet = (XtextResourceSet) xr.getResourceSet(); URIConverter uriConverter = resourceSet.getURIConverter(); URI uri = xr.getURI(); String encoding = xr.getEncoding(); InputStream inputStream = null; try { inputStream = uriConverter.createInputStream(uri); return getCompleteContent(encoding, inputStream); } finally { tryClose(inputStream, null); } }
InputStream inputStream = resourceSet.getURIConverter().createInputStream(uri); wsdlMainResource.load(inputStream, resourceSet.getLoadOptions());