1 package de.j32.pimstuff.conduit;
3 import java.io.IOException;
4 import java.io.InputStream;
6 import org.w3c.dom.Document;
7 import org.w3c.dom.Element;
8 import org.xml.sax.SAXException;
10 import de.j32.pimstuff.data.Entry;
11 import de.j32.pimstuff.data.EntryConsumer;
12 import de.j32.util.XmlUtil;
14 public class FritzAddressbookImporter
19 public FritzAddressbookImporter(InputStream is)
20 throws SAXException, IOException
22 xml_ = XmlUtil.parse(is);
26 public void sendTo(EntryConsumer consumer)
28 for (Element node : XmlUtil.iterateElements(xml_.getElementsByTagName("contact"))) {
30 * category (unused, always 0)
33 * telephony/number (@prio, @type, @vanity)
37 Entry entry = new Entry();
40 entry.name(node.getElementsByTagName("realName").item(0).getTextContent());
42 for (Element phone : XmlUtil.iterateElements(node.getElementsByTagName("number"))) {
43 entry.attribute("phone", phone.getAttribute("type"), phone.getTextContent());
47 entry.attribute("email", "",
48 node.getElementsByTagName("email").item(0).getTextContent());
50 catch (NullPointerException e) {} // ignore missing optional email
52 catch (NullPointerException e) {
53 // Ignore incomplete entries
58 consumer.consume(entry);