Class JsonLdOptions
java.lang.Object
no.hasmac.jsonld.JsonLdOptions
The
JsonLdOptions type is used to pass various options to the processor.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate URIThe base IRI to use when expanding or compacting the document.private booleanIf set to true, the JSON-LD processor replaces arrays with just one element with that element during compaction.private booleanDetermines if IRIs are compacted relative to the base option or document location when compacting.static final booleanstatic final booleanstatic final booleanprivate DocumentLoaderThe callback of the loader to be used to retrieve remote documents and contexts, implementing the LoadDocumentCallback.private JsonLdEmbedprivate booleanprivate DocumentA context that is used to initialize the active context when expanding a document.private booleanprivate booleanprivate booleanprivate booleanprivate Booleanprivate booleanprivate JsonLdVersionprivate booleanprivate JsonLdOptions.RdfDirectionprivate booleanprivate booleanprivate booleanprivate booleanprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetBase()The base IRI to use when expanding or compacting the document.The callback of the loader to be used to retrieve remote documents and contexts, implementing theDocumentLoader.getEmbed()booleanIf set totrue, the processor replaces arrays with just one element with that element during compaction.booleanDetermines if IRIs are compacted relative to thegetBase()option or document location when compacting.booleanIf enabled, warnings are thrown as exceptions and not just logged.booleanbooleanIf 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.booleanExperimental: Numeric @id support state.booleanbooleanIf set totrue, certain algorithm processing steps where indicated are ordered lexicographically.booleanbooleanbooleanbooleanif disabled only URIs required for processing are parsed and validated.booleanbooleanvoidvoidsetCompactArrays(boolean compactArrays) voidsetCompactToRelative(boolean compactToRelative) voidsetContextCache(Cache<String, jakarta.json.JsonValue> contextCache) voidsetDocumentCache(Cache<String, Document> documentCache) voidsetDocumentLoader(DocumentLoader documentLoader) voidsetEmbed(JsonLdEmbed embed) voidsetExceptionOnWarning(boolean exceptionOnWarning) If enabled, warnings are thrown as exceptions and not just logged.voidsetExpandContext(jakarta.json.JsonObject context) voidsetExpandContext(String contextLocation) voidsetExpandContext(URI contextUri) voidsetExpandContext(Document context) 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 Details
-
DEFAULT_RDF_STAR
public static final boolean DEFAULT_RDF_STAR- See Also:
-
DEFAULT_NUMERIC_ID
public static final boolean DEFAULT_NUMERIC_ID- See Also:
-
DEFAULT_URI_VALIDATION
public static final boolean DEFAULT_URI_VALIDATION- See Also:
-
base
The base IRI to use when expanding or compacting the document. If set, this overrides the input document's IRI. -
compactArrays
private boolean compactArraysIf set to true, the JSON-LD 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. -
compactToRelative
private boolean compactToRelativeDetermines if IRIs are compacted relative to the base option or document location when compacting. -
documentLoader
The callback of the loader to be used to retrieve remote documents and contexts, implementing the LoadDocumentCallback. If specified, it is used to retrieve remote documents and contexts; otherwise, if not specified, the processor's built-in loader is used. -
expandContext
A context that is used to initialize the active context when expanding a document. -
extractAllScripts
private boolean extractAllScripts -
ordered
private boolean ordered -
processingMode
-
produceGeneralizedRdf
private boolean produceGeneralizedRdf -
rdfDirection
-
useNativeTypes
private boolean useNativeTypes -
useRdfType
private boolean useRdfType -
embed
-
explicit
private boolean explicit -
omitDefault
private boolean omitDefault -
omitGraph
-
requiredAll
private boolean requiredAll -
rdfStar
private boolean rdfStar -
numericId
private boolean numericId -
contextCache
-
documentCache
-
uriValidation
private boolean uriValidation -
exceptionOnWarning
private boolean exceptionOnWarning
-
-
Constructor Details
-
JsonLdOptions
public JsonLdOptions() -
JsonLdOptions
-
JsonLdOptions
-
-
Method Details
-
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
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
-
isProduceGeneralizedRdf
public boolean isProduceGeneralizedRdf() -
getRdfDirection
-
isUseNativeTypes
public boolean isUseNativeTypes() -
isUseRdfType
public boolean isUseRdfType() -
getExpandContext
-
setBase
-
setCompactArrays
public void setCompactArrays(boolean compactArrays) -
setCompactToRelative
public void setCompactToRelative(boolean compactToRelative) -
setDocumentLoader
-
setExtractAllScripts
public void setExtractAllScripts(boolean extractAllScripts) -
setOrdered
public void setOrdered(boolean ordered) -
setProcessingMode
-
setProduceGeneralizedRdf
public void setProduceGeneralizedRdf(boolean produceGeneralizedRdf) -
setRdfDirection
-
setUseNativeTypes
public void setUseNativeTypes(boolean useNativeTypes) -
setUseRdfType
public void setUseRdfType(boolean useRdfType) -
setExpandContext
-
setExpandContext
-
setExpandContext
public void setExpandContext(jakarta.json.JsonObject context) -
setExpandContext
-
getEmbed
-
setEmbed
-
isExplicit
public boolean isExplicit() -
setExplicit
public void setExplicit(boolean explicit) -
isOmitDefault
public boolean isOmitDefault() -
setOmitDefault
public void setOmitDefault(boolean omitDefault) -
isOmitGraph
-
setOmitGraph
-
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
-
getContextCache
-
setContextCache
-
getDocumentCache
-
setDocumentCache
-
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:
-
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
-
isExceptionOnWarning
public boolean isExceptionOnWarning()If enabled, warnings are thrown as exceptions and not just logged.Disabled by default.
- Returns:
- true if warnings are thrown as exceptions
-
setExceptionOnWarning
public void setExceptionOnWarning(boolean exceptionOnWarning) If enabled, warnings are thrown as exceptions and not just logged.Disabled by default.
- Parameters:
exceptionOnWarning- settrueto throw warnings as exceptions
-