diff options
Diffstat (limited to 'org/madore/damlengine/ElementHandler.java')
-rw-r--r-- | org/madore/damlengine/ElementHandler.java | 41 |
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); + } + +} |