Package no.hasmac.jsonld.api
Class CompactionApi
- java.lang.Object
-
- no.hasmac.jsonld.api.CompactionApi
-
- All Implemented Interfaces:
CommonApi<CompactionApi>
,LoaderApi<CompactionApi>
public final class CompactionApi extends java.lang.Object implements CommonApi<CompactionApi>, LoaderApi<CompactionApi>
-
-
Field Summary
Fields Modifier and Type Field Description private Document
context
private java.net.URI
contextUri
private Document
document
private java.net.URI
documentUri
private JsonLdOptions
options
-
Constructor Summary
Constructors Constructor Description CompactionApi(java.net.URI documentUri, java.net.URI contextUri)
CompactionApi(java.net.URI documentUri, Document context)
CompactionApi(Document document, java.net.URI contextUri)
CompactionApi(Document document, Document context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompactionApi
base(java.net.URI baseUri)
Set the baseIRI
.CompactionApi
compactArrays()
The processor replaces arrays with just one element.CompactionApi
compactArrays(boolean enable)
If set totrue
, the processor replaces arrays with just one element If set to false, all arrays will remain arrays even if they have just one element.CompactionApi
compactToRelative()
IRIs are compacted relative to thebase(URI)
or document location.CompactionApi
compactToRelative(boolean enable)
Determines if IRIs are compacted relative to thebase(URI)
or document location .jakarta.json.JsonObject
get()
Get the result of compaction.CompactionApi
loader(DocumentLoader loader)
Set the loader to be used to retrieve remote documents and contexts, implementing theDocumentLoader
.CompactionApi
mode(JsonLdVersion processingMode)
SetJSON-LD
processing mode.CompactionApi
options(JsonLdOptions options)
Override an existing settings withJsonLdOptions
.CompactionApi
ordered(boolean enable)
If set totrue
, certain algorithm processing steps are ordered lexicographically.CompactionApi
rdfStar()
Experimental: Enables JSON-LD-STAR extension.
-
-
-
Field Detail
-
document
private final Document document
-
documentUri
private final java.net.URI documentUri
-
context
private final Document context
-
contextUri
private final java.net.URI contextUri
-
options
private JsonLdOptions options
-
-
Method Detail
-
options
public CompactionApi options(JsonLdOptions options)
Description copied from interface:CommonApi
Override an existing settings withJsonLdOptions
.- Specified by:
options
in interfaceCommonApi<CompactionApi>
- Parameters:
options
-JsonLdOptions
- Returns:
- builder instance
-
mode
public CompactionApi mode(JsonLdVersion processingMode)
Description copied from interface:CommonApi
SetJSON-LD
processing mode. JSON-LD 1.1 is set by default.- Specified by:
mode
in interfaceCommonApi<CompactionApi>
- Parameters:
processingMode
- to set- Returns:
- builder instance
-
base
public CompactionApi base(java.net.URI baseUri)
Description copied from interface:CommonApi
Set the baseIRI
. If set, this overrides the input document's IRI.- Specified by:
base
in interfaceCommonApi<CompactionApi>
- Returns:
- builder instance
-
compactArrays
public CompactionApi compactArrays(boolean enable)
If set totrue
, the processor replaces arrays with just one element If set to false, all arrays will remain arrays even if they have just one element.true
by default.- Parameters:
enable
-- Returns:
- builder instance
-
compactArrays
public CompactionApi compactArrays()
The processor replaces arrays with just one element.- Returns:
CompactionApi
instance
-
compactToRelative
public CompactionApi compactToRelative(boolean enable)
Determines if IRIs are compacted relative to thebase(URI)
or document location .true
by default.- Parameters:
enable
-- Returns:
- builder instance
-
compactToRelative
public CompactionApi compactToRelative()
IRIs are compacted relative to thebase(URI)
or document location.- Returns:
- builder instance
-
loader
public CompactionApi loader(DocumentLoader loader)
Description copied from interface:LoaderApi
Set 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.- Specified by:
loader
in interfaceLoaderApi<CompactionApi>
- Returns:
- builder instance
-
ordered
public CompactionApi ordered(boolean enable)
Description copied from interface:CommonApi
If set totrue
, certain algorithm processing steps are ordered lexicographically. Iffalse
, order is not considered in processing.- Specified by:
ordered
in interfaceCommonApi<CompactionApi>
- Returns:
- builder instance
-
rdfStar
public CompactionApi rdfStar()
Experimental: Enables JSON-LD-STAR extension. Disabled by default.- Returns:
- builder instance
- See Also:
- JSON-LD-STAR Draft
-
get
public jakarta.json.JsonObject get() throws JsonLdError
Get the result of compaction.- Returns:
JsonObject
representing compacted document- Throws:
JsonLdError
-
-