public static Map<String, Object> frame(Object input, Object frame, JsonLdOptions opts)
            throws JsonLdError {

        if (frame instanceof Map) {
            frame = JsonLdUtils.clone(frame);
        }
        // TODO string/IO input

        // 2. Set expanded input to the result of using the expand method using
        // input and options.
        final Object expandedInput = expand(input, opts);

        // 3. Set expanded frame to the result of using the expand method using
        // frame and options with expandContext set to null and the
        // frameExpansion option set to true.
        final Object savedExpandedContext = opts.getExpandContext();
        opts.setExpandContext(null);
        opts.setFrameExpansion(true);
        final List<Object> expandedFrame = expand(frame, opts);
        opts.setExpandContext(savedExpandedContext);

        // 4. Set context to the value of @context from frame, if it exists, or
        // to a new empty
        // context, otherwise.
        final JsonLdApi api = new JsonLdApi(expandedInput, opts);
        final Context activeCtx = api.context
                .parse(((Map<String, Object>) frame).get(JsonLdConsts.CONTEXT));
        final List<Object> framed = api.frame(expandedInput, expandedFrame);
        if (opts.getPruneBlankNodeIdentifiers()) {
            JsonLdUtils.pruneBlankNodes(framed);
        }
        Object compacted = api.compact(activeCtx, null, framed, opts.getCompactArrays());
        final Map<String, Object> rval = activeCtx.serialize();
        final boolean addGraph = ((!(compacted instanceof List)) && !opts.getOmitGraph());
        if (addGraph && !(compacted instanceof List)) {
            final List<Object> tmp = new ArrayList<Object>();
            tmp.add(compacted);
            compacted = tmp;
        }
        if (addGraph || (compacted instanceof List)) {
            final String alias = activeCtx.compactIri(JsonLdConsts.GRAPH);
            rval.put(alias, compacted);
        } else if (!addGraph && (compacted instanceof Map)) {
            rval.putAll((Map) compacted);
        }
        JsonLdUtils.removePreserve(activeCtx, rval, opts);
        return rval;
    }
public static Map < String , Object > frame ( Object input , Object frame , JsonLdOptions opts ) throws JsonLdError { if ( frame instanceof Map ) { frame = JsonLdUtils . clone ( frame ) ; } final Object expandedInput = expand ( input , opts ) ; final Object savedExpandedContext = opts . getExpandContext ( ) ; opts . setExpandContext ( null ) ; opts . setFrameExpansion ( true ) ; final List < Object > expandedFrame = expand ( frame , opts ) ; opts . setExpandContext ( savedExpandedContext ) ; final JsonLdApi api = new JsonLdApi ( expandedInput , opts ) ; final Context activeCtx = api . context . parse ( ( ( Map < String , Object > ) frame ) . get ( JsonLdConsts . CONTEXT ) ) ; final List < Object > framed = api . frame ( expandedInput , expandedFrame ) ; if ( opts . getPruneBlankNodeIdentifiers ( ) ) { JsonLdUtils . pruneBlankNodes ( framed ) ; } Object compacted = api . compact ( activeCtx , null , framed , opts . getCompactArrays ( ) ) ; final Map < String , Object > rval = activeCtx . serialize ( ) ; final boolean addGraph = ( ( ! ( compacted instanceof List ) ) && ! opts . getOmitGraph ( ) ) ; if ( addGraph && ! ( compacted instanceof List ) ) { final List < Object > tmp = new ArrayList < Object > ( ) ; tmp . add ( compacted ) ; compacted = tmp ; } if ( addGraph || ( compacted instanceof List ) ) { final String alias = activeCtx . compactIri ( JsonLdConsts . GRAPH ) ; rval . put ( alias , compacted ) ; } else if ( ! addGraph && ( compacted instanceof Map ) ) { rval . putAll ( ( Map ) compacted ) ; } JsonLdUtils . removePreserve ( activeCtx , rval , opts ) ; return rval ; }
Frames the given input using the frame according to the steps in the
<a href=
"http://json-ld.org/spec/latest/json-ld-framing/#framing-algorithm">
Framing Algorithm</a>.

@param input
The input JSON-LD object.
@param frame
The frame to use when re-arranging the data of input; either
in the form of an JSON object or as IRI.
@param opts
The {@link JsonLdOptions} that are to be sent to the framing
algorithm.
@return The framed JSON-LD document
@throws JsonLdError
If there is an error while framing.