public RamlResourceSet() { final List<URIHandler> uriHandlers = Arrays.asList( new PlatformResourceURIHandlerImpl(), new FileURIHandlerImpl(), new EFSURIHandlerImpl(), new ArchiveURIHandlerImpl(), new ContentNegotiationURIHandler(ACCEPT_HEADER_VALUE)); final ExtensibleURIConverterImpl uriConverter = new ExtensibleURIConverterImpl(uriHandlers, ContentHandler.Registry.INSTANCE.contentHandlers()); setURIConverter(uriConverter); final Resource.Factory.Registry resourceFactoryRegistry = getResourceFactoryRegistry(); final RamlResourceFactory resourceFactory = new RamlResourceFactory(); resourceFactoryRegistry .getExtensionToFactoryMap().put("raml", resourceFactory); resourceFactoryRegistry.getProtocolToFactoryMap() .put("http", resourceFactory); final Map<String, Object> contentTypeToFactoryMap = resourceFactoryRegistry.getContentTypeToFactoryMap(); for (final String contentType : ACCEPTED_MIME_TYPES) { contentTypeToFactoryMap .put(contentType, resourceFactory); } addBuiltinTypes(); }
public URIHandler getURIHandler(URI uri) { int size = uriHandlers.size(); if (size > 0) { URIHandler[] data = uriHandlers.data(); for (int i = 0; i < size; ++i) { URIHandler uriHandler = data[i]; if (uriHandler.canHandle(uri)) { return uriHandler; } } } throw new RuntimeException("There is no URIHandler to handle " + uri); }
private boolean registerScheme(URIConverter converter, @SuppressWarnings("hiding") ClassLoader classLoader) { URIHandler uriHandler = converter.getURIHandlers().get(0); if (uriHandler instanceof MyURIHandler || uriHandler.canHandle(SAMPLE_URI)) { return false; } converter.getURIHandlers().add(0, createURIHandler(classLoader, converter)); return true; }
@Override public InputStream getContents() throws CoreException { URIHandler handler = schemeHelper.createURIHandler(URIConverter.INSTANCE); try { return handler.createInputStream(getURI(), Collections.emptyMap()); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.n4js.ts.ui", "Cannot load " + getFullPath(), e)); } }
@Override public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException { for (URIHandler handler : otherHandlers) { if (handler.canHandle(uri)) { return handler.createInputStream(uri, options); } } return super.createInputStream(uri, options); }
public void configureConverter(URIConverter converter, IExternalContentProvider contentProvider) { List<URIHandler> uriHandlers = converter.getURIHandlers(); ListIterator<URIHandler> iter = uriHandlers.listIterator(); while(iter.hasNext()) { URIHandler transformed = new ExternalContentAwareURIHandler(iter.next(), contentProvider); iter.set(transformed); } }
@Override protected synchronized URIConverter getURIConverter() { if (this.uriConverter == null) { List<ContentHandler> withoutPlatformDelegate = Lists.newArrayList(); for (ContentHandler contentHandler : ContentHandler.Registry.INSTANCE.contentHandlers()) { if (!isTooEager(contentHandler)) withoutPlatformDelegate.add(contentHandler); } this.uriConverter = new ExtensibleURIConverterImpl(URIHandler.DEFAULT_HANDLERS, withoutPlatformDelegate); } return this.uriConverter; }
public EnsembleResourceSet() { super(); for (EnsembleResourceFactory factory : factories) { factory.setResourceSet(this); } List<URIHandler> handlers = new ArrayList<URIHandler>(URIHandler.DEFAULT_HANDLERS); handlers.addAll(0, getURIHandlerContributions()); setURIConverter(new ExtensibleURIConverterImpl(handlers, ContentHandler.Registry.INSTANCE.contentHandlers())); }
/** * * {@inheritDoc} * * @see org.eclipse.emf.emfstore.mongodb.AbstractMongoDBResourceSetProvider#setURIConverter(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) */ @Override protected void setURIConverter(ResourceSetImpl resourceSet) { // reuse uri handlers set up by resourcesetfactory EList<URIHandler> uriHandler = resourceSet.getURIConverter().getURIHandlers(); URIConverter uriConverter = new MongoServerURIConverter(); uriConverter.getURIHandlers().clear(); uriConverter.getURIHandlers().addAll(uriHandler); resourceSet.setURIConverter(uriConverter); }
/** * * {@inheritDoc} * * @see org.eclipse.emf.emfstore.mongodb.AbstractMongoDBResourceSetProvider#setURIConverter(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) */ @Override protected void setURIConverter(ResourceSetImpl resourceSet) { // reuse uri handlers set up by resourcesetfactory EList<URIHandler> uriHandler = resourceSet.getURIConverter().getURIHandlers(); URIConverter uriConverter = new MongoClientURIConverter(); uriConverter.getURIHandlers().clear(); uriConverter.getURIHandlers().addAll(uriHandler); resourceSet.setURIConverter(uriConverter); }
public EList<URIHandler> getURIHandlers() { if (uriHandlers == null) { uriHandlers = new URIHandlerList(); } return uriHandlers; }
private URIHandler createURIHandler(ClassLoader theClassLoader, URIConverter converter) { return new MyURIHandler(theClassLoader, converter); }
/** * Creates a new URI Handler for the n4scheme. */ public URIHandler createURIHandler(URIConverter converter) { return createURIHandler(classLoader, converter); }
public DebugURIHandler(EList<URIHandler> uriHandlers) { otherHandlers = new ArrayList<>(); otherHandlers.addAll(uriHandlers); }
@Override public EList<URIHandler> getURIHandlers() { return existing.getURIHandlers(); }
@Override public URIHandler getURIHandler(URI uri) { return existing.getURIHandler(uri); }
public ExternalContentAwareURIHandler(URIHandler delegate, IExternalContentProvider contentProvider) { this.delegate = delegate; this.contentProvider = contentProvider; }
private void checkConverter(URIConverter wrapped) { assertNotNull(wrapped); for(URIHandler handler: wrapped.getURIHandlers()) { assertTrue(handler instanceof ExternalContentSupport.ExternalContentAwareURIHandler); } }
@Override protected Object [] newData(int capacity) { return new URIHandler [capacity]; }
@Override public URIHandler [] data() { return (URIHandler[])data; }
/** * Creates an instance. */ public ExtensibleURIConverterImpl() { this(URIHandler.DEFAULT_HANDLERS, ContentHandler.Registry.INSTANCE.contentHandlers()); }
/** * Creates an instance. */ public ExtensibleURIConverterImpl(Collection<URIHandler> uriHandlers, Collection<ContentHandler> contentHandlers) { getURIHandlers().addAll(uriHandlers); getContentHandlers().addAll(contentHandlers); }
/** * Allows for the platform to contribute {@link URIHandler} elements to * the resource set. Contributions can come from: * * <ul> * <li>ClassRegistry extension point</li> * </ul> * * @return a list of {@link URIHandler} elements. */ protected List<URIHandler> getURIHandlerContributions() { return ClassRegistry.createInstances(URIHandler.class); }