Class FormatXMLAbstractContentHandler<A,​B>

java.lang.Object
com.io7m.coffeepick.runtime.format.xml.FormatXMLAbstractContentHandler<A,​B>
Type Parameters:
A - The type of values returned by child handlers
B - The type of result values
All Implemented Interfaces:
FormatXMLContentHandlerType<B>
Direct Known Subclasses:
FormatXML1BrandingHandler, FormatXML1BuildHandler, FormatXML1HashHandler, FormatXML1RepositoryHandler, FormatXML1RuntimeHandler, FormatXML1RuntimesHandler, FormatXML1TagHandler, FormatXML1TagsHandler, FormatXML1TopLevelHandler

public abstract class FormatXMLAbstractContentHandler<A,​B>
extends java.lang.Object
implements FormatXMLContentHandlerType<B>
An abstract implementation of the content handler interface.
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected FormatXMLAbstractContentHandler​(org.xml.sax.ext.Locator2 in_locator, java.util.Optional<java.lang.String> in_direct)  
  • Method Summary

    Modifier and Type Method Description
    protected void finish​(B r)  
    B get()  
    protected org.xml.sax.ext.Locator2 locator()  
    <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.
    protected abstract void onChildResultReceived​(A value)
    A value was received from a child handler.
    protected abstract java.util.Optional<B> onElementFinishDirectly​(java.lang.String namespace, java.lang.String name, java.lang.String qname)  
    java.util.Optional<B> onElementFinished​(java.lang.String namespace, java.lang.String name, java.lang.String qname)
    An XML element has finished.
    protected abstract void onElementStartDirectly​(java.lang.String namespace, java.lang.String name, java.lang.String qname, org.xml.sax.Attributes attributes)  
    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.
    protected abstract java.util.Map<java.lang.String,​java.util.function.Supplier<FormatXMLContentHandlerType<A>>> onWantChildHandlers()  
    protected abstract java.lang.String onWantHandlerName()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

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

    • FormatXMLAbstractContentHandler

      protected FormatXMLAbstractContentHandler​(org.xml.sax.ext.Locator2 in_locator, java.util.Optional<java.lang.String> in_direct)
  • Method Details

    • map

      public final <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
    • toString

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

      public final 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
    • locator

      protected final org.xml.sax.ext.Locator2 locator()
    • onWantHandlerName

      protected abstract java.lang.String onWantHandlerName()
    • onWantChildHandlers

      protected abstract java.util.Map<java.lang.String,​java.util.function.Supplier<FormatXMLContentHandlerType<A>>> onWantChildHandlers()
    • onElementFinishDirectly

      protected abstract java.util.Optional<B> onElementFinishDirectly​(java.lang.String namespace, java.lang.String name, java.lang.String qname) throws org.xml.sax.SAXException
      Throws:
      org.xml.sax.SAXException
    • onElementStartDirectly

      protected abstract void onElementStartDirectly​(java.lang.String namespace, java.lang.String name, java.lang.String qname, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
      Throws:
      org.xml.sax.SAXException
    • onChildResultReceived

      protected abstract void onChildResultReceived​(A value)
      A value was received from a child handler.
      Parameters:
      value - The result value
    • onElementFinished

      public final 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
    • finish

      protected final void finish​(B r)
    • onCharacters

      public final 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 final B get()
      Specified by:
      get in interface FormatXMLContentHandlerType<A>
      Returns:
      The completed value