Merged SyndElement with NSElement

This commit is contained in:
daniel oeh 2012-06-09 11:40:56 +02:00
parent 7f978fde78
commit b19afaa82c
3 changed files with 6 additions and 35 deletions

View File

@ -25,12 +25,8 @@ public abstract class SyndHandler extends DefaultHandler{
Attributes attributes) throws SAXException {
state.tagstack.push(new SyndElement(qName));
String[] parts = qName.split(":");
String prefix = "";
if (parts.length >= 2) {
prefix = parts[0];
}
Namespace handler = state.namespaces.get(prefix);
Namespace handler = state.namespaces.get(uri);
if (handler != null) {
handler.handleElement(localName, state, attributes);
}
@ -48,7 +44,7 @@ public abstract class SyndHandler extends DefaultHandler{
@Override
public void endPrefixMapping(String prefix) throws SAXException {
state.namespaces.remove(prefix);
// TODO remove Namespace
}
@ -59,7 +55,7 @@ public abstract class SyndHandler extends DefaultHandler{
Log.d(TAG, "Found Prefix Mapping with prefix " + prefix + " and uri " + uri);
// Find the right namespace
if (prefix.equals(NSAtom.NSTAG) || uri.equals(NSAtom.NSURI)) {
state.namespaces.put(prefix, new NSAtom());
state.namespaces.put(uri, new NSAtom());
}
}

View File

@ -1,25 +0,0 @@
package de.podfetcher.syndication.namespace;
import org.xml.sax.Attributes;
import de.podfetcher.feed.Feed;
import de.podfetcher.syndication.handler.HandlerState;
/** Defines a XML Element of a specific namespace */
public abstract class NSElement extends SyndElement{
protected Namespace namespace;
public NSElement(String name, Namespace namespace) {
super(name);
this.namespace = namespace;
}
/** Called by its namespace if the processing of the element gets more complex */
public abstract void handleElement(String localName, HandlerState state, Attributes attributes);
@Override
public Namespace getNamespace() {
return namespace;
}
}

View File

@ -3,9 +3,9 @@ package de.podfetcher.syndication.namespace;
/** Defines a XML Element that is pushed on the tagstack */
public class SyndElement {
protected String name;
protected Namespace namespace;
public SyndElement(String name) {
public SyndElement(String name, Namespace namespace) {
super();
this.name = name;
}