summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/opml
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2014-09-17 20:51:45 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2014-09-17 20:51:45 +0200
commit072639b5b22e816df9f78b5cd8a7d4e5379b6aff (patch)
tree341c574bd6eb64497470e7226b3222b0a7c5a824 /src/de/danoeh/antennapod/opml
parent76add8ef68dbc9997e901f4c11c397f581e8eabe (diff)
downloadAntennaPod-072639b5b22e816df9f78b5cd8a7d4e5379b6aff.zip
Changed project structure
Switched from custom layout to standard gradle project structure
Diffstat (limited to 'src/de/danoeh/antennapod/opml')
-rw-r--r--src/de/danoeh/antennapod/opml/OpmlElement.java46
-rw-r--r--src/de/danoeh/antennapod/opml/OpmlReader.java87
-rw-r--r--src/de/danoeh/antennapod/opml/OpmlSymbols.java21
-rw-r--r--src/de/danoeh/antennapod/opml/OpmlWriter.java65
4 files changed, 0 insertions, 219 deletions
diff --git a/src/de/danoeh/antennapod/opml/OpmlElement.java b/src/de/danoeh/antennapod/opml/OpmlElement.java
deleted file mode 100644
index 4cb563c04..000000000
--- a/src/de/danoeh/antennapod/opml/OpmlElement.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package de.danoeh.antennapod.opml;
-
-/** Represents a single feed in an OPML file. */
-public class OpmlElement {
- private String text;
- private String xmlUrl;
- private String htmlUrl;
- private String type;
-
- public OpmlElement() {
-
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public String getXmlUrl() {
- return xmlUrl;
- }
-
- public void setXmlUrl(String xmlUrl) {
- this.xmlUrl = xmlUrl;
- }
-
- public String getHtmlUrl() {
- return htmlUrl;
- }
-
- public void setHtmlUrl(String htmlUrl) {
- this.htmlUrl = htmlUrl;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
-}
diff --git a/src/de/danoeh/antennapod/opml/OpmlReader.java b/src/de/danoeh/antennapod/opml/OpmlReader.java
deleted file mode 100644
index 19a980dee..000000000
--- a/src/de/danoeh/antennapod/opml/OpmlReader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package de.danoeh.antennapod.opml;
-
-import android.util.Log;
-import de.danoeh.antennapod.BuildConfig;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-
-/** Reads OPML documents. */
-public class OpmlReader {
- private static final String TAG = "OpmlReader";
-
- // ATTRIBUTES
- private boolean isInOpml = false;
- private ArrayList<OpmlElement> elementList;
-
- /**
- * Reads an Opml document and returns a list of all OPML elements it can
- * find
- *
- * @throws IOException
- * @throws XmlPullParserException
- */
- public ArrayList<OpmlElement> readDocument(Reader reader)
- throws XmlPullParserException, IOException {
- elementList = new ArrayList<OpmlElement>();
- XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
- factory.setNamespaceAware(true);
- XmlPullParser xpp = factory.newPullParser();
- xpp.setInput(reader);
- int eventType = xpp.getEventType();
-
- while (eventType != XmlPullParser.END_DOCUMENT) {
- switch (eventType) {
- case XmlPullParser.START_DOCUMENT:
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Reached beginning of document");
- break;
- case XmlPullParser.START_TAG:
- if (xpp.getName().equals(OpmlSymbols.OPML)) {
- isInOpml = true;
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Reached beginning of OPML tree.");
- } else if (isInOpml && xpp.getName().equals(OpmlSymbols.OUTLINE)) {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Found new Opml element");
- OpmlElement element = new OpmlElement();
-
- final String title = xpp.getAttributeValue(null, OpmlSymbols.TITLE);
- if (title != null) {
- Log.i(TAG, "Using title: " + title);
- element.setText(title);
- } else {
- Log.i(TAG, "Title not found, using text");
- element.setText(xpp.getAttributeValue(null, OpmlSymbols.TEXT));
- }
- element.setXmlUrl(xpp.getAttributeValue(null, OpmlSymbols.XMLURL));
- element.setHtmlUrl(xpp.getAttributeValue(null, OpmlSymbols.HTMLURL));
- element.setType(xpp.getAttributeValue(null, OpmlSymbols.TYPE));
- if (element.getXmlUrl() != null) {
- if (element.getText() == null) {
- Log.i(TAG, "Opml element has no text attribute.");
- element.setText(element.getXmlUrl());
- }
- elementList.add(element);
- } else {
- if (BuildConfig.DEBUG)
- Log.d(TAG,
- "Skipping element because of missing xml url");
- }
- }
- break;
- }
- eventType = xpp.next();
- }
-
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Parsing finished.");
-
- return elementList;
- }
-
-}
diff --git a/src/de/danoeh/antennapod/opml/OpmlSymbols.java b/src/de/danoeh/antennapod/opml/OpmlSymbols.java
deleted file mode 100644
index 4b0b7316a..000000000
--- a/src/de/danoeh/antennapod/opml/OpmlSymbols.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package de.danoeh.antennapod.opml;
-
-/** Contains symbols for reading and writing OPML documents. */
-public final class OpmlSymbols {
-
- public static final String OPML = "opml";
- public static final String BODY = "body";
- public static final String OUTLINE = "outline";
- public static final String TEXT = "text";
- public static final String XMLURL = "xmlUrl";
- public static final String HTMLURL = "htmlUrl";
- public static final String TYPE = "type";
- public static final String VERSION = "version";
- public static final String HEAD = "head";
- public static final String TITLE = "title";
-
- private OpmlSymbols() {
-
- }
-
-}
diff --git a/src/de/danoeh/antennapod/opml/OpmlWriter.java b/src/de/danoeh/antennapod/opml/OpmlWriter.java
deleted file mode 100644
index 405a5e35a..000000000
--- a/src/de/danoeh/antennapod/opml/OpmlWriter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package de.danoeh.antennapod.opml;
-
-import android.util.Log;
-import android.util.Xml;
-import de.danoeh.antennapod.BuildConfig;
-import de.danoeh.antennapod.feed.Feed;
-import org.xmlpull.v1.XmlSerializer;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-
-/** Writes OPML documents. */
-public class OpmlWriter {
- private static final String TAG = "OpmlWriter";
- private static final String ENCODING = "UTF-8";
- private static final String OPML_VERSION = "2.0";
- private static final String OPML_TITLE = "AntennaPod Subscriptions";
-
- /**
- * Takes a list of feeds and a writer and writes those into an OPML
- * document.
- *
- * @throws IOException
- * @throws IllegalStateException
- * @throws IllegalArgumentException
- */
- public void writeDocument(List<Feed> feeds, Writer writer)
- throws IllegalArgumentException, IllegalStateException, IOException {
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Starting to write document");
- XmlSerializer xs = Xml.newSerializer();
- xs.setOutput(writer);
-
- xs.startDocument(ENCODING, false);
- xs.startTag(null, OpmlSymbols.OPML);
- xs.attribute(null, OpmlSymbols.VERSION, OPML_VERSION);
-
- xs.startTag(null, OpmlSymbols.HEAD);
- xs.startTag(null, OpmlSymbols.TITLE);
- xs.text(OPML_TITLE);
- xs.endTag(null, OpmlSymbols.TITLE);
- xs.endTag(null, OpmlSymbols.HEAD);
-
- xs.startTag(null, OpmlSymbols.BODY);
- for (Feed feed : feeds) {
- xs.startTag(null, OpmlSymbols.OUTLINE);
- xs.attribute(null, OpmlSymbols.TEXT, feed.getTitle());
- xs.attribute(null, OpmlSymbols.TITLE, feed.getTitle());
- if (feed.getType() != null) {
- xs.attribute(null, OpmlSymbols.TYPE, feed.getType());
- }
- xs.attribute(null, OpmlSymbols.XMLURL, feed.getDownload_url());
- if (feed.getLink() != null) {
- xs.attribute(null, OpmlSymbols.HTMLURL, feed.getLink());
- }
- xs.endTag(null, OpmlSymbols.OUTLINE);
- }
- xs.endTag(null, OpmlSymbols.BODY);
- xs.endTag(null, OpmlSymbols.OPML);
- xs.endDocument();
- if (BuildConfig.DEBUG)
- Log.d(TAG, "Finished writing document");
- }
-}