br.ufsc.bridge.mpiclient.responsehandler.XmlTextHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mpi-client Show documentation
Show all versions of mpi-client Show documentation
Implementação de client para um servidor MPI (Master Patient Index) utilizando mensagens SOAP (PIX/PDQ) baseadas na especificação técnica para integração do
DATASUS.
The newest version!
package br.ufsc.bridge.mpiclient.responsehandler;
import java.io.CharArrayWriter;
import java.util.function.Consumer;
import org.xml.sax.SAXException;
public class XmlTextHandler extends DefaultAttributeHandler {
private CharArrayWriter contents = new CharArrayWriter();
private Consumer textConsumer;
public XmlTextHandler(String tag, Consumer textConsumer) {
super(tag);
this.textConsumer = textConsumer;
}
@Override
public void characters(char[] ch, int start, int length) {
this.contents.write(ch, start, length);
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (this.tag.equals(localName)) {
this.textConsumer.accept(this.contents.toString());
this.contents.reset();
}
super.endElement(uri, localName, qName);
}
}