Class NodeContentProducer

  • All Implemented Interfaces:
    ContentProducer

    public abstract class NodeContentProducer
    extends Object
    implements ContentProducer
    A content producer that supports both XML and JSON as content format.

    Clients may subclass this class.

    Since:
    2.0
    • Constructor Detail

      • NodeContentProducer

        public NodeContentProducer()
    • Method Detail

      • getContents

        public InputStream getContents​(Map<?,​?> options)
                                throws IOException,
                                       UnsupportedOperationException
        Returns the underlying content as a stream, either in XML or JSON format.

        The options configures the content to retrieve. Options must include a "Content-Type" property to determine the format of data to retrieve, which is either one of the following: "application/json", "application/xml" or "text/xml".

        Specified by:
        getContents in interface ContentProducer
        Parameters:
        options - properties describing the content to retrieve.
        Returns:
        the underlying content as a stream.
        Throws:
        IOException - if the content cannot be read.
        UnsupportedOperationException - if the "Content-Type" property is missing or is neither one of the following: "application/json", "application/xml" or "text/xml".
      • write

        protected abstract void write​(NodeWriter writer,
                                      Map<?,​?> options)
                               throws IOException
        Implementation must call methods on the specified NodeWriter to build a node tree that is later serialized either as JSON or XML format.
        Parameters:
        writer - the node writer on which nodes creation is requested.
        options - properties describing the content to retrieve.
        Throws:
        IOException - if the nodes cannot be produced.