Package com.io7m.coffeepick.runtime.format.xml

# Class FormatXMLMappingHandler<A,​B>

java.lang.Object
com.io7m.coffeepick.runtime.format.xml.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.

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `FormatXMLMappingHandler​(FormatXMLContentHandlerType<A> in_handler, java.util.function.Function<A,​B> in_function)` | Construct a handler.

- ## Method Summary

  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 Details

  - ### 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 Details

  - ### toString

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

  - ### map

    public <C> FormatXMLContentHandlerType<C> map​(java.util.function.Function<B,​C> f)
    Description copied from interface: `FormatXMLContentHandlerType`
    Apply `f` to the results of this content handler.
    Specified by:
      `map` in interface `FormatXMLContentHandlerType<A>`
    Type Parameters:
      `C` - The type of returned values
    Parameters:
      `f` - The function
    Returns:
      A content handler that produces values of type `B`

  - ### 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

  - ### get

    public B get()
    Specified by:
      `get` in interface `FormatXMLContentHandlerType<A>`
    Returns:
      The completed value