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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Bget()<C> FormatXMLContentHandlerType<C>map(java.util.function.Function<B,C> f)Applyfto the results of this content handler.voidonCharacters(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.voidonElementStarted(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.StringtoString()
-
-
-
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 handlerin_function- The mapping function
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
map
public <C> FormatXMLContentHandlerType<C> map(java.util.function.Function<B,C> f)
Description copied from interface:FormatXMLContentHandlerTypeApplyfto the results of this content handler.- Specified by:
mapin 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:FormatXMLContentHandlerTypeAn XML element has been started.- Specified by:
onElementStartedin 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.SAXException
Description copied from interface:FormatXMLContentHandlerTypeAn XML element has finished.- Specified by:
onElementFinishedin interfaceFormatXMLContentHandlerType<A>- Parameters:
namespace- The namespace URIname- The local element nameqname- The fully qualified name- Returns:
- A value of
Aif 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:FormatXMLContentHandlerTypeText was received.- Specified by:
onCharactersin 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
public B get()
- Specified by:
getin interfaceFormatXMLContentHandlerType<A>- Returns:
- The completed value
-
-