@Override public RemoteDocument loadDocument(String url) throws JsonLdError { return new RemoteDocument("http://nonexisting.example.com/context", context); } };
public RemoteDocument loadDocument(String url) throws JsonLdError { final RemoteDocument doc = new RemoteDocument(url, null); try { doc.setDocument(fromURL(new URL(url))); } catch (final Exception e) { new JsonLdError(JsonLdError.Error.LOADING_REMOTE_CONTEXT_FAILED, url); } return doc; }
if (m_injectedDocs.containsKey(url)) { try { return new RemoteDocument(url, m_injectedDocs.get(url)); } catch (final Exception e) { throw new JsonLdError(JsonLdError.Error.LOADING_INJECTED_CONTEXT_FAILED, url, e); return new RemoteDocument(url, JsonUtils.fromURL(new URL(url), getHttpClient())); } catch (final Exception e) { throw new JsonLdError(JsonLdError.Error.LOADING_REMOTE_CONTEXT_FAILED, url, e);
if (m_injectedDocs.containsKey(url)) { try { return new RemoteDocument(url, m_injectedDocs.get(url)); } catch (final Exception e) { throw new JsonLdError(JsonLdError.Error.LOADING_INJECTED_CONTEXT_FAILED, url, e); return new RemoteDocument(url, JsonUtils.fromURL(new URL(url), getHttpClient())); } catch (final Exception e) { throw new JsonLdError(JsonLdError.Error.LOADING_REMOTE_CONTEXT_FAILED, url, e);
@Override public RemoteDocument loadDocument(String url) throws JsonLdError { if (url == null) { throw new JsonLdError(JsonLdError.Error.LOADING_REMOTE_CONTEXT_FAILED, "URL was null"); } if (url.contains(":")) { // check if the url is relative to the test base if (url.startsWith(this.base)) { final String classpath = url.substring(this.base.length()); final ClassLoader cl = Thread.currentThread().getContextClassLoader(); final InputStream inputStream = cl .getResourceAsStream(TEST_DIR + "/" + classpath); try { return new RemoteDocument(url, JsonUtils.fromInputStream(inputStream)); } catch (final IOException e) { throw new JsonLdError(JsonLdError.Error.LOADING_DOCUMENT_FAILED, e); } } } // we can't load this remote document from the test suite throw new JsonLdError(JsonLdError.Error.NOT_IMPLEMENTED, "URL scheme was not recognised: " + url); }