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
|
package org.madore.damlengine;
import java.util.ArrayList;
import java.util.regex.Pattern;
import org.w3c.dom.*;
public final class TodoEntryTitleElement extends TodoDefaultElement {
public static class Factory extends TodoElement.Factory {
@Override
public TodoEntryTitleElement newItem(Element node,
Context ctx,
TodoItem caller) {
return new TodoEntryTitleElement(node, ctx, caller);
}
}
public TodoEntryTitleElement(Element node,
Context ctx,
TodoItem caller) {
super(node, ctx, caller);
}
@Override
public void handleNodeOnly() {
if ( ctx.ent == null )
throw new IllegalStateException("entry context not defined in entry title element");
Element h2 = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "h2");
String explicitLang = LangHelper.getLangNorec(node);
if ( explicitLang != null )
LangHelper.setLangNorec(h2, explicitLang);
ctx.ent.headerNode.appendChild(h2);
Node ws = node.getNextSibling();
if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE
|| ws.getNodeType() == Node.CDATA_SECTION_NODE )
&& Pattern.matches("^\\s*$",((CharacterData)ws).getData()) )
node.getParentNode().removeChild(ws);
node.getParentNode().removeChild(node);
h2.setAttributeNS(null, "class", "weblog-entry-title entry-title");
ArrayList<Node> childList = getChildList(this.node);
ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(childList.size());
for ( Node child : childList ) {
h2.appendChild(child);
if ( child.getNodeType() == Node.ELEMENT_NODE ) {
TodoElement it
= TodoElement.getTodoElement((Element)child, this.ctx, this);
toProcess.add(it);
}
}
this.ownerDeque.registerAtStart(toProcess);
}
}
|