summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/ElementHandler.java
diff options
context:
space:
mode:
authorDavid A. Madore <david@procyon.(none)>2010-04-14 20:52:52 +0200
committerDavid A. Madore <david@procyon.(none)>2010-04-14 20:52:52 +0200
commit5c6ccfca16a421860cd57d11e41d94d8a70cda76 (patch)
treee4a8591e48ebaf93d003dc61f1a42bcf66c1033d /org/madore/damlengine/ElementHandler.java
parent7d6eccbd43ba703306328e133c43e0760ceead8c (diff)
downloaddamlengine-5c6ccfca16a421860cd57d11e41d94d8a70cda76.tar.gz
damlengine-5c6ccfca16a421860cd57d11e41d94d8a70cda76.tar.bz2
damlengine-5c6ccfca16a421860cd57d11e41d94d8a70cda76.zip
Make handlers instances instead of using static methods.
Diffstat (limited to 'org/madore/damlengine/ElementHandler.java')
-rw-r--r--org/madore/damlengine/ElementHandler.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/org/madore/damlengine/ElementHandler.java b/org/madore/damlengine/ElementHandler.java
new file mode 100644
index 0000000..4e14756
--- /dev/null
+++ b/org/madore/damlengine/ElementHandler.java
@@ -0,0 +1,41 @@
+package org.madore.damlengine;
+
+import java.util.Vector;
+import java.util.HashMap;
+import org.w3c.dom.*;
+
+public abstract class ElementHandler {
+
+ public void handleAttributes(TodoElement that) {
+ NamedNodeMap attrs = that.node.getAttributes();
+ Node attr;
+ Vector<TodoAttr> toProcess = new Vector<TodoAttr>();
+ for ( int i=0 ; (attr=attrs.item(i)) != null ; i++ ) {
+ TodoAttr it = new TodoAttr((Attr)attr, that.node, that.context,
+ new HashMap<String,Object>());
+ toProcess.add(it);
+ }
+ TodoDeque.registerAtStart(toProcess);
+ }
+
+ public void handleNodeOnly(TodoElement that) {
+ System.err.println("handling a "+that.node.getNodeName()+" element");
+ NodeList children = that.node.getChildNodes();
+ Node child;
+ Vector<TodoElement> toProcess = new Vector<TodoElement>();
+ for ( int i=0 ; (child=children.item(i)) != null ; i++ ) {
+ if ( child.getNodeType() == Node.ELEMENT_NODE ) {
+ TodoElement it = new TodoElement((Element)child, that.context,
+ new HashMap<String,Object>());
+ toProcess.add(it);
+ }
+ }
+ TodoDeque.registerAtStart(toProcess);
+ }
+
+ public void handle(TodoElement that) {
+ handleAttributes(that);
+ handleNodeOnly(that);
+ }
+
+}