summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoMetaElement.java
blob: 509d56061a9e18736255cadac377143dad4d519a (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
package org.madore.damlengine;

import org.w3c.dom.*;

public final class TodoMetaElement extends TodoDefaultElement {

    public enum Type {
	DESCRIPTION("Description"),
	KEYWORDS("Keywords");
	final String metaName;
	Type(String metaName) {
	    this.metaName = metaName;
	}
    }

    public static class Factory extends TodoElement.Factory {
	final Type t;
	public Factory(Type t) {
	    super();
	    this.t = t;
	}
	@Override
	public TodoMetaElement newItem(Element node,
				       Context ctx,
				       TodoItem caller) {
	    return new TodoMetaElement(t, node, ctx, caller);
	}
    }

    final Type t;

    public TodoMetaElement(Type t,
			   Element node,
			   Context ctx,
			   TodoItem caller) {
	super(node, ctx, caller);
	this.t = t;
    }

    @Override
    public void handleNodeOnly() {
	Element meta = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "meta");
	String lang = LangHelper.getLangNorec(node);
	if ( lang != null )
	    LangHelper.setLangNorec(meta, lang);
	meta.setAttributeNS(null, "name", t.metaName);
	meta.setAttributeNS(null, "content", node.getTextContent());
	node.getParentNode().replaceChild(meta, node);
    }

}