Class XmlSplitter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable
    Direct Known Subclasses:
    XmppXmlSplitter

    public class XmlSplitter
    extends java.io.Writer
    A XML splitter capable of splitting XML into top-level elements.

    Note that this class does not yet support the feature set of XML. Only the required features for XMPP are supported. XML comments and processing instructions are not supported.

    • Constructor Detail

      • XmlSplitter

        public XmlSplitter​(int bufferSize,
                           CompleteElementCallback completeElementCallback,
                           DeclarationCallback declarationCallback,
                           ProcessingInstructionCallback processingInstructionCallback)
        Construct a new XML splitter.
        Parameters:
        bufferSize - the initial size of the buffer.
        completeElementCallback - the callback invoked once a complete element has been processed.
        declarationCallback - a optional callback for the XML declaration.
        processingInstructionCallback - a optional callback for Processing Instructions.
      • XmlSplitter

        public XmlSplitter​(int bufferSize,
                           CompleteElementCallback completeElementCallback,
                           XmlPrinter xmlPrinter)
        Construct a new XML splitter.
        Parameters:
        bufferSize - the initial size of the buffer.
        completeElementCallback - the callback invoked once a complete element has been processed.
        xmlPrinter - an optional XmlPrinter.
      • XmlSplitter

        public XmlSplitter​(int bufferSize,
                           CompleteElementCallback completeElementCallback)
        Construct a new XML splitter.
        Parameters:
        bufferSize - the initial size of the buffer.
        completeElementCallback - the callback invoked once a complete element has been processed.
      • XmlSplitter

        public XmlSplitter​(int bufferSize,
                           CompleteElementCallback completeElementCallback,
                           DeclarationCallback declarationCallback,
                           ProcessingInstructionCallback processingInstructionCallback,
                           XmlPrinter xmlPrinter)
        Construct a new XML splitter.
        Parameters:
        bufferSize - the initial size of the buffer.
        completeElementCallback - the callback invoked once a complete element has been processed.
        declarationCallback - a optional callback for the XML declaration.
        processingInstructionCallback - a optional callback for Processing Instructions.
        xmlPrinter - an optional XmlPrinter.
    • Method Detail

      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
                   throws java.io.IOException
        Specified by:
        write in class java.io.Writer
        Throws:
        java.io.IOException
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer
      • getCurrentSplittedPartSize

        public final int getCurrentSplittedPartSize()
        Get the size in bytes of the splitted part currently being processed.
        Returns:
        the size of the current splitted part in chars.
      • onNextChar

        protected void onNextChar()
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • onStartTag

        protected void onStartTag​(java.lang.String prefix,
                                  java.lang.String localpart,
                                  java.util.Map<java.lang.String,​java.lang.String> attributes)
      • onEndTag

        protected void onEndTag​(java.lang.String qName)
      • newSplittedPart

        protected final void newSplittedPart()