Class QuadsToJsonld
- java.lang.Object
-
- com.apicatalog.jsonld.serialization.QuadsToJsonld
-
- All Implemented Interfaces:
com.apicatalog.rdf.api.RdfQuadConsumer
public class QuadsToJsonld extends java.lang.Object implements com.apicatalog.rdf.api.RdfQuadConsumerQuadsToJsonld implementsRdfQuadConsumerand provides functionality to transform an RDF quad set into a JSON-LD document in expanded form.The transformation process involves processing compound literal subjects, lists, blank nodes, and constructing JSON-LD representations for both default and named graphs.
This class can be configured using methods such as
ordered(boolean),rdfDirection(RdfDirection),useNativeTypes(boolean),useRdfType(boolean),mode(JsonLdVersion), anduriValidation(UriValidationPolicy).Key methods include:
reset()to clear the internal state for reuse.toJsonLd()to generate the JSON-LD output from the processed quads.quad(String, String, String, String, String, String, String)to ingest a single RDF quad.
- Since:
- 1.7.0
- See Also:
RdfQuadConsumer
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Boolean>>compoundLiteralSubjectsprotected GraphMapgraphMapprotected booleanorderedprotected JsonLdVersionprocessingModeprotected JsonLdOptions.RdfDirectionrdfDirectionprotected java.util.Map<java.lang.String,GraphMap.Reference>referenceOnceprotected UriValidationPolicyuriValidationprotected booleanuseNativeTypesprotected booleanuseRdfType
-
Constructor Summary
Constructors Constructor Description QuadsToJsonld()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QuadsToJsonldmode(JsonLdVersion processingMode)Sets the JSON-LD processing mode.QuadsToJsonldoptions(JsonLdOptions options)QuadsToJsonldordered(boolean ordered)Configures whether the output should be ordered.com.apicatalog.rdf.api.RdfQuadConsumerquad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph)QuadsToJsonldrdfDirection(JsonLdOptions.RdfDirection rdfDirection)Sets the RDF direction configuration.QuadsToJsonldreset()Resets the consumer to an empty state, allowing the same instance to process different datasets.jakarta.json.JsonArraytoJsonLd()Generates a new JSON-LD representation based on the received quads.(package private) jakarta.json.JsonObjecttoObject(java.lang.String object, java.lang.String datatype, java.lang.String langTag, java.lang.String direction)QuadsToJsonlduriValidation(UriValidationPolicy uriValidation)Sets the URI validation policy.QuadsToJsonlduseNativeTypes(boolean useNativeTypes)Configures whether to use native types for literal conversion.QuadsToJsonlduseRdfType(boolean useRdfType)
-
-
-
Field Detail
-
ordered
protected boolean ordered
-
rdfDirection
protected JsonLdOptions.RdfDirection rdfDirection
-
useNativeTypes
protected boolean useNativeTypes
-
useRdfType
protected boolean useRdfType
-
uriValidation
protected UriValidationPolicy uriValidation
-
processingMode
protected JsonLdVersion processingMode
-
graphMap
protected GraphMap graphMap
-
compoundLiteralSubjects
protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Boolean>> compoundLiteralSubjects
-
referenceOnce
protected java.util.Map<java.lang.String,GraphMap.Reference> referenceOnce
-
-
Method Detail
-
ordered
public QuadsToJsonld ordered(boolean ordered)
Configures whether the output should be ordered.- Parameters:
ordered- true if ordering is required; false otherwise- Returns:
- this instance for chaining
-
rdfDirection
public QuadsToJsonld rdfDirection(JsonLdOptions.RdfDirection rdfDirection)
Sets the RDF direction configuration.- Parameters:
rdfDirection- the RDF direction (e.g., COMPOUND_LITERAL)- Returns:
- this instance for chaining
-
useNativeTypes
public QuadsToJsonld useNativeTypes(boolean useNativeTypes)
Configures whether to use native types for literal conversion.- Parameters:
useNativeTypes- true to use native types; false otherwise- Returns:
- this instance for chaining
-
useRdfType
public QuadsToJsonld useRdfType(boolean useRdfType)
-
mode
public QuadsToJsonld mode(JsonLdVersion processingMode)
Sets the JSON-LD processing mode.- Parameters:
processingMode- the processing mode (e.g., V1_0, V1_1)- Returns:
- this instance for chaining
-
uriValidation
public QuadsToJsonld uriValidation(UriValidationPolicy uriValidation)
Sets the URI validation policy.- Parameters:
uriValidation- the URI validation policy- Returns:
- this instance for chaining
-
options
public QuadsToJsonld options(JsonLdOptions options)
-
reset
public QuadsToJsonld reset()
Resets the consumer to an empty state, allowing the same instance to process different datasets.- Returns:
- the current
QuadsToJsonldinstance after resetting
-
toJsonLd
public jakarta.json.JsonArray toJsonLd() throws JsonLdErrorGenerates a new JSON-LD representation based on the received quads.This method processes all the quads stored in the internal graph map and transforms them into a JSON-LD document in expanded form.
- Returns:
- a
JsonArraycontaining the generated JSON-LD data - Throws:
JsonLdError- if an error occurs during JSON-LD generation
-
quad
public com.apicatalog.rdf.api.RdfQuadConsumer quad(java.lang.String subject, java.lang.String predicate, java.lang.String object, java.lang.String datatype, java.lang.String language, java.lang.String direction, java.lang.String graph) throws com.apicatalog.rdf.api.RdfConsumerException- Specified by:
quadin interfacecom.apicatalog.rdf.api.RdfQuadConsumer- Throws:
com.apicatalog.rdf.api.RdfConsumerException
-
toObject
jakarta.json.JsonObject toObject(java.lang.String object, java.lang.String datatype, java.lang.String langTag, java.lang.String direction) throws com.apicatalog.rdf.api.RdfConsumerException- Throws:
com.apicatalog.rdf.api.RdfConsumerException
-
-