diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2012-06-08 21:20:22 +0200 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2012-06-08 21:20:22 +0200 |
commit | b1dbb0f45e4c4f824ab00acfb7fa4906b85063c9 (patch) | |
tree | 5eeaf661fbdeb27308a8814e5be0429a5a428e49 /src | |
parent | f78755bd1392c28bbad45bbd2a5ad884d97c7bb5 (diff) | |
download | AntennaPod-b1dbb0f45e4c4f824ab00acfb7fa4906b85063c9.zip |
Created SyndHandler and Namespace classes
Diffstat (limited to 'src')
-rw-r--r-- | src/de/podfetcher/service/DownloadService.java | 2 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/handler/FeedHandler.java (renamed from src/de/podfetcher/syndication/FeedHandler.java) | 2 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/handler/HandlerState.java | 30 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/handler/RSSHandler.java (renamed from src/de/podfetcher/syndication/RSSHandler.java) | 2 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/handler/SyndHandler.java | 16 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/handler/TypeGetter.java (renamed from src/de/podfetcher/syndication/TypeGetter.java) | 2 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/namespace/NSElement.java | 11 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/namespace/Namespace.java | 18 | ||||
-rw-r--r-- | src/de/podfetcher/syndication/namespace/atom/NSAtom.java | 38 |
9 files changed, 117 insertions, 4 deletions
diff --git a/src/de/podfetcher/service/DownloadService.java b/src/de/podfetcher/service/DownloadService.java index 261341db9..dbdf8d504 100644 --- a/src/de/podfetcher/service/DownloadService.java +++ b/src/de/podfetcher/service/DownloadService.java @@ -13,7 +13,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import de.podfetcher.feed.*; import de.podfetcher.storage.DownloadRequester; -import de.podfetcher.syndication.FeedHandler; +import de.podfetcher.syndication.handler.FeedHandler; import android.app.Service; import android.app.DownloadManager; import android.content.Intent; diff --git a/src/de/podfetcher/syndication/FeedHandler.java b/src/de/podfetcher/syndication/handler/FeedHandler.java index dc9f660c0..46fe4399c 100644 --- a/src/de/podfetcher/syndication/FeedHandler.java +++ b/src/de/podfetcher/syndication/handler/FeedHandler.java @@ -1,4 +1,4 @@ -package de.podfetcher.syndication; +package de.podfetcher.syndication.handler; import java.io.File; import java.io.IOException; diff --git a/src/de/podfetcher/syndication/handler/HandlerState.java b/src/de/podfetcher/syndication/handler/HandlerState.java new file mode 100644 index 000000000..7e0c07585 --- /dev/null +++ b/src/de/podfetcher/syndication/handler/HandlerState.java @@ -0,0 +1,30 @@ +package de.podfetcher.syndication.handler; + +import java.util.ArrayList; +import java.util.Stack; + +import de.podfetcher.syndication.namespace.Namespace; +import de.podfetcher.feed.Feed; +import de.podfetcher.feed.FeedItem; + +/** Contains all relevant information to describe the current state of a SyndHandler.*/ +public class HandlerState { + /** Feed that the Handler is currently processing. */ + protected Feed feed; + protected FeedItem currentItem; + protected Stack<String> tagstack; + /** Namespaces that have been defined so far. */ + protected ArrayList<Namespace> namespaces; + + public Feed getFeed() { + return feed; + } + public FeedItem getCurrentItem() { + return currentItem; + } + public Stack<String> getTagstack() { + return tagstack; + } + + +} diff --git a/src/de/podfetcher/syndication/RSSHandler.java b/src/de/podfetcher/syndication/handler/RSSHandler.java index cfabd1415..279cfca63 100644 --- a/src/de/podfetcher/syndication/RSSHandler.java +++ b/src/de/podfetcher/syndication/handler/RSSHandler.java @@ -1,4 +1,4 @@ -package de.podfetcher.syndication; +package de.podfetcher.syndication.handler; import java.util.ArrayList; diff --git a/src/de/podfetcher/syndication/handler/SyndHandler.java b/src/de/podfetcher/syndication/handler/SyndHandler.java new file mode 100644 index 000000000..5f20a2b87 --- /dev/null +++ b/src/de/podfetcher/syndication/handler/SyndHandler.java @@ -0,0 +1,16 @@ +package de.podfetcher.syndication.handler; + +import org.xml.sax.helpers.DefaultHandler; + +import de.podfetcher.feed.Feed; +import de.podfetcher.feed.FeedItem; + +/** Superclass for all SAX Handlers which process Syndication formats */ +public abstract class SyndHandler extends DefaultHandler{ + protected HandlerState state; + + public HandlerState getState() { + return state; + } + +} diff --git a/src/de/podfetcher/syndication/TypeGetter.java b/src/de/podfetcher/syndication/handler/TypeGetter.java index b3fd2bb54..9dab56af8 100644 --- a/src/de/podfetcher/syndication/TypeGetter.java +++ b/src/de/podfetcher/syndication/handler/TypeGetter.java @@ -1,4 +1,4 @@ -package de.podfetcher.syndication; +package de.podfetcher.syndication.handler; import java.io.File; import java.io.FileNotFoundException; diff --git a/src/de/podfetcher/syndication/namespace/NSElement.java b/src/de/podfetcher/syndication/namespace/NSElement.java new file mode 100644 index 000000000..6b62def77 --- /dev/null +++ b/src/de/podfetcher/syndication/namespace/NSElement.java @@ -0,0 +1,11 @@ +package de.podfetcher.syndication.namespace; + +import org.xml.sax.Attributes; + +import de.podfetcher.feed.Feed; + +/** Defines a XML Element of a specific namespace */ +public abstract class NSElement { + /** Called by its namespace if the processing of the element gets more complex */ + public abstract void handleElement(String localName, Feed feed, Attributes attributes); +} diff --git a/src/de/podfetcher/syndication/namespace/Namespace.java b/src/de/podfetcher/syndication/namespace/Namespace.java new file mode 100644 index 000000000..152c53652 --- /dev/null +++ b/src/de/podfetcher/syndication/namespace/Namespace.java @@ -0,0 +1,18 @@ +package de.podfetcher.syndication.namespace; + +import org.xml.sax.Attributes; + +import de.podfetcher.feed.Feed; + + +public abstract class Namespace { + + /** Called by a Feedhandler when in startElement and it detects a namespace element */ + public abstract void handleElement(String localName, Feed feed, Attributes attributes); + + /** Called by a Feedhandler when in characters and it detects a namespace element */ + public abstract void handleCharacters(String localName, Feed feed, char ch[], int start, int length); + + public abstract String getNsTag(); + public abstract String getNsURI(); +} diff --git a/src/de/podfetcher/syndication/namespace/atom/NSAtom.java b/src/de/podfetcher/syndication/namespace/atom/NSAtom.java new file mode 100644 index 000000000..c55e9fcd6 --- /dev/null +++ b/src/de/podfetcher/syndication/namespace/atom/NSAtom.java @@ -0,0 +1,38 @@ +package de.podfetcher.syndication.namespace.atom; + +import org.xml.sax.Attributes; + +import de.podfetcher.feed.Feed; +import de.podfetcher.syndication.namespace.Namespace; + +public class NSAtom extends Namespace { + private static final String TITLE = "title"; + private static final String LINK = "link"; + private static final String UPDATED = "updated"; + private static final String AUTHOR = "author"; + + @Override + public void handleElement(String localName, Feed feed, Attributes attributes) { + if (localName.equals(TITLE)) { + + } + + } + + @Override + public void handleCharacters(String localName, Feed feed, char[] ch, + int start, int length) { + + } + + @Override + public String getNsTag() { + return "atom"; + } + + @Override + public String getNsURI() { + return "http://www.w3.org/2005/Atom"; + } + +} |