Class JsonLdApi
java.lang.Object
com.github.jsonldjava.core.JsonLdApi
A container object to maintain state relating to JsonLdOptions and the
current Context, and push these into the relevant algorithms in
JsonLdProcessor as necessary.
- Author:
- tristan
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty JsonLdApi object using the default JsonLdOptions, and without initialization.JsonLdApi(JsonLdOptions opts) Constructs an empty JsonLdApi object using the given JsonLdOptions, and without initialization.JsonLdApi(Object input, JsonLdOptions opts) Constructs a JsonLdApi object using the given object as the initial JSON-LD object, and the given JsonLdOptions.JsonLdApi(Object input, Object context, JsonLdOptions opts) Constructs a JsonLdApi object using the given object as the initial JSON-LD object, the given context, and the given JsonLdOptions. -
Method Summary
Modifier and TypeMethodDescriptionCompaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#compaction-algorithmCompaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#compaction-algorithmExpansion Algorithm http://json-ld.org/spec/latest/json-ld-api/#expansion-algorithmExpansion Algorithm http://json-ld.org/spec/latest/json-ld-api/#expansion-algorithmPerforms JSON-LD framing.fromRDF(RDFDataset dataset) Converts RDF statements into JSON-LD.fromRDF(RDFDataset dataset, boolean noDuplicatesInDataset) Converts RDF statements into JSON-LD, presuming that there are no duplicates in the dataset.Performs RDF normalization on the given JSON-LD input.toRDF()Adds RDF triples for each graph in the current node map to an RDF dataset.
-
Constructor Details
-
JsonLdApi
public JsonLdApi()Constructs an empty JsonLdApi object using the default JsonLdOptions, and without initialization. -
JsonLdApi
Constructs a JsonLdApi object using the given object as the initial JSON-LD object, and the given JsonLdOptions.- Parameters:
input- The initial JSON-LD object.opts- The JsonLdOptions to use.- Throws:
JsonLdError- If there is an error initializing using the object and options.
-
JsonLdApi
Constructs a JsonLdApi object using the given object as the initial JSON-LD object, the given context, and the given JsonLdOptions.- Parameters:
input- The initial JSON-LD object.context- The initial context.opts- The JsonLdOptions to use.- Throws:
JsonLdError- If there is an error initializing using the object and options.
-
JsonLdApi
Constructs an empty JsonLdApi object using the given JsonLdOptions, and without initialization.
If the JsonLdOptions parameter is null, then the default options are used.- Parameters:
opts- The JsonLdOptions to use.
-
-
Method Details
-
compact
public Object compact(Context activeCtx, String activeProperty, Object element, boolean compactArrays) throws JsonLdError Compaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#compaction-algorithm- Parameters:
activeCtx- The Active ContextactiveProperty- The Active Propertyelement- The current elementcompactArrays- True to compact arrays.- Returns:
- The compacted JSON-LD object.
- Throws:
JsonLdError- If there was an error during compaction.
-
compact
Compaction Algorithm http://json-ld.org/spec/latest/json-ld-api/#compaction-algorithm- Parameters:
activeCtx- The Active ContextactiveProperty- The Active Propertyelement- The current element- Returns:
- The compacted JSON-LD object.
- Throws:
JsonLdError- If there was an error during compaction.
-
expand
Expansion Algorithm http://json-ld.org/spec/latest/json-ld-api/#expansion-algorithm- Parameters:
activeCtx- The Active ContextactiveProperty- The Active Propertyelement- The current element- Returns:
- The expanded JSON-LD object.
- Throws:
JsonLdError- If there was an error during expansion.
-
expand
Expansion Algorithm http://json-ld.org/spec/latest/json-ld-api/#expansion-algorithm- Parameters:
activeCtx- The Active Contextelement- The current element- Returns:
- The expanded JSON-LD object.
- Throws:
JsonLdError- If there was an error during expansion.
-
frame
Performs JSON-LD framing.- Parameters:
input- the expanded JSON-LD to frame.frame- the expanded JSON-LD frame to use.- Returns:
- the framed output.
- Throws:
JsonLdError- If the framing was not successful.
-
fromRDF
Converts RDF statements into JSON-LD.- Parameters:
dataset- the RDF statements.- Returns:
- A list of JSON-LD objects found in the given dataset.
- Throws:
JsonLdError- If there was an error during conversion from RDF to JSON-LD.
-
fromRDF
Converts RDF statements into JSON-LD, presuming that there are no duplicates in the dataset.- Parameters:
dataset- the RDF statements.noDuplicatesInDataset- True if there are no duplicates in the dataset and false otherwise.- Returns:
- A list of JSON-LD objects found in the given dataset.
- Throws:
JsonLdError- If there was an error during conversion from RDF to JSON-LD.
-
toRDF
Adds RDF triples for each graph in the current node map to an RDF dataset.- Returns:
- the RDF dataset.
- Throws:
JsonLdError- If there was an error converting from JSON-LD to RDF.
-
normalize
Performs RDF normalization on the given JSON-LD input.- Parameters:
dataset- the expanded JSON-LD object to normalize.- Returns:
- The normalized JSON-LD object
- Throws:
JsonLdError- If there was an error while normalizing.
-