summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2011-05-01 01:00:00 +0200
committerDavid A. Madore <david+git@madore.org>2011-05-01 01:00:00 +0200
commit29e1d0cef40d41fd262fedd8b023d341b53259f0 (patch)
treeff20a5fbb107002a5765b938fdc7e5433d43d689
parent5ce61e8a007388a7f02cb51c9b2f2b22491a4f67 (diff)
downloaddamlengine-29e1d0cef40d41fd262fedd8b023d341b53259f0.tar.gz
damlengine-29e1d0cef40d41fd262fedd8b023d341b53259f0.tar.bz2
damlengine-29e1d0cef40d41fd262fedd8b023d341b53259f0.zip
(Temporary!) support for <weblog> element.
-rw-r--r--org/madore/damlengine/TodoElement.java1
-rw-r--r--org/madore/damlengine/TodoWeblogElement.java48
2 files changed, 49 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java
index 8db448c..7449ea3 100644
--- a/org/madore/damlengine/TodoElement.java
+++ b/org/madore/damlengine/TodoElement.java
@@ -33,6 +33,7 @@ public abstract class TodoElement extends TodoItem {
damlDefaultFactory = new TodoDefaultElement.Factory();
damlFactories.put("daml", new TodoDamlElement.Factory());
damlFactories.put("body", new TodoBodyElement.Factory());
+ damlFactories.put("weblog", new TodoWeblogElement.Factory());
damlFactories.put("title", new TitleDisambiguationFactory());
damlFactories.put("subtitle", new TodoSubtitleElement.Factory());
damlFactories.put("translation", new TodoTranslationElement.Factory());
diff --git a/org/madore/damlengine/TodoWeblogElement.java b/org/madore/damlengine/TodoWeblogElement.java
new file mode 100644
index 0000000..2b42820
--- /dev/null
+++ b/org/madore/damlengine/TodoWeblogElement.java
@@ -0,0 +1,48 @@
+package org.madore.damlengine;
+
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+import org.w3c.dom.*;
+
+public final class TodoWeblogElement extends TodoDefaultElement {
+
+ public static class Factory extends TodoElement.Factory {
+ @Override
+ public TodoWeblogElement newItem(Element node,
+ Context ctx,
+ TodoItem caller) {
+ return new TodoWeblogElement(node, ctx, caller);
+ }
+ }
+
+ public TodoWeblogElement(Element node,
+ Context ctx,
+ TodoItem caller) {
+ super(node, ctx, caller);
+ }
+
+ @Override
+ public void handleNodeOnly() {
+ Node parent = node.getParentNode();
+ String lang = LangHelper.getLangNorec(node);
+ ArrayList<Node> childList = getChildList(this.node);
+ ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(childList.size()+8);
+ for ( Node child : childList ) {
+ if ( child.getNodeType() == Node.TEXT_NODE
+ || child.getNodeType() == Node.CDATA_SECTION_NODE ) {
+ if ( ! Pattern.matches("^\\s*$",((CharacterData)child).getData()) )
+ throw new IllegalArgumentException("weblog element cannot contain text");
+ }
+ parent.insertBefore(child, node);
+ if ( child.getNodeType() == Node.ELEMENT_NODE ) {
+ if ( lang != null )
+ LangHelper.setLangRec((Element)child, lang); // Dubious
+ TodoElement it
+ = TodoElement.getTodoElement((Element)child, this.ctx, this);
+ toProcess.add(it);
+ }
+ }
+ this.ownerDeque.registerAtStart(toProcess);
+ }
+
+}