Removed redundancy

This commit is contained in:
daniel oeh 2012-06-10 10:54:50 +02:00
parent 6726c92b40
commit 4166e04a3f
1 changed files with 10 additions and 10 deletions

View File

@ -30,10 +30,7 @@ public class SyndHandler extends DefaultHandler {
public void startElement(String uri, String localName, String qName, public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException { Attributes attributes) throws SAXException {
Namespace handler = state.namespaces.get(uri); Namespace handler = getHandlingNamespace(uri);
if (handler == null && uri.equals(DEFAULT_PREFIX) && !state.defaultNamespaces.empty()) {
handler = state.defaultNamespaces.peek();
}
if (handler != null) { if (handler != null) {
handler.handleElementStart(localName, state, attributes); handler.handleElementStart(localName, state, attributes);
state.tagstack.push(new SyndElement(localName, handler)); state.tagstack.push(new SyndElement(localName, handler));
@ -55,10 +52,7 @@ public class SyndHandler extends DefaultHandler {
@Override @Override
public void endElement(String uri, String localName, String qName) public void endElement(String uri, String localName, String qName)
throws SAXException { throws SAXException {
Namespace handler = state.namespaces.get(uri); Namespace handler = getHandlingNamespace(uri);
if (handler == null && uri.equals(DEFAULT_PREFIX) && !state.defaultNamespaces.empty()) {
handler = state.defaultNamespaces.peek();
}
if (handler != null) { if (handler != null) {
handler.handleElementEnd(localName, state); handler.handleElementEnd(localName, state);
state.tagstack.pop(); state.tagstack.pop();
@ -75,8 +69,6 @@ public class SyndHandler extends DefaultHandler {
@Override @Override
public void startPrefixMapping(String prefix, String uri) public void startPrefixMapping(String prefix, String uri)
throws SAXException { throws SAXException {
Log.d(TAG, "Found Prefix Mapping with prefix " + prefix + " and uri "
+ uri);
// Find the right namespace // Find the right namespace
if (uri.equals(NSAtom.NSURI)) { if (uri.equals(NSAtom.NSURI)) {
if (prefix.equals(DEFAULT_PREFIX)) { if (prefix.equals(DEFAULT_PREFIX)) {
@ -86,6 +78,14 @@ public class SyndHandler extends DefaultHandler {
} }
} }
} }
private Namespace getHandlingNamespace(String uri) {
Namespace handler = state.namespaces.get(uri);
if (handler == null && uri.equals(DEFAULT_PREFIX) && !state.defaultNamespaces.empty()) {
handler = state.defaultNamespaces.peek();
}
return handler;
}
public HandlerState getState() { public HandlerState getState() {
return state; return state;