/** Set an empty context. */ public void setContext() { this.context = new Context(); }
/** * 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 activeCtx = new Context(opts); activeCtx = activeCtx.parse(context);
Context activeCtx = new Context(opts); activeCtx = activeCtx.parse(context);
Context activeCtx = new Context(opts); activeCtx = activeCtx.parse(context);
context = ((Map<String, Object>) context).get(JsonLdConsts.CONTEXT); Context activeCtx = new Context(opts); activeCtx = activeCtx.parse(context);
context = ((Map<String, Object>) context).get("@context"); Context activeCtx = new Context(opts); activeCtx = activeCtx.parse(context);
context = ((Map<String, Object>) context).get(JsonLdConsts.CONTEXT); Context activeCtx = new Context(opts); activeCtx = activeCtx.parse(context);
Context activeCtx = new Context(opts);
Context activeCtx = new Context(opts);
Context activeCtx = new Context(opts);
result = new Context(this.options); continue; } else if (context instanceof Context) {