All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.ufsc.bridge.mpiclient.responsehandler.XmlTextHandler Maven / Gradle / Ivy

Go to download

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);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy