/** * Add a prefix mapping to the current JSON-LD context, as a prefix string and target string. * Rebuilds the context. * * @param prefix the short prefix to add; should not include ":" * @param target the IRI string that is the target of the prefix * @throws IOException if prefix cannot be parsed */ public void addPrefix(String prefix, String target) throws IOException { try { context.put(prefix.trim(), target.trim()); context.remove("@base"); setContext((Map<String, Object>) context); } catch (Exception e) { throw new IOException(String.format(prefixLoadError, prefix, target), e); } }
private void init(JsonLdOptions options) { this.options = options; if (options.getBase() != null) { this.put(JsonLdConsts.BASE, options.getBase()); } this.termDefinitions = newMap(); }
private void init(JsonLdOptions options) { this.options = options; if (options.getBase() != null) { this.put("@base", options.getBase()); } this.termDefinitions = newMap(); }
private void init(JsonLdOptions options) { this.options = options; if (options.getBase() != null) { this.put(JsonLdConsts.BASE, options.getBase()); } this.termDefinitions = newMap(); }
} else if (value instanceof String) { if (JsonLdUtils.isAbsoluteIri((String) value)) { result.put("@base", value); } else { final String baseUri = (String) result.get("@base"); throw new JsonLdError(Error.INVALID_BASE_IRI, baseUri); result.put("@base", JsonLdUrl.resolve(baseUri, (String) value)); } else if (value instanceof String) { if (JsonLdUtils.isAbsoluteIri((String) value)) { result.put("@vocab", value); } else { throw new JsonLdError(Error.INVALID_VOCAB_MAPPING, result.remove("@language"); } else if (value instanceof String) { result.put("@language", ((String) value).toLowerCase()); } else { throw new JsonLdError(Error.INVALID_DEFAULT_LANGUAGE, value);
result.put(JsonLdConsts.BASE, value); } else { throw new JsonLdError(Error.INVALID_BASE_IRI, baseUri); result.put(JsonLdConsts.BASE, JsonLdUrl.resolve(baseUri, (String) value)); } else if (value instanceof String) { if (JsonLdUtils.isAbsoluteIri((String) value)) { result.put(JsonLdConsts.VOCAB, value); } else { throw new JsonLdError(Error.INVALID_VOCAB_MAPPING, result.remove(JsonLdConsts.LANGUAGE); } else if (value instanceof String) { result.put(JsonLdConsts.LANGUAGE, ((String) value).toLowerCase()); } else { throw new JsonLdError(Error.INVALID_DEFAULT_LANGUAGE, value);
result.put(JsonLdConsts.BASE, value); } else { throw new JsonLdError(Error.INVALID_BASE_IRI, baseUri); result.put(JsonLdConsts.BASE, JsonLdUrl.resolve(baseUri, (String) value)); } else if (value instanceof String) { if (JsonLdUtils.isAbsoluteIri((String) value)) { result.put(JsonLdConsts.VOCAB, value); } else { throw new JsonLdError(Error.INVALID_VOCAB_MAPPING, result.remove(JsonLdConsts.LANGUAGE); } else if (value instanceof String) { result.put(JsonLdConsts.LANGUAGE, ((String) value).toLowerCase()); } else { throw new JsonLdError(Error.INVALID_DEFAULT_LANGUAGE, value);