Package com.apicatalog.jsonld.document
Class JsonDocument
- java.lang.Object
-
- com.apicatalog.jsonld.document.JsonDocument
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
accepts(MediaType contentType)
MediaType
getContentType()
The Content-Type of the loaded document, exclusive of any optional parameters.URI
getContextUrl()
The value of the HTTP Link header when profile attribute matcheshttp://www.w3.org/ns/json-ld#context
.URI
getDocumentUrl()
The finalURI
of the loaded document.Optional<jakarta.json.JsonStructure>
getJsonContent()
Get the document content as parsedJsonStructure
.Optional<String>
getProfile()
The value of anyprofile
parameter retrieved as part of the originalDocument.getContentType()
.static JsonDocument
of(MediaType contentType, jakarta.json.JsonStructure structure)
Create a new document fromJsonStructure
.static JsonDocument
of(MediaType contentType, InputStream is)
Create a new document from content provided byInputStream
.static JsonDocument
of(MediaType contentType, Reader reader)
Create a new document from content provided byReader
.static JsonDocument
of(jakarta.json.JsonStructure structure)
Create a new document fromJsonStructure
.static JsonDocument
of(InputStream is)
Create a new document from content provided byInputStream
.static JsonDocument
of(Reader reader)
Create a new document from content provided byReader
.void
setContextUrl(URI contextUrl)
void
setDocumentUrl(URI documentUrl)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.apicatalog.jsonld.document.Document
getRdfContent
-
-
-
-
Method Detail
-
of
public static JsonDocument of(jakarta.json.JsonStructure structure)
Create a new document fromJsonStructure
. SetsMediaType.JSON
as the content type.- Parameters:
structure
- representing parsed JSON content- Returns:
Document
representing JSON content
-
of
public static JsonDocument of(MediaType contentType, jakarta.json.JsonStructure structure)
Create a new document fromJsonStructure
.- Parameters:
contentType
- reflecting the providedJsonStructure
, e.g.MediaType.JSON_LD
, any JSON based media type is allowedstructure
- representing parsed JSON content- Returns:
Document
representing JSON content
-
of
public static final JsonDocument of(InputStream is) throws JsonLdError
Create a new document from content provided byInputStream
. SetsMediaType.JSON
as the content type.- Parameters:
is
- representing parsed JSON content- Returns:
Document
representing JSON document- Throws:
JsonLdError
-
of
public static final JsonDocument of(MediaType contentType, InputStream is) throws JsonLdError
Create a new document from content provided byInputStream
.- Parameters:
contentType
- reflecting the providedInputStream
content, e.g.MediaType.JSON_LD
, any JSON based media type is allowedis
- providing JSON content- Returns:
Document
representing JSON document- Throws:
JsonLdError
-
of
public static final JsonDocument of(Reader reader) throws JsonLdError
Create a new document from content provided byReader
. SetsMediaType.JSON
as the content type.- Parameters:
reader
- providing JSON content- Returns:
Document
representing JSON document- Throws:
JsonLdError
-
of
public static final JsonDocument of(MediaType contentType, Reader reader) throws JsonLdError
Create a new document from content provided byReader
.- Parameters:
contentType
- reflecting the provided content, e.g.MediaType.JSON_LD
, any JSON based media type is allowedreader
- providing JSON content- Returns:
Document
representing JSON document- Throws:
JsonLdError
-
accepts
public static final boolean accepts(MediaType contentType)
-
getJsonContent
public Optional<jakarta.json.JsonStructure> getJsonContent()
Description copied from interface:Document
Get the document content as parsedJsonStructure
.- Specified by:
getJsonContent
in interfaceDocument
- Returns:
JsonStructure
orOptional.empty()
if document content is not JSON based
-
getContentType
public MediaType getContentType()
Description copied from interface:Document
The Content-Type of the loaded document, exclusive of any optional parameters.- Specified by:
getContentType
in interfaceDocument
- Returns:
Content-Type
of the loaded document, nevernull
-
getContextUrl
public URI getContextUrl()
Description copied from interface:Document
The value of the HTTP Link header when profile attribute matcheshttp://www.w3.org/ns/json-ld#context
.- Specified by:
getContextUrl
in interfaceDocument
- Returns:
- attached
URI
referencing document context ornull
if not available
-
setContextUrl
public void setContextUrl(URI contextUrl)
- Specified by:
setContextUrl
in interfaceDocument
-
getDocumentUrl
public URI getDocumentUrl()
Description copied from interface:Document
The finalURI
of the loaded document.- Specified by:
getDocumentUrl
in interfaceDocument
- Returns:
URI
of the loaded document ornull
if not available
-
setDocumentUrl
public void setDocumentUrl(URI documentUrl)
- Specified by:
setDocumentUrl
in interfaceDocument
-
getProfile
public Optional<String> getProfile()
Description copied from interface:Document
The value of anyprofile
parameter retrieved as part of the originalDocument.getContentType()
.- Specified by:
getProfile
in interfaceDocument
- Returns:
- document profile or
Optional.empty()
-
-