Class AbstractXMLRenderer

    • Field Detail

      • EMPTY_ATTS

        public static final org.xml.sax.Attributes EMPTY_ATTS
        An empty Attributes object used when no attributes are needed.
      • atts

        protected org.xml.sax.helpers.AttributesImpl atts
        AttributesImpl instance that can be used during XML generation.
      • handler

        protected org.xml.sax.ContentHandler handler
        ContentHandler that the generated XML is written to
      • out

        protected java.io.OutputStream out
        The OutputStream to write the generated XML to.
      • extensionAttachments

        protected java.util.List extensionAttachments
        A list of ExtensionAttachements received through processOffDocumentItem()
    • Constructor Detail

      • AbstractXMLRenderer

        public AbstractXMLRenderer​(FOUserAgent userAgent)
        Parameters:
        userAgent - the user agent that contains configuration details. This cannot be null.
    • Method Detail

      • handleSAXException

        protected void handleSAXException​(org.xml.sax.SAXException saxe)
        Handles SAXExceptions.
        Parameters:
        saxe - the SAXException to handle
      • handlePageExtensionAttachments

        protected void handlePageExtensionAttachments​(PageViewport page)
        Handles page extension attachments
        Parameters:
        page - the page viewport
      • comment

        protected void comment​(java.lang.String comment)
        Writes a comment to the generated XML.
        Parameters:
        comment - the comment
      • startElement

        protected void startElement​(java.lang.String tagName)
        Starts a new element (without attributes).
        Parameters:
        tagName - tag name of the element
      • startElement

        protected void startElement​(java.lang.String tagName,
                                    org.xml.sax.Attributes atts)
        Starts a new element.
        Parameters:
        tagName - tag name of the element
        atts - attributes to add
      • endElement

        protected void endElement​(java.lang.String tagName)
        Ends an element.
        Parameters:
        tagName - tag name of the element
      • characters

        protected void characters​(java.lang.String text)
        Sends plain text to the XML
        Parameters:
        text - the text
      • addAttribute

        protected void addAttribute​(java.lang.String name,
                                    java.lang.String value)
        Adds a new attribute to the protected member variable "atts".
        Parameters:
        name - name of the attribute
        value - value of the attribute
      • addAttribute

        protected void addAttribute​(org.apache.xmlgraphics.util.QName name,
                                    java.lang.String value)
        Adds a new attribute to the protected member variable "atts".
        Parameters:
        name - name of the attribute
        value - value of the attribute
      • addAttribute

        protected void addAttribute​(java.lang.String name,
                                    int value)
        Adds a new attribute to the protected member variable "atts".
        Parameters:
        name - name of the attribute
        value - value of the attribute
      • addAttribute

        protected void addAttribute​(java.lang.String name,
                                    java.awt.geom.Rectangle2D rect)
        Adds a new attribute to the protected member variable "atts".
        Parameters:
        name - name of the attribute
        rect - a Rectangle2D to format and use as attribute value
      • startRenderer

        public void startRenderer​(java.io.OutputStream outputStream)
                           throws java.io.IOException
        Initiates the rendering phase. This must only be called once for a rendering. If stopRenderer is called then this may be called again for a new document rendering.
        Specified by:
        startRenderer in interface Renderer
        Overrides:
        startRenderer in class AbstractRenderer
        Parameters:
        outputStream - The OutputStream to use for output
        Throws:
        java.io.IOException - If an I/O error occurs
      • stopRenderer

        public void stopRenderer()
                          throws java.io.IOException
        Signals the end of the rendering phase. The renderer should reset to an initial state and dispose of any resources for the completed rendering.
        Specified by:
        stopRenderer in interface Renderer
        Overrides:
        stopRenderer in class AbstractRenderer
        Throws:
        java.io.IOException - If an I/O error occurs
      • processOffDocumentItem

        public void processOffDocumentItem​(OffDocumentItem oDI)
        Tells the renderer to process an item not explicitly placed on the document (e.g., PDF bookmarks). Note - not all renderers will process all off-document items.
        Specified by:
        processOffDocumentItem in interface Renderer
        Overrides:
        processOffDocumentItem in class AbstractRenderer
        Parameters:
        oDI - The off-document item to be rendered
      • handleDocumentExtensionAttachments

        protected void handleDocumentExtensionAttachments()
        Handle document extension attachments.
      • setContentHandler

        public void setContentHandler​(org.xml.sax.ContentHandler handler)
        Sets an outside TransformerHandler to use instead of the default one create in this class in startRenderer().
        Parameters:
        handler - Overriding TransformerHandler
      • handleExtensionAttachments

        protected abstract void handleExtensionAttachments​(java.util.List attachments)
        Handles a list of extension attachments
        Parameters:
        attachments - a list of extension attachments
      • renderBookmarkTree

        protected abstract void renderBookmarkTree​(BookmarkData odi)
        Renders a bookmark tree
        Parameters:
        odi - the bookmark data