Class JsonDocument

java.lang.Object
no.hasmac.jsonld.document.JsonDocument
All Implemented Interfaces:
Document

public final class JsonDocument extends Object implements Document
  • Method Details

    • of

      public static JsonDocument of(jakarta.json.JsonStructure structure)
      Create a new document from JsonStructure. Sets MediaType.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 from JsonStructure.
      Parameters:
      contentType - reflecting the provided JsonStructure, e.g. MediaType.JSON_LD, any JSON based media type is allowed
      structure - representing parsed JSON content
      Returns:
      Document representing JSON content
    • of

      public static JsonDocument of(InputStream is) throws JsonLdError
      Create a new document from content provided by InputStream. Sets MediaType.JSON as the content type.
      Parameters:
      is - representing parsed JSON content
      Returns:
      Document representing JSON document
      Throws:
      JsonLdError
    • of

      public static JsonDocument of(MediaType contentType, InputStream is) throws JsonLdError
      Create a new document from content provided by InputStream.
      Parameters:
      contentType - reflecting the provided InputStream content, e.g. MediaType.JSON_LD, any JSON based media type is allowed
      is - providing JSON content
      Returns:
      Document representing JSON document
      Throws:
      JsonLdError
    • of

      public static JsonDocument of(Reader reader) throws JsonLdError
      Create a new document from content provided by Reader. Sets MediaType.JSON as the content type.
      Parameters:
      reader - providing JSON content
      Returns:
      Document representing JSON document
      Throws:
      JsonLdError
    • of

      public static JsonDocument of(MediaType contentType, Reader reader) throws JsonLdError
      Create a new document from content provided by Reader.
      Parameters:
      contentType - reflecting the provided content, e.g. MediaType.JSON_LD, any JSON based media type is allowed
      reader - providing JSON content
      Returns:
      Document representing JSON document
      Throws:
      JsonLdError
    • accepts

      public static boolean accepts(MediaType contentType)
    • getJsonContent

      public Optional<jakarta.json.JsonStructure> getJsonContent()
      Description copied from interface: Document
      Get the document content as parsed JsonStructure.
      Specified by:
      getJsonContent in interface Document
      Returns:
      JsonStructure or Optional.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 interface Document
      Returns:
      Content-Type of the loaded document, never null
    • getContextUrl

      public URI getContextUrl()
      Description copied from interface: Document
      The value of the HTTP Link header when profile attribute matches http://www.w3.org/ns/json-ld#context.
      Specified by:
      getContextUrl in interface Document
      Returns:
      attached URI referencing document context or null if not available
    • setContextUrl

      public void setContextUrl(URI contextUrl)
      Specified by:
      setContextUrl in interface Document
    • getDocumentUrl

      public URI getDocumentUrl()
      Description copied from interface: Document
      The final URI of the loaded document.
      Specified by:
      getDocumentUrl in interface Document
      Returns:
      URI of the loaded document or null if not available
    • setDocumentUrl

      public void setDocumentUrl(URI documentUrl)
      Specified by:
      setDocumentUrl in interface Document
    • getProfile

      public Optional<String> getProfile()
      Description copied from interface: Document
      The value of any profile parameter retrieved as part of the original Document.getContentType().
      Specified by:
      getProfile in interface Document
      Returns:
      document profile or Optional.empty()