blob: ae23a3b6772b923acffe01405dc0c14755b52fdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package org.madore.damlengine;
import java.util.Vector;
import java.util.HashMap;
import org.w3c.dom.*;
public class DefaultHandler {
private DefaultHandler() { }
public static 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 static 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 static void handle(TodoElement that) {
handleAttributes(that);
handleNodeOnly(that);
}
}
|