Class AbstractXMLRenderer

All Implemented Interfaces:
Constants, Renderer
Direct Known Subclasses:
XMLRenderer

public abstract class AbstractXMLRenderer extends PrintRenderer
Abstract xml renderer base class.
  • Field Details

    • NS

      public static final String NS
      Main namespace in use.
      See Also:
    • CDATA

      public static final String CDATA
      CDATA type
      See Also:
    • EMPTY_ATTS

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

      protected AttributesImpl atts
      AttributesImpl instance that can be used during XML generation.
    • handler

      protected ContentHandler handler
      ContentHandler that the generated XML is written to
    • out

      protected OutputStream out
      The OutputStream to write the generated XML to.
    • context

      protected RendererContext context
      The renderer context.
    • extensionAttachments

      protected List extensionAttachments
      A list of ExtensionAttachements received through processOffDocumentItem()
  • Constructor Details

    • AbstractXMLRenderer

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

    • handleSAXException

      protected void handleSAXException(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(String comment)
      Writes a comment to the generated XML.
      Parameters:
      comment - the comment
    • startElement

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

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

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

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

      protected void addAttribute(String name, 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, 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(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(String name, 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(OutputStream outputStream) throws 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:
      IOException - If an I/O error occurs
    • stopRenderer

      public void stopRenderer() throws 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:
      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(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(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