From e3b7a9c657a6a5f5a7a8f3c7ee4fdff1aee6410f Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 13 Apr 2010 15:21:41 +0200 Subject: Framework for handling attributes. --- org/madore/damlengine/DefaultHandler.java | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'org/madore/damlengine/DefaultHandler.java') diff --git a/org/madore/damlengine/DefaultHandler.java b/org/madore/damlengine/DefaultHandler.java index 4720f67..ae23a3b 100644 --- a/org/madore/damlengine/DefaultHandler.java +++ b/org/madore/damlengine/DefaultHandler.java @@ -8,19 +8,36 @@ public class DefaultHandler { private DefaultHandler() { } - public static void handle(TodoItem that) { - System.err.println("handling a "+that.node.getNodeName()+" node"); + public static void handleAttributes(TodoElement that) { + NamedNodeMap attrs = that.node.getAttributes(); + Node attr; + Vector toProcess = new Vector(); + for ( int i=0 ; (attr=attrs.item(i)) != null ; i++ ) { + TodoAttr it = new TodoAttr((Attr)attr, that.node, that.context, + new HashMap()); + toProcess.add(it); + } + TodoDeque.registerAtStart(toProcess); + } + + public static void handleNodeOnly(TodoElement that) { + System.err.println("handling a "+that.node.getNodeName()+" element"); NodeList children = that.node.getChildNodes(); Node child; - Vector toProcess = new Vector(); + Vector toProcess = new Vector(); for ( int i=0 ; (child=children.item(i)) != null ; i++ ) { if ( child.getNodeType() == Node.ELEMENT_NODE ) { - TodoItem it = new TodoItem(child, that.context, - new HashMap()); + TodoElement it = new TodoElement((Element)child, that.context, + new HashMap()); toProcess.add(it); } } TodoDeque.registerAtStart(toProcess); } + public static void handle(TodoElement that) { + handleAttributes(that); + handleNodeOnly(that); + } + } -- cgit v1.2.3