Class XMLDataHandler

java.lang.Object
org.xml.sax.helpers.DefaultHandler
com.nomagic.magicreport.engine.xml.XMLDataHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

@OpenApiAll public class XMLDataHandler extends DefaultHandler
XML Data handler.
Since:
May 23, 2008
  • Field Details

    • writer

      protected Writer writer
      Contains writer for this handler.
  • Constructor Details

    • XMLDataHandler

      public XMLDataHandler(Writer writer)
      Create SAX handler.
      Parameters:
      writer - output writer
  • Method Details

    • write

      protected void write(String string) throws SAXException
      Write a string.
      Parameters:
      string - String to be written
      Throws:
      SAXException - If an I/O error occurs
    • write

      protected void write(StringBuffer buffer) throws SAXException
      Write a StringBuffer.
      Parameters:
      buffer - StringBuffer to be written.
      Throws:
      SAXException - If an I/O error occurs
    • write

      protected void write(StringBuilder buffer) throws SAXException
      Throws:
      SAXException
    • write

      protected void write(char c) throws SAXException
      Write a single character.
      Parameters:
      c - int specifying a character to be written.
      Throws:
      SAXException - If an I/O error occurs
    • write

      protected void write(char[] cbuf, int off, int len) throws SAXException
      Write a portion of an array of characters.
      Parameters:
      cbuf - Array of characters
      off - Offset from which to start writing characters
      len - Number of characters to write
      Throws:
      SAXException - If an I/O error occurs
    • writeText

      protected void writeText(char chr) throws SAXException
      Filter the specified character that are sensitive to XML interpreters and write into the writer.
      Parameters:
      chr - int specifying a character to be written.
      Throws:
      SAXException - If an I/O error occurs
    • writeText

      protected void writeText(char[] cbuf, int off, int len) throws SAXException
      Filter the specified character that are sensitive to XML interpreters and write a portion of an array of characters into the writer.
      Parameters:
      cbuf - Array of characters
      off - Offset from which to start writing characters
      len - Number of characters to write
      Throws:
      SAXException - If an I/O error occurs
    • writeText

      protected void writeText(CharSequence buffer) throws SAXException
      Filter the specified character that are sensitive to XML interpreters and write a StringBuffer into the writer.
      Parameters:
      buffer - StringBuffer
      Throws:
      SAXException - If an I/O error occurs
    • writeAttributes

      protected void writeAttributes(Attributes attributes) throws SAXException
      Write all attributes to writer.
      Parameters:
      attributes - XML attributes
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
    • startDocument

      public void startDocument() throws SAXException
      Receive notification of the beginning of the document.

      By default, write a XML document header.

      Specified by:
      startDocument in interface ContentHandler
      Overrides:
      startDocument in class DefaultHandler
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
    • endDocument

      public void endDocument() throws SAXException
      Receive notification of the end of the document.

      By default, do nothing. Application writers may override this method in a subclass to take specific actions at the end of a document (such as finalizing a tree or closing an output file).

      Specified by:
      endDocument in interface ContentHandler
      Overrides:
      endDocument in class DefaultHandler
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
    • startElement

      public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
      Receive notification of the start of an element.

      By default, write a XML start tag and attributes.

      Specified by:
      startElement in interface ContentHandler
      Overrides:
      startElement in class DefaultHandler
      Parameters:
      uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
      localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
      qName - The qualified name (with prefix), or the empty string if qualified names are not available.
      attributes - The attributes attached to the element. If there are no attributes, it shall be an empty Attributes object.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
    • characters

      public void characters(char[] ch, int start, int length) throws SAXException
      /** Receive notification of character data inside an element.

      By default, write a XML text content

      Specified by:
      characters in interface ContentHandler
      Overrides:
      characters in class DefaultHandler
      Parameters:
      ch - The characters.
      start - The start position in the character array.
      length - The number of characters to use from the character array.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.
    • endElement

      public void endElement(String uri, String localName, String qName) throws SAXException
      Receive notification of the end of an element.

      By default, write a XML end tag

      Specified by:
      endElement in interface ContentHandler
      Overrides:
      endElement in class DefaultHandler
      Parameters:
      uri - The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace processing is not being performed.
      localName - The local name (without prefix), or the empty string if Namespace processing is not being performed.
      qName - The qualified name (with prefix), or the empty string if qualified names are not available.
      Throws:
      SAXException - Any SAX exception, possibly wrapping another exception.