summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoEmailDespammedElement.java
blob: 13dce54e08773031009d1bc3adfcda4893b25235 (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
59
package org.madore.damlengine;

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

public final class TodoEmailDespammedElement extends TodoDefaultElement {

    public static class Factory extends TodoElement.Factory {
	@Override
	public TodoEmailDespammedElement newItem(Element node,
						 Context ctx,
						 TodoItem caller) {
	    return new TodoEmailDespammedElement(node, ctx, caller);
	}
    }

    public TodoEmailDespammedElement(Element node,
				  Context ctx,
				  TodoItem caller) {
	super(node, ctx, caller);
    }

    @Override
    public void handleNodeOnly() {
	Element out0 = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "code");
	Element out;
	if ( node.getAttributeNS(null, "nolink").equals("") ) {
	    out = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a");
	    out.appendChild(out0);
	    out.setAttributeNS(null, "class", "despammed-address");
	} else
	    out = out0;
	String lang = LangHelper.getLangNorec(node);
	if ( lang != null )
	    LangHelper.setLangNorec(out, lang);
	{
	    String classAtt = node.getAttributeNS(null, "class");
	    if ( ! classAtt.equals("") )
		out0.setAttributeNS(null, "class",
				    "despammed-email "+classAtt);
	    else
		out0.setAttributeNS(null, "class", "despammed-email");
	}
	ArrayList<Node> childList = getChildList(node);
	ArrayList<TodoElement> toProcess
	    = new ArrayList<TodoElement>(childList.size()+8);
	for ( Node child : childList ) {
	    out0.appendChild(child);
	    if ( child.getNodeType() == Node.ELEMENT_NODE ) {
		TodoElement it
		    = TodoElement.getTodoElement((Element)child, this.ctx, this);
		toProcess.add(it);
	    }
	}
	node.getParentNode().replaceChild(out, node);
	this.ownerDeque.registerAtStart(toProcess);
    }

}