diff options
author | David A. Madore <david@procyon.(none)> | 2010-04-15 23:06:03 +0200 |
---|---|---|
committer | David A. Madore <david@procyon.(none)> | 2010-04-15 23:06:03 +0200 |
commit | c18d6e561179a3a96d93a9ae8c6034115ba36923 (patch) | |
tree | d349bbc9f2e53d45e693b15b965812d7b531fe0d /org/madore/damlengine/TodoDefaultElement.java | |
parent | 9176d80ae6dcad88da79714d934b226afe66c1ad (diff) | |
download | damlengine-c18d6e561179a3a96d93a9ae8c6034115ba36923.tar.gz damlengine-c18d6e561179a3a96d93a9ae8c6034115ba36923.tar.bz2 damlengine-c18d6e561179a3a96d93a9ae8c6034115ba36923.zip |
Change dispatching approach: handlers are now part of todoItems.
Instead of dispatching the todo item in function of the DAML node's
local name at todo-handling time, the appropriate todo handler
subclass is now instantiated in the todo deque by dispatching the
creation of the todo item to the appropriate constructor.
Diffstat (limited to 'org/madore/damlengine/TodoDefaultElement.java')
-rw-r--r-- | org/madore/damlengine/TodoDefaultElement.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoDefaultElement.java b/org/madore/damlengine/TodoDefaultElement.java new file mode 100644 index 0000000..3329696 --- /dev/null +++ b/org/madore/damlengine/TodoDefaultElement.java @@ -0,0 +1,49 @@ +package org.madore.damlengine; + +import java.util.Map; +import java.util.HashMap; +import java.util.Vector; +import org.w3c.dom.*; + +public class TodoDefaultElement extends TodoElement { + + public TodoDefaultElement(Element node, + Map<String,Object> context, Map<String,Object> options) { + super(node,context,options); + } + + public void handleAttributes() { + NamedNodeMap attrs = this.node.getAttributes(); + Node attr; + Vector<TodoAttr> toProcess = new Vector<TodoAttr>(); + for ( int i=0 ; (attr=attrs.item(i)) != null ; i++ ) { + TodoAttr it = TodoAttr.getTodoAttr((Attr)attr, this.node, this.context, + new HashMap<String,Object>()); + if ( it != null ) + toProcess.add(it); + } + this.ownerDeque.registerAtStart(toProcess); + } + + public void handleNodeOnly() { + System.err.println("handling a "+this.node.getNodeName()+" element"); + NodeList children = this.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 = TodoElement.getTodoElement((Element)child, this.context, + new HashMap<String,Object>()); + toProcess.add(it); + } + } + this.ownerDeque.registerAtStart(toProcess); + } + + public void handle() { + assert(this.ownerDeque != null); + handleAttributes(); + handleNodeOnly(); + } + +} |