/** * Context Processing Algorithm * * http://json-ld.org/spec/latest/json-ld-api/#context-processing-algorithms * * @param localContext * The Local Context object. * @param remoteContexts * The list of Strings denoting the remote Context URLs. * @return The parsed and merged Context. * @throws JsonLdError * If there is an error parsing the contexts. */ @SuppressWarnings("unchecked") public Context parse(Object localContext, List<String> remoteContexts) throws JsonLdError { return parse(localContext, remoteContexts, false); }
/** * Context Processing Algorithm * * http://json-ld.org/spec/latest/json-ld-api/#context-processing-algorithms * * @param localContext * The Local Context object. * @param remoteContexts * The list of Strings denoting the remote Context URLs. * @return The parsed and merged Context. * @throws JsonLdError * If there is an error parsing the contexts. */ @SuppressWarnings("unchecked") public Context parse(Object localContext, List<String> remoteContexts) throws JsonLdError { return parse(localContext, remoteContexts, false); }
public Context parse(Object localContext) throws JsonLdError { return this.parse(localContext, new ArrayList<String>()); }
public Context parse(Object localContext) throws JsonLdError { return this.parse(localContext, new ArrayList<String>()); }
public Context parse(Object localContext) throws JsonLdError { return this.parse(localContext, new ArrayList<String>()); }
/** * Set the current JSON-LD context to the given map. * * @param map a map of strings for the new JSON-LD context * @throws IOException on issue parsing JSON */ public void setContext(Map<String, Object> map) throws IOException { try { this.context = new Context().parse(map); } catch (JsonLdError e) { throw new IOException(jsonldContextParseError, e); } }
private BdioContext(Builder builder) { this.valueMapper = Objects.requireNonNull(builder.valueMapper); this.documentLoader = Objects.requireNonNull(builder.documentLoader); this.embeddedTypes = ImmutableSet.copyOf(builder.embeddedTypes); this.base = builder.base; this.expandContext = builder.expandContext; // TODO We should have a different path for legacy BDIO contexts this.context = new Context(jsonLdOptions()).parse(expandContext); }
/** * Load a map of prefixes from the "@context" of a JSON-LD string. * * @param jsonString the JSON-LD string * @return a map from prefix name strings to prefix IRI strings * @throws IOException on any problem */ @SuppressWarnings("unchecked") public static Context parseContext(String jsonString) throws IOException { try { Object jsonObject = JsonUtils.fromString(jsonString); if (!(jsonObject instanceof Map)) { throw new IOException(jsonldContextParseError); } Map<String, Object> jsonMap = (Map<String, Object>) jsonObject; if (!jsonMap.containsKey("@context")) { throw new IOException(jsonldContextParseError); } Object jsonContext = jsonMap.get("@context"); return new Context().parse(jsonContext); } catch (Exception e) { throw new IOException(jsonldContextParseError, e); } }
/** * Initializes this object by cloning the input object using * {@link JsonLdUtils#clone(Object)}, and by parsing the context using * {@link Context#parse(Object)}. * * @param input * The initial object, which is to be cloned and used in * operations. * @param context * The context object, which is to be parsed and used in * operations. * @throws JsonLdError * If there was an error cloning the object, or in parsing the * context. */ private void initialize(Object input, Object context) throws JsonLdError { if (input instanceof List || input instanceof Map) { this.value = JsonLdUtils.clone(input); } // TODO: string/IO input this.context = new Context(opts); if (context != null) { this.context = this.context.parse(context); } }
/** * Initializes this object by cloning the input object using * {@link JsonLdUtils#clone(Object)}, and by parsing the context using * {@link Context#parse(Object)}. * * @param input * The initial object, which is to be cloned and used in * operations. * @param context * The context object, which is to be parsed and used in * operations. * @throws JsonLdError * If there was an error cloning the object, or in parsing the * context. */ private void initialize(Object input, Object context) throws JsonLdError { if (input instanceof List || input instanceof Map) { this.value = JsonLdUtils.clone(input); } // TODO: string/IO input this.context = new Context(opts); if (context != null) { this.context = this.context.parse(context); } }
/** * Initializes this object by cloning the input object using * {@link JsonLdUtils#clone(Object)}, and by parsing the context using * {@link Context#parse(Object)}. * * @param input * The initial object, which is to be cloned and used in * operations. * @param context * The context object, which is to be parsed and used in * operations. * @throws JsonLdError * If there was an error cloning the object, or in parsing the * context. */ private void initialize(Object input, Object context) throws JsonLdError { if (input instanceof List || input instanceof Map) { this.value = JsonLdUtils.clone(input); } // TODO: string/IO input this.context = new Context(opts); if (context != null) { this.context = this.context.parse(context); } }
context = context.parse(contextLike);
activeCtx = activeCtx.parse(context);
activeCtx = activeCtx.parse(context);
exCtx = ((Map<String, Object>) exCtx).get("@context"); activeCtx = activeCtx.parse(exCtx);
context = context.parse(contextLike);
context = context.parse(contextLike);
exCtx = ((Map<String, Object>) exCtx).get(JsonLdConsts.CONTEXT); activeCtx = activeCtx.parse(exCtx);
final Context activeCtx = api.context.parse(((Map<String, Object>) frame).get("@context"));
.parse(((Map<String, Object>) frame).get(JsonLdConsts.CONTEXT)); final List<Object> framed = api.frame(expandedInput, expandedFrame); if (opts.getPruneBlankNodeIdentifiers()) {