Class FormatXMLMappingHandler<A,B>
java.lang.Object
com.io7m.coffeepick.runtime.format.xml.FormatXMLMappingHandler<A,B>
- Type Parameters:
A
- The type of source valuesB
- 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)
Applyf
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()
-
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 handlerin_function
- The mapping function
-
-
Method Details
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
map
Description copied from interface:FormatXMLContentHandlerType
Applyf
to the results of this content handler.- Specified by:
map
in interfaceFormatXMLContentHandlerType<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.SAXExceptionDescription copied from interface:FormatXMLContentHandlerType
An XML element has been started.- Specified by:
onElementStarted
in interfaceFormatXMLContentHandlerType<A>
- Parameters:
namespace
- The namespace URIname
- The local element nameqname
- The fully qualified nameattributes
- 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.SAXExceptionDescription copied from interface:FormatXMLContentHandlerType
An XML element has finished.- Specified by:
onElementFinished
in interfaceFormatXMLContentHandlerType<A>
- Parameters:
namespace
- The namespace URIname
- The local element nameqname
- 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.SAXExceptionDescription copied from interface:FormatXMLContentHandlerType
Text was received.- Specified by:
onCharacters
in interfaceFormatXMLContentHandlerType<A>
- Parameters:
ch
- The character bufferstart
- The offset of the start of the data in the bufferlength
- The length of the data in the buffer- Throws:
org.xml.sax.SAXException
- On errors
-
get
- Specified by:
get
in interfaceFormatXMLContentHandlerType<A>
- Returns:
- The completed value
-