From 59791481739bafd33bae4bd56d90f915471e419a Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Thu, 26 Jul 2012 18:10:20 +0200 Subject: [PATCH] Moved OPML Symbols into separate class --- src/de/danoeh/antennapod/opml/OpmlReader.java | 30 ++++++------------- .../danoeh/antennapod/opml/OpmlSymbols.java | 18 +++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 src/de/danoeh/antennapod/opml/OpmlSymbols.java diff --git a/src/de/danoeh/antennapod/opml/OpmlReader.java b/src/de/danoeh/antennapod/opml/OpmlReader.java index b7673dcb5..55ab74b27 100644 --- a/src/de/danoeh/antennapod/opml/OpmlReader.java +++ b/src/de/danoeh/antennapod/opml/OpmlReader.java @@ -8,25 +8,13 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; -import de.danoeh.antennapod.AppConfig; -import de.danoeh.antennapod.util.URLChecker; - -import android.content.Context; import android.util.Log; +import de.danoeh.antennapod.AppConfig; /** Reads OPML documents. */ public class OpmlReader { private static final String TAG = "OpmlReader"; - - // TAGS - private static final String OPML = "opml"; - private static final String BODY = "body"; - private static final String OUTLINE = "outline"; - private static final String TEXT = "text"; - private static final String XMLURL = "xmlUrl"; - private static final String HTMLURL = "htmlUrl"; - private static final String TYPE = "type"; - + // ATTRIBUTES private boolean isInOpml = false; private boolean isInBody = false; @@ -55,23 +43,23 @@ public class OpmlReader { Log.d(TAG, "Reached beginning of document"); break; case XmlPullParser.START_TAG: - if (xpp.getName().equals(OPML)) { + if (xpp.getName().equals(OpmlSymbols.OPML)) { isInOpml = true; if (AppConfig.DEBUG) Log.d(TAG, "Reached beginning of OPML tree."); - } else if (isInOpml && xpp.getName().equals(BODY)) { + } else if (isInOpml && xpp.getName().equals(OpmlSymbols.BODY)) { isInBody = true; if (AppConfig.DEBUG) Log.d(TAG, "Reached beginning of body tree."); - } else if (isInBody && xpp.getName().equals(OUTLINE)) { + } else if (isInBody && xpp.getName().equals(OpmlSymbols.OUTLINE)) { if (AppConfig.DEBUG) Log.d(TAG, "Found new Opml element"); OpmlElement element = new OpmlElement(); - element.setText(xpp.getAttributeValue(null, TEXT)); - element.setXmlUrl(xpp.getAttributeValue(null, XMLURL)); - element.setHtmlUrl(xpp.getAttributeValue(null, HTMLURL)); - element.setType(xpp.getAttributeValue(null, TYPE)); + 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) { elementList.add(element); } else { diff --git a/src/de/danoeh/antennapod/opml/OpmlSymbols.java b/src/de/danoeh/antennapod/opml/OpmlSymbols.java new file mode 100644 index 000000000..54088f821 --- /dev/null +++ b/src/de/danoeh/antennapod/opml/OpmlSymbols.java @@ -0,0 +1,18 @@ +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"; + + private OpmlSymbols() { + + } + +}