/*** * _____ _ _ _ _ _ _ _ _ | ___| | __ _| |_| |_ ___ _ __ / \ | | __ _ ___ _ * __(_) |_| |__ _ __ ___ | |_ | |/ _` | __| __/ _ \ '_ \ / _ \ | |/ _` |/ _ * \| '__| | __| '_ \| '_ ` _ \ | _| | | (_| | |_| || __/ | | | / ___ \| | * (_| | (_) | | | | |_| | | | | | | | | |_| |_|\__,_|\__|\__\___|_| |_| /_/ * \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_| |___/ */ void generateNodeMap(Object element, Map<String, Object> nodeMap) throws JsonLdError { generateNodeMap(element, nodeMap, "@default", null, null, null); }
/*** * _____ _ _ _ _ _ _ _ _ | ___| | __ _| |_| |_ ___ _ __ / \ | | __ _ ___ _ * __(_) |_| |__ _ __ ___ | |_ | |/ _` | __| __/ _ \ '_ \ / _ \ | |/ _` |/ _ * \| '__| | __| '_ \| '_ ` _ \ | _| | | (_| | |_| || __/ | | | / ___ \| | * (_| | (_) | | | | |_| | | | | | | | | |_| |_|\__,_|\__|\__\___|_| |_| /_/ * \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_| |___/ */ void generateNodeMap(Object element, Map<String, Object> nodeMap) throws JsonLdError { generateNodeMap(element, nodeMap, JsonLdConsts.DEFAULT, null, null, null); }
/*** * _____ _ _ _ _ _ _ _ _ | ___| | __ _| |_| |_ ___ _ __ / \ | | __ _ ___ _ * __(_) |_| |__ _ __ ___ | |_ | |/ _` | __| __/ _ \ '_ \ / _ \ | |/ _` |/ _ * \| '__| | __| '_ \| '_ ` _ \ | _| | | (_| | |_| || __/ | | | / ___ \| | * (_| | (_) | | | | |_| | | | | | | | | |_| |_|\__,_|\__|\__\___|_| |_| /_/ * \_\_|\__, |\___/|_| |_|\__|_| |_|_| |_| |_| |___/ */ void generateNodeMap(Object element, Map<String, Object> nodeMap) throws JsonLdError { generateNodeMap(element, nodeMap, JsonLdConsts.DEFAULT, null, null, null); }
/** * Performs JSON-LD * <a href="http://json-ld.org/spec/latest/json-ld-framing/">framing</a>. * * @param input * the expanded JSON-LD to frame. * @param frame * the expanded JSON-LD frame to use. * @return the framed output. * @throws JsonLdError * If the framing was not successful. */ public List<Object> frame(Object input, List<Object> frame) throws JsonLdError { // create framing state final FramingContext state = new FramingContext(this.opts); // use tree map so keys are sorted by default final Map<String, Object> nodes = new TreeMap<String, Object>(); generateNodeMap(input, nodes); this.nodeMap = (Map<String, Object>) nodes.get(JsonLdConsts.DEFAULT); final List<Object> framed = new ArrayList<Object>(); // NOTE: frame validation is done by the function not allowing anything // other than list to me passed // 1. // If frame is an array, set frame to the first member of the array, // which MUST be a valid frame. frame(state, this.nodeMap, (frame != null && frame.size() > 0 ? (Map<String, Object>) frame.get(0) : newMap()), framed, null); return framed; }
/** * Performs JSON-LD <a * href="http://json-ld.org/spec/latest/json-ld-framing/">framing</a>. * * @param input * the expanded JSON-LD to frame. * @param frame * the expanded JSON-LD frame to use. * @return the framed output. * @throws JsonLdError * If the framing was not successful. */ public List<Object> frame(Object input, List<Object> frame) throws JsonLdError { // create framing state final FramingContext state = new FramingContext(this.opts); // use tree map so keys are sotred by default final Map<String, Object> nodes = new TreeMap<>(); generateNodeMap(input, nodes); this.nodeMap = (Map<String, Object>) nodes.get("@default"); final List<Object> framed = new ArrayList<>(); // NOTE: frame validation is done by the function not allowing anything // other than list to me passed frame(state, this.nodeMap, (frame != null && !frame.isEmpty() ? (Map<String, Object>) frame.get(0) : newMap()), framed, null); return framed; }
/** * Performs JSON-LD * <a href="http://json-ld.org/spec/latest/json-ld-framing/">framing</a>. * * @param input * the expanded JSON-LD to frame. * @param frame * the expanded JSON-LD frame to use. * @return the framed output. * @throws JsonLdError * If the framing was not successful. */ public List<Object> frame(Object input, List<Object> frame) throws JsonLdError { // create framing state final FramingContext state = new FramingContext(this.opts); // use tree map so keys are sorted by default final Map<String, Object> nodes = new TreeMap<String, Object>(); generateNodeMap(input, nodes); this.nodeMap = (Map<String, Object>) nodes.get(JsonLdConsts.DEFAULT); final List<Object> framed = new ArrayList<Object>(); // NOTE: frame validation is done by the function not allowing anything // other than list to me passed // 1. // If frame is an array, set frame to the first member of the array, // which MUST be a valid frame. frame(state, this.nodeMap, (frame != null && frame.size() > 0 ? (Map<String, Object>) frame.get(0) : newMap()), framed, null); return framed; }
/** * Adds RDF triples for each graph in the current node map to an RDF * dataset. * * @return the RDF dataset. * @throws JsonLdError * If there was an error converting from JSON-LD to RDF. */ public RDFDataset toRDF() throws JsonLdError { // TODO: make the default generateNodeMap call (i.e. without a // graphName) create and return the nodeMap final Map<String, Object> nodeMap = newMap(); nodeMap.put("@default", newMap()); generateNodeMap(this.value, nodeMap); final RDFDataset dataset = new RDFDataset(this); for (final Map.Entry<String, Object> stringObjectEntry : nodeMap.entrySet()) { // 4.1) if (JsonLdUtils.isRelativeIri(stringObjectEntry.getKey())) { continue; } final Map<String, Object> graph = (Map<String, Object>) stringObjectEntry.getValue(); replaceBlankNode(graph); dataset.graphToRDF(stringObjectEntry.getKey(), graph); } return dataset; }
generateNodeMap(item, nodeMap, activeGraph, activeSubject, activeProperty, list); generateNodeMap(elem.get("@list"), nodeMap, activeGraph, activeSubject, activeProperty, result); generateNodeMap(value, nodeMap, activeGraph, referencedNode, stringObjectEntry.getKey(), null); generateNodeMap(elem.remove("@graph"), nodeMap, id, null, null, null); generateNodeMap(value, nodeMap, activeGraph, id, property, null);
nodeMap.put("@default", newMap()); new JsonLdApi(opts).generateNodeMap(expanded, nodeMap);
nodeMap.put(JsonLdConsts.DEFAULT, newMap()); new JsonLdApi(opts).generateNodeMap(expanded, nodeMap);
/** * Adds RDF triples for each graph in the current node map to an RDF * dataset. * * @return the RDF dataset. * @throws JsonLdError * If there was an error converting from JSON-LD to RDF. */ public RDFDataset toRDF() throws JsonLdError { // TODO: make the default generateNodeMap call (i.e. without a // graphName) create and return the nodeMap final Map<String, Object> nodeMap = newMap(); nodeMap.put(JsonLdConsts.DEFAULT, newMap()); generateNodeMap(this.value, nodeMap); final RDFDataset dataset = new RDFDataset(this); for (final String graphName : nodeMap.keySet()) { // 4.1) if (JsonLdUtils.isRelativeIri(graphName)) { continue; } final Map<String, Object> graph = (Map<String, Object>) nodeMap.get(graphName); dataset.graphToRDF(graphName, graph); } return dataset; }
/** * Adds RDF triples for each graph in the current node map to an RDF * dataset. * * @return the RDF dataset. * @throws JsonLdError * If there was an error converting from JSON-LD to RDF. */ public RDFDataset toRDF() throws JsonLdError { // TODO: make the default generateNodeMap call (i.e. without a // graphName) create and return the nodeMap final Map<String, Object> nodeMap = newMap(); nodeMap.put(JsonLdConsts.DEFAULT, newMap()); generateNodeMap(this.value, nodeMap); final RDFDataset dataset = new RDFDataset(this); for (final String graphName : nodeMap.keySet()) { // 4.1) if (JsonLdUtils.isRelativeIri(graphName)) { continue; } final Map<String, Object> graph = (Map<String, Object>) nodeMap.get(graphName); dataset.graphToRDF(graphName, graph); } return dataset; }
nodeMap.put(JsonLdConsts.DEFAULT, newMap()); new JsonLdApi(opts).generateNodeMap(expanded, nodeMap);
generateNodeMap(item, nodeMap, activeGraph, activeSubject, activeProperty, list); generateNodeMap(elem.get(JsonLdConsts.LIST), nodeMap, activeGraph, activeSubject, activeProperty, result); generateNodeMap(value, nodeMap, activeGraph, referencedNode, property, null); generateNodeMap(elem.remove(JsonLdConsts.GRAPH), nodeMap, id, null, null, null); generateNodeMap(value, nodeMap, activeGraph, id, property, null);
generateNodeMap(item, nodeMap, activeGraph, activeSubject, activeProperty, list); generateNodeMap(elem.get(JsonLdConsts.LIST), nodeMap, activeGraph, activeSubject, activeProperty, result); generateNodeMap(value, nodeMap, activeGraph, referencedNode, property, null); generateNodeMap(elem.remove(JsonLdConsts.GRAPH), nodeMap, id, null, null, null); generateNodeMap(value, nodeMap, activeGraph, id, property, null);