Package com.apicatalog.jsonld
Class JsonLdOptions
- java.lang.Object
-
- com.apicatalog.jsonld.JsonLdOptions
-
public final class JsonLdOptions extends Object
TheJsonLdOptionstype is used to pass various options to the processor.- See Also:
- The JsonLdOptions Specification.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJsonLdOptions.RdfDirection
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_NUMERIC_IDstatic booleanDEFAULT_RDF_STARstatic booleanDEFAULT_URI_VALIDATION
-
Constructor Summary
Constructors Constructor Description JsonLdOptions()JsonLdOptions(JsonLdOptions options)JsonLdOptions(DocumentLoader loader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URIgetBase()The base IRI to use when expanding or compacting the document.Cache<String,jakarta.json.JsonValue>getContextCache()Cache<String,Document>getDocumentCache()DocumentLoadergetDocumentLoader()The callback of the loader to be used to retrieve remote documents and contexts, implementing theDocumentLoader.JsonLdEmbedgetEmbed()DocumentgetExpandContext()JsonLdVersiongetProcessingMode()JsonLdOptions.RdfDirectiongetRdfDirection()booleanisCompactArrays()If set totrue, the processor replaces arrays with just one element with that element during compaction.booleanisCompactToRelative()Determines if IRIs are compacted relative to thegetBase()option or document location when compacting.booleanisExplicit()booleanisExtractAllScripts()If set totrue, when extracting JSON-LD script elements from HTML, unless a specific fragment identifier is targeted, extracts all encountered JSON-LD script elements using an array form, if necessary.booleanisNumericId()Experimental: Numeric @id support state.booleanisOmitDefault()BooleanisOmitGraph()booleanisOrdered()If set totrue, certain algorithm processing steps where indicated are ordered lexicographically.booleanisProduceGeneralizedRdf()booleanisRdfStar()booleanisRequiredAll()booleanisUriValidation()if disabled only URIs required for processing are parsed and validated.booleanisUseNativeTypes()booleanisUseRdfType()voidsetBase(URI baseUri)voidsetCompactArrays(boolean compactArrays)voidsetCompactToRelative(boolean compactToRelative)voidsetContextCache(Cache<String,jakarta.json.JsonValue> contextCache)voidsetDocumentCache(Cache<String,Document> documentCache)voidsetDocumentLoader(DocumentLoader documentLoader)voidsetEmbed(JsonLdEmbed embed)voidsetExpandContext(Document context)voidsetExpandContext(jakarta.json.JsonObject context)voidsetExpandContext(String contextLocation)voidsetExpandContext(URI contextUri)voidsetExplicit(boolean explicit)voidsetExtractAllScripts(boolean extractAllScripts)voidsetNumericId(boolean enable)Experimental: Enables/Disables numeric @id support.voidsetOmitDefault(boolean omitDefault)voidsetOmitGraph(Boolean omitGraph)voidsetOrdered(boolean ordered)voidsetProcessingMode(JsonLdVersion processingMode)voidsetProduceGeneralizedRdf(boolean produceGeneralizedRdf)voidsetRdfDirection(JsonLdOptions.RdfDirection rdfDirection)voidsetRdfStar(boolean rdfStar)Experimental: Enables JSON-LD-STAR extension.voidsetRequiredAll(boolean requiredAll)voidsetUriValidation(boolean enabled)if disabled only URIs required for processing are parsed and validated.voidsetUseNativeTypes(boolean useNativeTypes)voidsetUseRdfType(boolean useRdfType)
-
-
-
Field Detail
-
DEFAULT_RDF_STAR
public static final boolean DEFAULT_RDF_STAR
- See Also:
- Constant Field Values
-
DEFAULT_NUMERIC_ID
public static final boolean DEFAULT_NUMERIC_ID
- See Also:
- Constant Field Values
-
DEFAULT_URI_VALIDATION
public static final boolean DEFAULT_URI_VALIDATION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JsonLdOptions
public JsonLdOptions()
-
JsonLdOptions
public JsonLdOptions(DocumentLoader loader)
-
JsonLdOptions
public JsonLdOptions(JsonLdOptions options)
-
-
Method Detail
-
getBase
public URI getBase()
The base IRI to use when expanding or compacting the document. If set, this overrides the input document's IRI.- Returns:
- the base URI or
null
-
isCompactArrays
public boolean isCompactArrays()
If set totrue, the processor replaces arrays with just one element with that element during compaction. If set to false, all arrays will remain arrays even if they have just one element.- Returns:
trueif array compaction is enabled
-
isCompactToRelative
public boolean isCompactToRelative()
Determines if IRIs are compacted relative to thegetBase()option or document location when compacting.- Returns:
trueif IRI relativization is enabled
-
getDocumentLoader
public DocumentLoader getDocumentLoader()
The callback of the loader to be used to retrieve remote documents and contexts, implementing theDocumentLoader. If specified, it is used to retrieve remote documents and contexts; otherwise, if not specified, the processor's built-in loader is used.- Returns:
- the loader or
nullis is not set
-
isExtractAllScripts
public boolean isExtractAllScripts()
If set totrue, when extracting JSON-LD script elements from HTML, unless a specific fragment identifier is targeted, extracts all encountered JSON-LD script elements using an array form, if necessary.- Returns:
trueif script extraction is enabled
-
isOrdered
public boolean isOrdered()
If set totrue, certain algorithm processing steps where indicated are ordered lexicographically. Iffalse, order is not considered in processing.- Returns:
trueif array sorting is enabled
-
getProcessingMode
public JsonLdVersion getProcessingMode()
-
isProduceGeneralizedRdf
public boolean isProduceGeneralizedRdf()
-
getRdfDirection
public JsonLdOptions.RdfDirection getRdfDirection()
-
isUseNativeTypes
public boolean isUseNativeTypes()
-
isUseRdfType
public boolean isUseRdfType()
-
getExpandContext
public Document getExpandContext()
-
setBase
public void setBase(URI baseUri)
-
setCompactArrays
public void setCompactArrays(boolean compactArrays)
-
setCompactToRelative
public void setCompactToRelative(boolean compactToRelative)
-
setDocumentLoader
public void setDocumentLoader(DocumentLoader documentLoader)
-
setExtractAllScripts
public void setExtractAllScripts(boolean extractAllScripts)
-
setOrdered
public void setOrdered(boolean ordered)
-
setProcessingMode
public void setProcessingMode(JsonLdVersion processingMode)
-
setProduceGeneralizedRdf
public void setProduceGeneralizedRdf(boolean produceGeneralizedRdf)
-
setRdfDirection
public void setRdfDirection(JsonLdOptions.RdfDirection rdfDirection)
-
setUseNativeTypes
public void setUseNativeTypes(boolean useNativeTypes)
-
setUseRdfType
public void setUseRdfType(boolean useRdfType)
-
setExpandContext
public void setExpandContext(String contextLocation)
-
setExpandContext
public void setExpandContext(URI contextUri)
-
setExpandContext
public void setExpandContext(jakarta.json.JsonObject context)
-
setExpandContext
public void setExpandContext(Document context)
-
getEmbed
public JsonLdEmbed getEmbed()
-
setEmbed
public void setEmbed(JsonLdEmbed embed)
-
isExplicit
public boolean isExplicit()
-
setExplicit
public void setExplicit(boolean explicit)
-
isOmitDefault
public boolean isOmitDefault()
-
setOmitDefault
public void setOmitDefault(boolean omitDefault)
-
isOmitGraph
public Boolean isOmitGraph()
-
setOmitGraph
public void setOmitGraph(Boolean omitGraph)
-
isRequiredAll
public boolean isRequiredAll()
-
setRequiredAll
public void setRequiredAll(boolean requiredAll)
-
setNumericId
public void setNumericId(boolean enable)
Experimental: Enables/Disables numeric @id support.- Parameters:
enable- numeric @id support
-
isNumericId
public boolean isNumericId()
Experimental: Numeric @id support state. Disabled by default.- Returns:
trueif numeric @id support is enabled
-
isRdfStar
public boolean isRdfStar()
-
setRdfStar
public void setRdfStar(boolean rdfStar)
Experimental: Enables JSON-LD-STAR extension. Only expansion is supported. Disabled by default.- See Also:
- JSON-LD-STAR Draft
-
isUriValidation
public boolean isUriValidation()
if disabled only URIs required for processing are parsed and validated. Disabling URI validation might improve performance depending on the number of processed URIs.Warning: Disabled validation could cause an invalid output.
Enabled by default.
- Returns:
- true if validation is enabled
-
setUriValidation
public void setUriValidation(boolean enabled)
if disabled only URIs required for processing are parsed and validated. Disabling URI validation might improve performance depending on the number of processed URIs.Warning: Disabled validation could cause an invalid output.
Enabled by default.
- Parameters:
enabled- settrueto enable validation
-
-