/** * 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 Map<URI, URI> getURIMap() { return existing.getURIMap(); }
public void enableAutoload(URI uri) { URI normalized = resourceSet.getURIConverter().normalize(uri); autoloadResourcesURIs.add(normalized); }
Long sourceTimeStamp = (Long)URIConverter.INSTANCE.getAttributes(sourceURI, options).get(URIConverter.ATTRIBUTE_TIME_STAMP); Long targetTimeStamp = (Long)URIConverter.INSTANCE.getAttributes(targetURI, options).get(URIConverter.ATTRIBUTE_TIME_STAMP); if (targetTimeStamp == null || targetTimeStamp.compareTo(sourceTimeStamp) < 0) OutputStream out = URIConverter.INSTANCE.createOutputStream(targetURI); InputStream in = URIConverter.INSTANCE.createInputStream(sourceURI); byte[] bytes = new byte[4048]; for (int length = in.read(bytes); length > 0; length = in.read(bytes))
@Override public boolean exists(URI uri, Map<?, ?> options) { return existing.exists(uri, options); }
if (uri != null) { URIConverter uriConverter = metamodel.eResource().getResourceSet().getURIConverter(); if (uriConverter.exists(uri, null)) { InputStream in = uriConverter.createInputStream(uri); try { XtendResourceParser parser = new XtendResourceParser();
@Override public OutputStream createOutputStream(URI uri) throws IOException { return existing.createOutputStream(uri); }
/** * checks whether the given URI can be loaded given the context. I.e. there's a resource set with a corresponding * resource factory and the physical resource exists. */ public static boolean isValidUri(Resource resource, URI uri) { if (uri == null || uri.isEmpty()) { return false; } URI newURI = getResolvedImportUri(resource, uri); try { ResourceSet resourceSet = resource.getResourceSet(); if (resourceSet.getResource(uri, false) != null) return true; URIConverter uriConverter = resourceSet.getURIConverter(); URI normalized = uriConverter.normalize(newURI); if (normalized != null) // fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=326760 if("platform".equals(normalized.scheme()) && !normalized.isPlatform()) return false; return uriConverter.exists(normalized, Collections.emptyMap()); } catch (RuntimeException e) { // thrown by org.eclipse.emf.ecore.resource.ResourceSet#getResource(URI, boolean) log.trace("Cannot load resource: " + newURI, e); } return false; }
@Override public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) { return existing.getAttributes(uri, options); }
resourceSet.getURIConverter().getURIHandlers().addAll(0, uriHandlers);
protected boolean exists(final URI uri) { boolean _xifexpression = false; if ((uri == null)) { _xifexpression = false; } else { _xifexpression = this.getURIConverter().exists(uri, null); } return _xifexpression; }
if (URIConverter.INSTANCE.exists(manifestURI, null)) manifestInputStream = URIConverter.INSTANCE.createInputStream(manifestURI); Manifest manifest = new Manifest(manifestInputStream); java.util.jar.Attributes mainAttributes = manifest.getMainAttributes(); InputStream bundleLocalizationInputStream = URIConverter.INSTANCE.createInputStream(pluginLocation.appendSegment(bundleLocalization)); resourceBundle = new PropertyResourceBundle(bundleLocalizationInputStream); bundleLocalizationInputStream.close(); InputStream pluginXMLInputStream = URIConverter.INSTANCE.createInputStream(pluginXMLURI); IContributor contributor = ContributorFactorySimple.createContributor(bundleSymbolicName); registry.addContribution(pluginXMLInputStream, contributor, false, bundleSymbolicName, resourceBundle, null);
@Override public OutputStream createOutputStream(URI uri, Map<?, ?> options) throws IOException { return existing.createOutputStream(uri, options); }
protected Object getAttribute(final URI uri, final String attributeName) { Object _xblockexpression = null; { if ((uri == null)) { return null; } final HashMap<String, Set<String>> options = CollectionLiterals.<String, Set<String>>newHashMap(); options.put(URIConverter.OPTION_REQUESTED_ATTRIBUTES, Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet(attributeName))); _xblockexpression = this.getURIConverter().getAttributes(uri, options).get(attributeName); } return _xblockexpression; }
@Override public EList<URIHandler> getURIHandlers() { return existing.getURIHandlers(); }
@Override public InputStream createInputStream(URI uri) throws IOException { return existing.createInputStream(uri); }
/** * Determines {@link ExtensibleURIConverterImpl.URIMap.Internal#modificationCount() modification count} of the {@link #cachedURIConverter cached URI converter}. */ protected int modificationCount() { return ((ExtensibleURIConverterImpl.URIMap.Internal)cachedURIConverter.getURIMap()).modificationCount(); }
public void disableAutoload(URI uri) { URI normalized = resourceSet.getURIConverter().normalize(uri); autoloadResourcesURIs.remove(normalized); }
/** * Determines whether a given workspace path URI represents a file that already exists. */ protected boolean exists(URI workspacePath) { if (EcorePlugin.getWorkspaceRoot() != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.exists(workspacePath.toString(), null); } return getURIConverter().exists(toPlatformResourceURI(workspacePath), null); }
@Override protected OutputStream createOutputStream(String nestedURL) throws IOException { return getURIConverter(options).createOutputStream(URI.createURI(nestedURL), options); } @Override