Package no.hasmac.jsonld
Class JsonLdOptions
- java.lang.Object
-
- no.hasmac.jsonld.JsonLdOptions
-
public final class JsonLdOptions extends java.lang.Object
TheJsonLdOptions
type 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 class
JsonLdOptions.RdfDirection
-
Field Summary
Fields Modifier and Type Field Description private java.net.URI
base
The base IRI to use when expanding or compacting the document.private boolean
compactArrays
If set to true, the JSON-LD processor replaces arrays with just one element with that element during compaction.private boolean
compactToRelative
Determines if IRIs are compacted relative to the base option or document location when compacting.private Cache<java.lang.String,jakarta.json.JsonValue>
contextCache
static boolean
DEFAULT_NUMERIC_ID
static boolean
DEFAULT_RDF_STAR
static boolean
DEFAULT_URI_VALIDATION
private Cache<java.lang.String,Document>
documentCache
private DocumentLoader
documentLoader
The callback of the loader to be used to retrieve remote documents and contexts, implementing the LoadDocumentCallback.private JsonLdEmbed
embed
private boolean
exceptionOnWarning
private Document
expandContext
A context that is used to initialize the active context when expanding a document.private boolean
explicit
private boolean
extractAllScripts
private boolean
numericId
private boolean
omitDefault
private java.lang.Boolean
omitGraph
private boolean
ordered
private JsonLdVersion
processingMode
private boolean
produceGeneralizedRdf
private JsonLdOptions.RdfDirection
rdfDirection
private boolean
rdfStar
private boolean
requiredAll
private boolean
uriValidation
private boolean
useNativeTypes
private boolean
useRdfType
-
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 java.net.URI
getBase()
The base IRI to use when expanding or compacting the document.Cache<java.lang.String,jakarta.json.JsonValue>
getContextCache()
Cache<java.lang.String,Document>
getDocumentCache()
DocumentLoader
getDocumentLoader()
The callback of the loader to be used to retrieve remote documents and contexts, implementing theDocumentLoader
.JsonLdEmbed
getEmbed()
Document
getExpandContext()
JsonLdVersion
getProcessingMode()
JsonLdOptions.RdfDirection
getRdfDirection()
boolean
isCompactArrays()
If set totrue
, the processor replaces arrays with just one element with that element during compaction.boolean
isCompactToRelative()
Determines if IRIs are compacted relative to thegetBase()
option or document location when compacting.boolean
isExceptionOnWarning()
If enabled, warnings are thrown as exceptions and not just logged.boolean
isExplicit()
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.boolean
isNumericId()
Experimental: Numeric @id support state.boolean
isOmitDefault()
java.lang.Boolean
isOmitGraph()
boolean
isOrdered()
If set totrue
, certain algorithm processing steps where indicated are ordered lexicographically.boolean
isProduceGeneralizedRdf()
boolean
isRdfStar()
boolean
isRequiredAll()
boolean
isUriValidation()
if disabled only URIs required for processing are parsed and validated.boolean
isUseNativeTypes()
boolean
isUseRdfType()
void
setBase(java.net.URI baseUri)
void
setCompactArrays(boolean compactArrays)
void
setCompactToRelative(boolean compactToRelative)
void
setContextCache(Cache<java.lang.String,jakarta.json.JsonValue> contextCache)
void
setDocumentCache(Cache<java.lang.String,Document> documentCache)
void
setDocumentLoader(DocumentLoader documentLoader)
void
setEmbed(JsonLdEmbed embed)
void
setExceptionOnWarning(boolean exceptionOnWarning)
If enabled, warnings are thrown as exceptions and not just logged.void
setExpandContext(jakarta.json.JsonObject context)
void
setExpandContext(java.lang.String contextLocation)
void
setExpandContext(java.net.URI contextUri)
void
setExpandContext(Document context)
void
setExplicit(boolean explicit)
void
setExtractAllScripts(boolean extractAllScripts)
void
setNumericId(boolean enable)
Experimental: Enables/Disables numeric @id support.void
setOmitDefault(boolean omitDefault)
void
setOmitGraph(java.lang.Boolean omitGraph)
void
setOrdered(boolean ordered)
void
setProcessingMode(JsonLdVersion processingMode)
void
setProduceGeneralizedRdf(boolean produceGeneralizedRdf)
void
setRdfDirection(JsonLdOptions.RdfDirection rdfDirection)
void
setRdfStar(boolean rdfStar)
Experimental: Enables JSON-LD-STAR extension.void
setRequiredAll(boolean requiredAll)
void
setUriValidation(boolean enabled)
if disabled only URIs required for processing are parsed and validated.void
setUseNativeTypes(boolean useNativeTypes)
void
setUseRdfType(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
-
base
private java.net.URI base
The base IRI to use when expanding or compacting the document. If set, this overrides the input document's IRI.
-
compactArrays
private boolean compactArrays
If 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 compactToRelative
Determines if IRIs are compacted relative to the base option or document location when compacting.
-
documentLoader
private DocumentLoader 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
private Document expandContext
A context that is used to initialize the active context when expanding a document.
-
extractAllScripts
private boolean extractAllScripts
-
ordered
private boolean ordered
-
processingMode
private JsonLdVersion processingMode
-
produceGeneralizedRdf
private boolean produceGeneralizedRdf
-
rdfDirection
private JsonLdOptions.RdfDirection rdfDirection
-
useNativeTypes
private boolean useNativeTypes
-
useRdfType
private boolean useRdfType
-
embed
private JsonLdEmbed embed
-
explicit
private boolean explicit
-
omitDefault
private boolean omitDefault
-
omitGraph
private java.lang.Boolean omitGraph
-
requiredAll
private boolean requiredAll
-
rdfStar
private boolean rdfStar
-
numericId
private boolean numericId
-
contextCache
private Cache<java.lang.String,jakarta.json.JsonValue> contextCache
-
uriValidation
private boolean uriValidation
-
exceptionOnWarning
private boolean exceptionOnWarning
-
-
Constructor Detail
-
JsonLdOptions
public JsonLdOptions()
-
JsonLdOptions
public JsonLdOptions(DocumentLoader loader)
-
JsonLdOptions
public JsonLdOptions(JsonLdOptions options)
-
-
Method Detail
-
getBase
public java.net.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:
true
if array compaction is enabled
-
isCompactToRelative
public boolean isCompactToRelative()
Determines if IRIs are compacted relative to thegetBase()
option or document location when compacting.- Returns:
true
if 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
null
is 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:
true
if 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:
true
if 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(java.net.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(java.lang.String contextLocation)
-
setExpandContext
public void setExpandContext(java.net.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 java.lang.Boolean isOmitGraph()
-
setOmitGraph
public void setOmitGraph(java.lang.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:
true
if numeric @id support is enabled
-
getContextCache
public Cache<java.lang.String,jakarta.json.JsonValue> getContextCache()
-
setContextCache
public void setContextCache(Cache<java.lang.String,jakarta.json.JsonValue> contextCache)
-
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
- settrue
to 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
- settrue
to throw warnings as exceptions
-
-