/** * Parses a JSON-LD document, from the contents of the JSON resource * resolved from the JsonLdUrl, to an object that can be used as input for * the {@link JsonLdApi} and {@link JsonLdProcessor} methods. * * @param url * The JsonLdUrl to resolve * @return A JSON Object. * @throws JsonParseException * If there was a JSON related error during parsing. * @throws IOException * If there was an IO error during parsing. */ public static Object fromURL(java.net.URL url) throws JsonParseException, IOException { return DOCUMENT_LOADER.fromURL(url); }
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; }
@Test public void contextLoadedFromJarCache() throws Exception { // RDFToManifest.makeBaseURI(); // trigger static{} block @SuppressWarnings("unchecked") Map<String, Object> context = (Map<String, Object>) new DocumentLoader() .fromURL(new URL(CONTEXT)); // FIXME: jsonld-java 0.3 and later uses DocumentLoader instead of // JSONUtils // Map<String, Object> context = (Map<String, Object>) // JSONUtils.fromURL(new URL(CONTEXT)); Object retrievedFrom = context.get("http://purl.org/pav/retrievedFrom"); assertNotNull("Did not load context from cache: " + CONTEXT, retrievedFrom); } }