Class FormatXMLMappingHandler<A,​B>

  • Type Parameters:
    A - The type of source values
    B - The type of target values
    All Implemented Interfaces:
    FormatXMLContentHandlerType<B>

    public final class FormatXMLMappingHandler<A,​B>
    extends java.lang.Object
    implements FormatXMLContentHandlerType<B>
    A content handler that simply applies a function to the results of another handler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      B get()  
      <C> FormatXMLContentHandlerType<C> map​(java.util.function.Function<B,​C> f)
      Apply f to the results of this content handler.
      void onCharacters​(char[] ch, int start, int length)
      Text was received.
      java.util.Optional<B> onElementFinished​(java.lang.String namespace, java.lang.String name, java.lang.String qname)
      An XML element has finished.
      void onElementStarted​(java.lang.String namespace, java.lang.String name, java.lang.String qname, org.xml.sax.Attributes attributes)
      An XML element has been started.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FormatXMLMappingHandler

        public FormatXMLMappingHandler​(FormatXMLContentHandlerType<A> in_handler,
                                       java.util.function.Function<A,​B> in_function)
        Construct a handler.
        Parameters:
        in_handler - The original handler
        in_function - The mapping function
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • onElementStarted

        public void onElementStarted​(java.lang.String namespace,
                                     java.lang.String name,
                                     java.lang.String qname,
                                     org.xml.sax.Attributes attributes)
                              throws org.xml.sax.SAXException
        Description copied from interface: FormatXMLContentHandlerType
        An XML element has been started.
        Specified by:
        onElementStarted in interface FormatXMLContentHandlerType<A>
        Parameters:
        namespace - The namespace URI
        name - The local element name
        qname - The fully qualified name
        attributes - The attributes
        Throws:
        org.xml.sax.SAXException - On errors
      • onElementFinished

        public java.util.Optional<B> onElementFinished​(java.lang.String namespace,
                                                       java.lang.String name,
                                                       java.lang.String qname)
                                                throws org.xml.sax.SAXException
        Description copied from interface: FormatXMLContentHandlerType
        An XML element has finished.
        Specified by:
        onElementFinished in interface FormatXMLContentHandlerType<A>
        Parameters:
        namespace - The namespace URI
        name - The local element name
        qname - The fully qualified name
        Returns:
        A value of A if the given element finished the content
        Throws:
        org.xml.sax.SAXException - On errors
      • onCharacters

        public void onCharacters​(char[] ch,
                                 int start,
                                 int length)
                          throws org.xml.sax.SAXException
        Description copied from interface: FormatXMLContentHandlerType
        Text was received.
        Specified by:
        onCharacters in interface FormatXMLContentHandlerType<A>
        Parameters:
        ch - The character buffer
        start - The offset of the start of the data in the buffer
        length - The length of the data in the buffer
        Throws:
        org.xml.sax.SAXException - On errors