Moved OPML Symbols into separate class

This commit is contained in:
daniel oeh 2012-07-26 18:10:20 +02:00
parent 9da07b8e72
commit 5979148173
2 changed files with 27 additions and 21 deletions

View File

@ -8,25 +8,13 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory; 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 android.util.Log;
import de.danoeh.antennapod.AppConfig;
/** Reads OPML documents. */ /** Reads OPML documents. */
public class OpmlReader { public class OpmlReader {
private static final String TAG = "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 // ATTRIBUTES
private boolean isInOpml = false; private boolean isInOpml = false;
private boolean isInBody = false; private boolean isInBody = false;
@ -55,23 +43,23 @@ public class OpmlReader {
Log.d(TAG, "Reached beginning of document"); Log.d(TAG, "Reached beginning of document");
break; break;
case XmlPullParser.START_TAG: case XmlPullParser.START_TAG:
if (xpp.getName().equals(OPML)) { if (xpp.getName().equals(OpmlSymbols.OPML)) {
isInOpml = true; isInOpml = true;
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
Log.d(TAG, "Reached beginning of OPML tree."); 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; isInBody = true;
if (AppConfig.DEBUG) if (AppConfig.DEBUG)
Log.d(TAG, "Reached beginning of body tree."); 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) if (AppConfig.DEBUG)
Log.d(TAG, "Found new Opml element"); Log.d(TAG, "Found new Opml element");
OpmlElement element = new OpmlElement(); OpmlElement element = new OpmlElement();
element.setText(xpp.getAttributeValue(null, TEXT)); element.setText(xpp.getAttributeValue(null, OpmlSymbols.TEXT));
element.setXmlUrl(xpp.getAttributeValue(null, XMLURL)); element.setXmlUrl(xpp.getAttributeValue(null, OpmlSymbols.XMLURL));
element.setHtmlUrl(xpp.getAttributeValue(null, HTMLURL)); element.setHtmlUrl(xpp.getAttributeValue(null, OpmlSymbols.HTMLURL));
element.setType(xpp.getAttributeValue(null, TYPE)); element.setType(xpp.getAttributeValue(null, OpmlSymbols.TYPE));
if (element.getXmlUrl() != null) { if (element.getXmlUrl() != null) {
elementList.add(element); elementList.add(element);
} else { } else {

View File

@ -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() {
}
}