summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2010-04-19 09:48:21 +0200
committerDavid A. Madore <david+git@madore.org>2010-04-19 09:48:21 +0200
commit8b2d4cc55eba7b1431a861beaf8181d0052b76bf (patch)
tree703e75860625d5c47137459d7e704eb1be368a13
parentc8808d230a8c4f938b6adb54eb250299a092d87c (diff)
downloaddamlengine-8b2d4cc55eba7b1431a861beaf8181d0052b76bf.tar.gz
damlengine-8b2d4cc55eba7b1431a861beaf8181d0052b76bf.tar.bz2
damlengine-8b2d4cc55eba7b1431a861beaf8181d0052b76bf.zip
Rather than an ad hoc "Options" class, use caller todo directly.
-rw-r--r--org/madore/damlengine/DamlEngine.java16
-rw-r--r--org/madore/damlengine/TodoAttr.java10
-rw-r--r--org/madore/damlengine/TodoBodyElement.java22
-rw-r--r--org/madore/damlengine/TodoDamlElement.java20
-rw-r--r--org/madore/damlengine/TodoDefaultElement.java14
-rw-r--r--org/madore/damlengine/TodoElement.java10
-rw-r--r--org/madore/damlengine/TodoItem.java9
-rw-r--r--org/madore/damlengine/TodoStyleOrScript.java4
-rw-r--r--org/madore/damlengine/TodoXemptyAttr.java8
9 files changed, 53 insertions, 60 deletions
diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java
index 36dd3c4..c9bd477 100644
--- a/org/madore/damlengine/DamlEngine.java
+++ b/org/madore/damlengine/DamlEngine.java
@@ -15,16 +15,22 @@ public final class DamlEngine {
private DamlEngine() { } // Forbid instantiation
- public static class RootOptions extends TodoItem.Options {
+ public static class RootTodo extends TodoItem {
+ public RootTodo(Context ctx) {
+ super(ctx, null);
+ }
+ public void handle() {
+ TodoItem it
+ = TodoElement.getTodoElement(ctx.doc.getDocumentElement(),
+ ctx, this);
+ this.ownerDeque.registerAtEnd(it);
+ }
}
public static void processDocument(Document doc) {
TodoDeque todoDeque = new TodoDeque();
Context ctx = new Context(doc);
- TodoItem.Options options = new RootOptions();
- todoDeque.
- registerAtEnd(TodoElement.getTodoElement(doc.getDocumentElement(),
- ctx, options));
+ todoDeque.registerAtEnd(new RootTodo(ctx));
todoDeque.dispatchLoop();
}
diff --git a/org/madore/damlengine/TodoAttr.java b/org/madore/damlengine/TodoAttr.java
index f9e2e70..2e4cfb8 100644
--- a/org/madore/damlengine/TodoAttr.java
+++ b/org/madore/damlengine/TodoAttr.java
@@ -10,7 +10,7 @@ public abstract class TodoAttr extends TodoItem {
public static abstract class Factory {
public abstract TodoAttr newItem(Attr attr, Element owner,
Context ctx,
- TodoItem.Options options);
+ TodoItem caller);
}
protected static Map<String,Factory> damlAttrFactories;
@@ -24,22 +24,22 @@ public abstract class TodoAttr extends TodoItem {
Element owner;
public TodoAttr(Attr attr, Element owner,
- Context ctx, TodoItem.Options options) {
- super(ctx, options);
+ Context ctx, TodoItem caller) {
+ super(ctx, caller);
this.attr = attr;
this.owner = owner;
}
public static TodoAttr getTodoAttr(Attr attr, Element owner,
Context ctx,
- TodoItem.Options options) {
+ TodoItem caller) {
Factory factory = null;
String nsuri = attr.getNamespaceURI();
if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) )
factory = damlAttrFactories.get(attr.getLocalName());
if ( factory == null )
return null;
- return factory.newItem(attr, owner, ctx, options);
+ return factory.newItem(attr, owner, ctx, caller);
}
}
diff --git a/org/madore/damlengine/TodoBodyElement.java b/org/madore/damlengine/TodoBodyElement.java
index c5cc6c8..2ee2286 100644
--- a/org/madore/damlengine/TodoBodyElement.java
+++ b/org/madore/damlengine/TodoBodyElement.java
@@ -9,19 +9,19 @@ public class TodoBodyElement extends TodoDefaultElement {
public static class Factory extends TodoElement.Factory {
public TodoBodyElement newItem(Element node,
Context ctx,
- TodoItem.Options options) {
- return new TodoBodyElement(node, ctx, options);
+ TodoItem caller) {
+ return new TodoBodyElement(node, ctx, caller);
}
}
public TodoBodyElement(Element node,
Context ctx,
- TodoItem.Options options) {
- super(node, ctx, options);
+ TodoItem caller) {
+ super(node, ctx, caller);
}
public void handleNodeOnly() {
- if ( ! ( options instanceof TodoDamlElement.DamlOptions ) )
+ if ( ! ( caller instanceof TodoDamlElement ) )
throw new IllegalArgumentException("body node can only be child of daml node");
Element bodyNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "body");
@@ -38,16 +38,14 @@ public class TodoBodyElement extends TodoDefaultElement {
"d:implicit-do-navbar");
bodyNode.appendChild(ctx.doc.createTextNode("\n"));
bodyNode.appendChild(token);
- // toProcess.add(new TodoNavbar(token, this.ctx,
- // new TodoItem.Options()));
+ // toProcess.add(new TodoNavbar(token, this.ctx, this));
}
if ( node.getAttributeNS(null, "notranslations").equals("") ) {
Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS,
"d:implicit-do-translations");
bodyNode.appendChild(ctx.doc.createTextNode("\n"));
bodyNode.appendChild(token);
- // toProcess.add(new TodoTranslations(token, this.ctx,
- // new TodoItem.Options()));
+ // toProcess.add(new TodoTranslations(token, this.ctx, this));
}
for ( Node child : childList ) {
if ( child.getNodeType() == Node.TEXT_NODE
@@ -58,8 +56,7 @@ public class TodoBodyElement extends TodoDefaultElement {
bodyNode.appendChild(child);
if ( child.getNodeType() == Node.ELEMENT_NODE ) {
TodoElement it
- = TodoElement.getTodoElement((Element)child, this.ctx,
- new TodoItem.Options());
+ = TodoElement.getTodoElement((Element)child, this.ctx, this);
toProcess.add(it);
}
}
@@ -68,8 +65,7 @@ public class TodoBodyElement extends TodoDefaultElement {
"d:implicit-do-footer");
bodyNode.appendChild(token);
bodyNode.appendChild(ctx.doc.createTextNode("\n"));
- // toProcess.add(new TodoFooter(token, this.ctx,
- // new TodoItem.Options()));
+ // toProcess.add(new TodoFooter(token, this.ctx, this));
}
this.ownerDeque.registerAtStart(toProcess);
}
diff --git a/org/madore/damlengine/TodoDamlElement.java b/org/madore/damlengine/TodoDamlElement.java
index d177998..419e7d3 100644
--- a/org/madore/damlengine/TodoDamlElement.java
+++ b/org/madore/damlengine/TodoDamlElement.java
@@ -9,22 +9,19 @@ public class TodoDamlElement extends TodoDefaultElement {
public static class Factory extends TodoElement.Factory {
public TodoDamlElement newItem(Element node,
Context ctx,
- TodoItem.Options options) {
- return new TodoDamlElement(node, ctx, options);
+ TodoItem caller) {
+ return new TodoDamlElement(node, ctx, caller);
}
}
public TodoDamlElement(Element node,
Context ctx,
- TodoItem.Options options) {
- super(node, ctx, options);
- }
-
- public static class DamlOptions extends TodoItem.Options {
+ TodoItem caller) {
+ super(node, ctx, caller);
}
public void handleNodeOnly() {
- if ( ! ( options instanceof DamlEngine.RootOptions ) )
+ if ( ! ( caller instanceof DamlEngine.RootTodo ) )
throw new IllegalArgumentException("daml node can only be root node");
final String uriToTopName = "uri-to-top";
if ( node.hasAttributeNS(null, uriToTopName) )
@@ -86,8 +83,7 @@ public class TodoDamlElement extends TodoDefaultElement {
ctx.headNode.appendChild(ctx.doc.createTextNode("\n"));
}
TodoElement it
- = TodoElement.getTodoElement((Element)child, this.ctx,
- new DamlOptions());
+ = TodoElement.getTodoElement((Element)child, this.ctx, this);
toProcess.add(it);
} else if ( child.getNodeType() == Node.TEXT_NODE
|| child.getNodeType() == Node.CDATA_SECTION_NODE ) {
@@ -98,10 +94,10 @@ public class TodoDamlElement extends TodoDefaultElement {
this.ownerDeque.registerAtStart(toProcess);
this.ownerDeque.
registerAtEnd(new TodoStyleOrScript(TodoStyleOrScript.Type.STYLE,
- this.ctx, new DamlOptions()));
+ this.ctx, this));
this.ownerDeque.
registerAtEnd(new TodoStyleOrScript(TodoStyleOrScript.Type.SCRIPT,
- this.ctx, new DamlOptions()));
+ this.ctx, this));
}
}
diff --git a/org/madore/damlengine/TodoDefaultElement.java b/org/madore/damlengine/TodoDefaultElement.java
index a7aa37e..4360fe5 100644
--- a/org/madore/damlengine/TodoDefaultElement.java
+++ b/org/madore/damlengine/TodoDefaultElement.java
@@ -8,15 +8,15 @@ public class TodoDefaultElement extends TodoElement {
public static class Factory extends TodoElement.Factory {
public TodoDefaultElement newItem(Element node,
Context ctx,
- TodoItem.Options options) {
- return new TodoDefaultElement(node, ctx, options);
+ TodoItem caller) {
+ return new TodoDefaultElement(node, ctx, caller);
}
}
public TodoDefaultElement(Element node,
Context ctx,
- TodoItem.Options options) {
- super(node, ctx, options);
+ TodoItem caller) {
+ super(node, ctx, caller);
}
public static ArrayList<Attr> getAttrList(Element node) {
@@ -42,8 +42,7 @@ public class TodoDefaultElement extends TodoElement {
ArrayList<TodoAttr> toProcess = new ArrayList<TodoAttr>(attrList.size());
for ( Attr attr : attrList ) {
TodoAttr it
- = TodoAttr.getTodoAttr(attr, this.node, this.ctx,
- new TodoItem.Options());
+ = TodoAttr.getTodoAttr(attr, this.node, this.ctx, this);
if ( it != null )
toProcess.add(it);
}
@@ -56,8 +55,7 @@ public class TodoDefaultElement extends TodoElement {
for ( Node child : childList ) {
if ( child.getNodeType() == Node.ELEMENT_NODE ) {
TodoElement it
- = TodoElement.getTodoElement((Element)child, this.ctx,
- new TodoItem.Options());
+ = TodoElement.getTodoElement((Element)child, this.ctx, this);
toProcess.add(it);
}
}
diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java
index 3cb07de..a871968 100644
--- a/org/madore/damlengine/TodoElement.java
+++ b/org/madore/damlengine/TodoElement.java
@@ -9,7 +9,7 @@ public abstract class TodoElement extends TodoItem {
public static abstract class Factory {
public abstract TodoElement newItem(Element node,
Context ctx,
- TodoItem.Options options);
+ TodoItem caller);
}
protected static Map<String,Factory> damlFactories;
@@ -26,21 +26,21 @@ public abstract class TodoElement extends TodoItem {
public TodoElement(Element node,
Context ctx,
- TodoItem.Options options) {
- super(ctx, options);
+ TodoItem caller) {
+ super(ctx, caller);
this.node = node;
}
public static TodoElement getTodoElement(Element node,
Context ctx,
- TodoItem.Options options) {
+ TodoItem caller) {
Factory factory = null;
String nsuri = node.getNamespaceURI();
if ( nsuri != null && nsuri.equals(DamlEngine.DAML_NS) )
factory = damlFactories.get(node.getLocalName());
if ( factory == null )
factory = damlDefaultFactory;
- return factory.newItem(node, ctx, options);
+ return factory.newItem(node, ctx, caller);
}
}
diff --git a/org/madore/damlengine/TodoItem.java b/org/madore/damlengine/TodoItem.java
index e4669c9..2c4bfd9 100644
--- a/org/madore/damlengine/TodoItem.java
+++ b/org/madore/damlengine/TodoItem.java
@@ -2,16 +2,13 @@ package org.madore.damlengine;
public abstract class TodoItem {
- public static class Options {
- }
-
public TodoDeque ownerDeque;
public Context ctx;
- public Options options;
+ public TodoItem caller;
- public TodoItem(Context ctx, Options options) {
+ public TodoItem(Context ctx, TodoItem caller) {
this.ctx = ctx;
- this.options = options;
+ this.caller = caller;
}
public abstract void handle();
diff --git a/org/madore/damlengine/TodoStyleOrScript.java b/org/madore/damlengine/TodoStyleOrScript.java
index 4c04528..57aefba 100644
--- a/org/madore/damlengine/TodoStyleOrScript.java
+++ b/org/madore/damlengine/TodoStyleOrScript.java
@@ -10,8 +10,8 @@ public class TodoStyleOrScript extends TodoItem {
public TodoStyleOrScript(Type t,
Context ctx,
- TodoItem.Options options) {
- super(ctx, options);
+ TodoItem caller) {
+ super(ctx, caller);
this.t = t;
}
diff --git a/org/madore/damlengine/TodoXemptyAttr.java b/org/madore/damlengine/TodoXemptyAttr.java
index 838deb2..cc8491c 100644
--- a/org/madore/damlengine/TodoXemptyAttr.java
+++ b/org/madore/damlengine/TodoXemptyAttr.java
@@ -7,15 +7,15 @@ public class TodoXemptyAttr extends TodoAttr {
public static class Factory extends TodoAttr.Factory {
public TodoXemptyAttr newItem(Attr attr, Element owner,
Context ctx,
- TodoItem.Options options) {
- return new TodoXemptyAttr(attr, owner, ctx, options);
+ TodoItem caller) {
+ return new TodoXemptyAttr(attr, owner, ctx, caller);
}
}
public TodoXemptyAttr(Attr attr, Element owner,
Context ctx,
- TodoItem.Options options) {
- super(attr, owner, ctx, options);
+ TodoItem caller) {
+ super(attr, owner, ctx, caller);
}
public void handle() {