summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoDefaultElement.java
blob: 942bca1e31a13e2d0c5ab1c50ad418500830f38d (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package org.madore.damlengine;

import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import org.w3c.dom.*;

public class TodoDefaultElement extends TodoElement {

    public static class Factory extends TodoElement.Factory {
	public TodoDefaultElement newItem(Element node,
					  Map<String,Object> context,
					  Map<String,Object> options) {
	    return new TodoDefaultElement(node, context, options);
	}
    }

    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;
	ArrayList<TodoAttr> toProcess = new ArrayList<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;
	ArrayList<TodoElement> toProcess = new ArrayList<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();
    }

}