Package no.hasmac.jsonld.document
Class JsonDocument
- java.lang.Object
-
- no.hasmac.jsonld.document.JsonDocument
-
-
Field Summary
Fields Modifier and Type Field Description private MediaTypecontentTypeprivate java.net.URIcontentUrlprivate java.net.URIdocumentUrlprivate static java.lang.StringPLUS_JSONprivate java.lang.Stringprofileprivate jakarta.json.JsonStructurestructure
-
Constructor Summary
Constructors Modifier Constructor Description privateJsonDocument(MediaType type, java.lang.String profile, jakarta.json.JsonStructure structure)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccepts(MediaType contentType)private static voidassertContentType(MediaType contentType)private static JsonDocumentdoParse(MediaType contentType, jakarta.json.stream.JsonParser parser)MediaTypegetContentType()The Content-Type of the loaded document, exclusive of any optional parameters.java.net.URIgetContextUrl()The value of the HTTP Link header when profile attribute matcheshttp://www.w3.org/ns/json-ld#context.java.net.URIgetDocumentUrl()The finalURIof the loaded document.java.util.Optional<jakarta.json.JsonStructure>getJsonContent()Get the document content as parsedJsonStructure.java.util.Optional<java.lang.String>getProfile()The value of anyprofileparameter retrieved as part of the originalDocument.getContentType().static JsonDocumentof(jakarta.json.JsonStructure structure)Create a new document fromJsonStructure.static JsonDocumentof(java.io.InputStream is)Create a new document from content provided byInputStream.static JsonDocumentof(java.io.Reader reader)Create a new document from content provided byReader.static JsonDocumentof(MediaType contentType, jakarta.json.JsonStructure structure)Create a new document fromJsonStructure.static JsonDocumentof(MediaType contentType, java.io.InputStream is)Create a new document from content provided byInputStream.static JsonDocumentof(MediaType contentType, java.io.Reader reader)Create a new document from content provided byReader.voidsetContextUrl(java.net.URI contextUrl)voidsetDocumentUrl(java.net.URI documentUrl)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface no.hasmac.jsonld.document.Document
getRdfContent
-
-
-
-
Field Detail
-
PLUS_JSON
private static final java.lang.String PLUS_JSON
- See Also:
- Constant Field Values
-
contentType
private final MediaType contentType
-
structure
private final jakarta.json.JsonStructure structure
-
profile
private final java.lang.String profile
-
documentUrl
private java.net.URI documentUrl
-
contentUrl
private java.net.URI contentUrl
-
-
Constructor Detail
-
JsonDocument
private JsonDocument(MediaType type, java.lang.String profile, jakarta.json.JsonStructure structure)
-
-
Method Detail
-
of
public static JsonDocument of(jakarta.json.JsonStructure structure)
Create a new document fromJsonStructure. SetsMediaType.JSONas the content type.- Parameters:
structure- representing parsed JSON content- Returns:
Documentrepresenting 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:
Documentrepresenting JSON content
-
of
public static JsonDocument of(java.io.InputStream is) throws JsonLdError
Create a new document from content provided byInputStream. SetsMediaType.JSONas the content type.- Parameters:
is- representing parsed JSON content- Returns:
Documentrepresenting JSON document- Throws:
JsonLdError
-
of
public static JsonDocument of(MediaType contentType, java.io.InputStream is) throws JsonLdError
Create a new document from content provided byInputStream.- Parameters:
contentType- reflecting the providedInputStreamcontent, e.g.MediaType.JSON_LD, any JSON based media type is allowedis- providing JSON content- Returns:
Documentrepresenting JSON document- Throws:
JsonLdError
-
of
public static JsonDocument of(java.io.Reader reader) throws JsonLdError
Create a new document from content provided byReader. SetsMediaType.JSONas the content type.- Parameters:
reader- providing JSON content- Returns:
Documentrepresenting JSON document- Throws:
JsonLdError
-
of
public static JsonDocument of(MediaType contentType, java.io.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:
Documentrepresenting JSON document- Throws:
JsonLdError
-
doParse
private static JsonDocument doParse(MediaType contentType, jakarta.json.stream.JsonParser parser) throws JsonLdError
- Throws:
JsonLdError
-
accepts
public static boolean accepts(MediaType contentType)
-
assertContentType
private static void assertContentType(MediaType contentType)
-
getJsonContent
public java.util.Optional<jakarta.json.JsonStructure> getJsonContent()
Description copied from interface:DocumentGet the document content as parsedJsonStructure.- Specified by:
getJsonContentin interfaceDocument- Returns:
JsonStructureorOptional.empty()if document content is not JSON based
-
getContentType
public MediaType getContentType()
Description copied from interface:DocumentThe Content-Type of the loaded document, exclusive of any optional parameters.- Specified by:
getContentTypein interfaceDocument- Returns:
Content-Typeof the loaded document, nevernull
-
getContextUrl
public java.net.URI getContextUrl()
Description copied from interface:DocumentThe value of the HTTP Link header when profile attribute matcheshttp://www.w3.org/ns/json-ld#context.- Specified by:
getContextUrlin interfaceDocument- Returns:
- attached
URIreferencing document context ornullif not available
-
setContextUrl
public void setContextUrl(java.net.URI contextUrl)
- Specified by:
setContextUrlin interfaceDocument
-
getDocumentUrl
public java.net.URI getDocumentUrl()
Description copied from interface:DocumentThe finalURIof the loaded document.- Specified by:
getDocumentUrlin interfaceDocument- Returns:
URIof the loaded document ornullif not available
-
setDocumentUrl
public void setDocumentUrl(java.net.URI documentUrl)
- Specified by:
setDocumentUrlin interfaceDocument
-
getProfile
public java.util.Optional<java.lang.String> getProfile()
Description copied from interface:DocumentThe value of anyprofileparameter retrieved as part of the originalDocument.getContentType().- Specified by:
getProfilein interfaceDocument- Returns:
- document profile or
Optional.empty()
-
-