/** * 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 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; }