Rename pimstuff -> jpim and move to Maven
[jpim.git] / src / de / j32 / pimstuff / conduit / FritzAddressbookExporter.java
diff --git a/src/de/j32/pimstuff/conduit/FritzAddressbookExporter.java b/src/de/j32/pimstuff/conduit/FritzAddressbookExporter.java
deleted file mode 100644 (file)
index 066585a..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-package de.j32.pimstuff.conduit;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.xml.sax.SAXException;
-
-import de.j32.pimstuff.data.Attribute;
-import de.j32.pimstuff.data.Entry;
-import de.j32.util.SimpleXmlGenerator;
-import de.j32.util.Util;
-
-public class FritzAddressbookExporter implements Exporter
-{
-    OutputStream os_;
-    SimpleXmlGenerator gen_;
-
-    /**
-     * Write Addressbook to Fritzbox XML stream
-     * 
-     * @param os
-     *            OutputStrea to which the XML data is sent.
-     *            <em>After successful</em> construction, the class takes
-     *            responsibility for closing the streanm.
-     */
-    public FritzAddressbookExporter(OutputStream os)
-    {
-        try {
-            os_ = os;
-            gen_ = new SimpleXmlGenerator(os_, "iso-8859-1");
-            gen_.startDocument();
-            gen_.nl();
-            gen_.start("phonebooks");
-            gen_.nl();
-            gen_.start("phonebook");
-            gen_.nl();
-        }
-        catch (SAXException e) {
-            throw new AssertionError("Invalid XML/SAX document generated.");
-        }
-        catch (UnsupportedEncodingException e) {
-            throw new AssertionError("Unsopported encoding iso-8859-1 ??");
-        }
-    }
-
-    @Override
-    public void consume(Entry entry)
-    {
-        try {
-            gen_.start("contact");
-            gen_.nl();
-
-            gen_.start("category");
-            gen_.text("0");
-            gen_.end();
-            gen_.nl();
-
-            gen_.start("person");
-            gen_.nl();
-            gen_.start("realName");
-            gen_.text(entry.name());
-            gen_.end();
-            gen_.nl();
-            gen_.empty("imageURL");
-            gen_.nl();
-            gen_.end();
-            gen_.nl();
-
-            gen_.start("telephony");
-            gen_.nl();
-            for (Attribute number : entry.attributes("phone")) {
-                gen_.start(
-                        "number",
-                        gen_.attribute("prio", number.index > 0 ? "0" : "1")
-                                .attribute("type", number.rel)
-                                .attribute("vanity", ""));
-                gen_.text(number.value);
-                gen_.end();
-                gen_.nl();
-            }
-            gen_.end();
-            gen_.nl();
-
-            Attribute email = Util.first(entry.attributes("email"));
-            if (email != null) {
-                gen_.start("services");
-                gen_.nl();
-                gen_.start("email", gen_.attribute("classifier", "private"));
-                gen_.text(email.value);
-                gen_.end();
-                gen_.nl();
-                gen_.end();
-                gen_.nl();
-            }
-            else {
-                gen_.empty("services");
-                gen_.nl();
-            }
-
-            gen_.end();
-            gen_.nl();
-        }
-        catch (SAXException e) {
-            throw new AssertionError("Invalid XML/SAX document generated.");
-        }
-    }
-
-    @Override
-    public void close() throws IOException
-    {
-        try {
-            gen_.end();
-            gen_.nl();
-            gen_.end();
-            gen_.endDocument();
-            os_.close();
-            os_ = null;
-        }
-        catch (SAXException e) {
-            throw new AssertionError("Invalid XML/SAX document generated.");
-        }
-        finally {
-            Util.nothrowClose(os_);
-        }
-    }
-
-}