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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package org.madore.damlengine;
import java.util.ArrayList;
import org.w3c.dom.*;
public class TodoDefaultElement extends TodoElement {
public static class Factory extends TodoElement.Factory {
@Override
public TodoDefaultElement newItem(Element node,
Context ctx,
TodoItem caller) {
return new TodoDefaultElement(node, ctx, caller);
}
}
public TodoDefaultElement(Element node,
Context ctx,
TodoItem caller) {
super(node, ctx, caller);
}
public static ArrayList<Attr> getAttrList(Element node) {
NamedNodeMap attrs = node.getAttributes();
ArrayList<Attr> attrList = new ArrayList<Attr>(attrs.getLength());
Node attr;
for ( int i=0 ; (attr=attrs.item(i)) != null ; i++ )
attrList.add((Attr)attr);
return attrList;
}
public static ArrayList<Node> getChildList(Element node) {
NodeList children = node.getChildNodes();
ArrayList<Node> childList = new ArrayList<Node>(children.getLength());
Node child;
for ( int i=0 ; (child=children.item(i)) != null ; i++ )
childList.add(child);
return childList;
}
public void handleAttributes() {
ArrayList<Attr> attrList = getAttrList(this.node);
ArrayList<TodoAttr> toProcess = new ArrayList<TodoAttr>(attrList.size());
for ( Attr attr : attrList ) {
TodoAttr it
= TodoAttr.getTodoAttr(attr, this.node, this.ctx, this);
if ( it != null )
toProcess.add(it);
}
this.ownerDeque.registerAtStart(toProcess);
}
public void handleNodeOnly() {
ArrayList<Node> childList = getChildList(this.node);
ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(childList.size());
for ( Node child : childList ) {
if ( child.getNodeType() == Node.ELEMENT_NODE ) {
TodoElement it
= TodoElement.getTodoElement((Element)child, this.ctx, this);
toProcess.add(it);
}
}
this.ownerDeque.registerAtStart(toProcess);
}
@Override
public void handle() {
assert(this.ownerDeque != null);
handleAttributes();
handleNodeOnly();
}
}
|