Class JSONResource

  • All Implemented Interfaces:
    Resource

    public class JSONResource
    extends java.lang.Object
    implements Resource
    A Resource (that is, an item in a collection) holding JSON content
    • Constructor Detail

      • JSONResource

        public JSONResource​(XPathContext context,
                            AbstractResourceCollection.InputDetails details)
        Create the resource
        Parameters:
        context - XPath dynamic context
        details - the input stream holding the JSON content plus details of encoding etc
    • Method Detail

      • getResourceURI

        public java.lang.String getResourceURI()
        Description copied from interface: Resource
        Get a URI that identifies this resource
        Specified by:
        getResourceURI in interface Resource
        Returns:
        a URI identifying this resource
      • getItem

        public Item getItem()
                     throws XPathException
        Description copied from interface: Resource
        Get an XDM Item holding the contents of this resource.
        Specified by:
        getItem in interface Resource
        Returns:
        an item holding the contents of the resource. The type of item will reflect the type of the resource: a document node for XML resources, a string for text resources, a map or array for JSON resources, a base64Binary value for binary resource. May also return null if the resource cannot be materialized and this is not to be treated as an error.
        Throws:
        XPathException - if a failure occurs materializing the resource, and errors are to be treated as fatal
      • getContentType

        public java.lang.String getContentType()
        Get the media type (MIME type) of the resource if known
        Specified by:
        getContentType in interface Resource
        Returns:
        the string "application/json"