From c18d6e561179a3a96d93a9ae8c6034115ba36923 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Thu, 15 Apr 2010 23:06:03 +0200 Subject: 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. --- org/madore/damlengine/TodoDefaultElement.java | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 org/madore/damlengine/TodoDefaultElement.java (limited to 'org/madore/damlengine/TodoDefaultElement.java') 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 context, Map options) { + super(node,context,options); + } + + public void handleAttributes() { + NamedNodeMap attrs = this.node.getAttributes(); + Node attr; + Vector toProcess = new Vector(); + for ( int i=0 ; (attr=attrs.item(i)) != null ; i++ ) { + TodoAttr it = TodoAttr.getTodoAttr((Attr)attr, this.node, this.context, + new HashMap()); + 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 toProcess = new Vector(); + 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()); + toProcess.add(it); + } + } + this.ownerDeque.registerAtStart(toProcess); + } + + public void handle() { + assert(this.ownerDeque != null); + handleAttributes(); + handleNodeOnly(); + } + +} -- cgit v1.2.3