From 99cea43742283d7bc383021ebd52087115448159 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Sun, 18 Apr 2010 21:07:21 +0200 Subject: Rename TodoContext class to Context. Usually call "ctx" its instances. --- org/madore/damlengine/Context.java | 17 ++++++++++ org/madore/damlengine/DamlEngine.java | 4 +-- org/madore/damlengine/TodoAttr.java | 10 +++--- org/madore/damlengine/TodoContext.java | 17 ---------- org/madore/damlengine/TodoDamlElement.java | 48 +++++++++++++-------------- org/madore/damlengine/TodoDefaultElement.java | 12 +++---- org/madore/damlengine/TodoElement.java | 10 +++--- org/madore/damlengine/TodoItem.java | 6 ++-- org/madore/damlengine/TodoXemptyAttr.java | 10 +++--- 9 files changed, 67 insertions(+), 67 deletions(-) create mode 100644 org/madore/damlengine/Context.java delete mode 100644 org/madore/damlengine/TodoContext.java (limited to 'org/madore/damlengine') diff --git a/org/madore/damlengine/Context.java b/org/madore/damlengine/Context.java new file mode 100644 index 0000000..cbb2c3e --- /dev/null +++ b/org/madore/damlengine/Context.java @@ -0,0 +1,17 @@ +package org.madore.damlengine; + +import org.w3c.dom.*; + +public class Context { + + public Document doc; + public Element htmlNode; + public Element headNode; + public String uriToTop; + public String fileName; + + public Context(Document doc) { + this.doc = doc; + } + +} diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index d71f62b..63f1442 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -20,11 +20,11 @@ public final class DamlEngine { public static void processDocument(Document doc) { TodoDeque todoDeque = new TodoDeque(); - TodoContext context = new TodoContext(doc); + Context ctx = new Context(doc); TodoItem.Options options = new RootOptions(); todoDeque. registerAtEnd(TodoElement.getTodoElement(doc.getDocumentElement(), - context, options)); + ctx, options)); todoDeque.dispatchLoop(); } diff --git a/org/madore/damlengine/TodoAttr.java b/org/madore/damlengine/TodoAttr.java index 0cc5389..f9e2e70 100644 --- a/org/madore/damlengine/TodoAttr.java +++ b/org/madore/damlengine/TodoAttr.java @@ -9,7 +9,7 @@ public abstract class TodoAttr extends TodoItem { public static abstract class Factory { public abstract TodoAttr newItem(Attr attr, Element owner, - TodoContext context, + Context ctx, TodoItem.Options options); } @@ -24,14 +24,14 @@ public abstract class TodoAttr extends TodoItem { Element owner; public TodoAttr(Attr attr, Element owner, - TodoContext context, TodoItem.Options options) { - super(context, options); + Context ctx, TodoItem.Options options) { + super(ctx, options); this.attr = attr; this.owner = owner; } public static TodoAttr getTodoAttr(Attr attr, Element owner, - TodoContext context, + Context ctx, TodoItem.Options options) { Factory factory = null; String nsuri = attr.getNamespaceURI(); @@ -39,7 +39,7 @@ public abstract class TodoAttr extends TodoItem { factory = damlAttrFactories.get(attr.getLocalName()); if ( factory == null ) return null; - return factory.newItem(attr, owner, context, options); + return factory.newItem(attr, owner, ctx, options); } } diff --git a/org/madore/damlengine/TodoContext.java b/org/madore/damlengine/TodoContext.java deleted file mode 100644 index 4042370..0000000 --- a/org/madore/damlengine/TodoContext.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.madore.damlengine; - -import org.w3c.dom.*; - -public class TodoContext { - - public Document doc; - public Element htmlNode; - public Element headNode; - public String uriToTop; - public String fileName; - - public TodoContext(Document doc) { - this.doc = doc; - } - -} diff --git a/org/madore/damlengine/TodoDamlElement.java b/org/madore/damlengine/TodoDamlElement.java index 88881ae..fefd0f1 100644 --- a/org/madore/damlengine/TodoDamlElement.java +++ b/org/madore/damlengine/TodoDamlElement.java @@ -8,16 +8,16 @@ public class TodoDamlElement extends TodoDefaultElement { public static class Factory extends TodoElement.Factory { public TodoDamlElement newItem(Element node, - TodoContext context, + Context ctx, TodoItem.Options options) { - return new TodoDamlElement(node, context, options); + return new TodoDamlElement(node, ctx, options); } } public TodoDamlElement(Element node, - TodoContext context, + Context ctx, TodoItem.Options options) { - super(node, context, options); + super(node, ctx, options); } public static class DamlOptions extends TodoItem.Options { @@ -28,42 +28,42 @@ public class TodoDamlElement extends TodoDefaultElement { throw new Error("daml node can only be root node"); String uriToTop = node.getAttributeNS(null, "uri-to-top"); if ( uriToTop != null ) - context.uriToTop = uriToTop; + ctx.uriToTop = uriToTop; String fileName = node.getAttributeNS(null, "file.name"); if ( fileName != null ) - context.fileName = fileName; + ctx.fileName = fileName; - if ( context.htmlNode != null ) + if ( ctx.htmlNode != null ) throw new Error("html node already defined at daml node"); - context.htmlNode = context.doc.createElementNS(DamlEngine.XHTML_NS, "html"); + ctx.htmlNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "html"); String lang = LangHelper.getLangNorec(node); if ( lang != null ) - LangHelper.setLangNorec(context.htmlNode, lang); - node.getParentNode().replaceChild(context.htmlNode, node); - context.htmlNode.appendChild(context.doc.createTextNode("\n")); - context.htmlNode.appendChild(context.doc.createComment(" This file is automatically generated. Do not edit! ")); - context.htmlNode.appendChild(context.doc.createTextNode("\n")); - if ( context.headNode != null ) + LangHelper.setLangNorec(ctx.htmlNode, lang); + node.getParentNode().replaceChild(ctx.htmlNode, node); + ctx.htmlNode.appendChild(ctx.doc.createTextNode("\n")); + ctx.htmlNode.appendChild(ctx.doc.createComment(" This file is automatically generated. Do not edit! ")); + ctx.htmlNode.appendChild(ctx.doc.createTextNode("\n")); + if ( ctx.headNode != null ) throw new Error("head node already defined at daml node"); - context.headNode = context.doc.createElementNS(DamlEngine.XHTML_NS, "head"); - context.htmlNode.appendChild(context.headNode); - context.htmlNode.appendChild(context.doc.createTextNode("\n")); - context.headNode.appendChild(context.doc.createTextNode("\n")); + ctx.headNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "head"); + ctx.htmlNode.appendChild(ctx.headNode); + ctx.htmlNode.appendChild(ctx.doc.createTextNode("\n")); + ctx.headNode.appendChild(ctx.doc.createTextNode("\n")); ArrayList childList = getChildList(this.node); ArrayList toProcess = new ArrayList(childList.size()); for ( Node child : childList ) { if ( child.getNodeType() == Node.ELEMENT_NODE ) { if ( child.getLocalName().equals("body") ) { - context.htmlNode.appendChild(context.doc.createTextNode("\n")); - context.htmlNode.appendChild(child); - context.htmlNode.appendChild(context.doc.createTextNode("\n")); + ctx.htmlNode.appendChild(ctx.doc.createTextNode("\n")); + ctx.htmlNode.appendChild(child); + ctx.htmlNode.appendChild(ctx.doc.createTextNode("\n")); } else { - context.headNode.appendChild(child); - context.headNode.appendChild(context.doc.createTextNode("\n")); + ctx.headNode.appendChild(child); + ctx.headNode.appendChild(ctx.doc.createTextNode("\n")); } TodoElement it - = TodoElement.getTodoElement((Element)child, this.context, + = TodoElement.getTodoElement((Element)child, this.ctx, new DamlOptions()); toProcess.add(it); } else if ( child.getNodeType() == Node.TEXT_NODE diff --git a/org/madore/damlengine/TodoDefaultElement.java b/org/madore/damlengine/TodoDefaultElement.java index 8b0efa9..a7aa37e 100644 --- a/org/madore/damlengine/TodoDefaultElement.java +++ b/org/madore/damlengine/TodoDefaultElement.java @@ -7,16 +7,16 @@ public class TodoDefaultElement extends TodoElement { public static class Factory extends TodoElement.Factory { public TodoDefaultElement newItem(Element node, - TodoContext context, + Context ctx, TodoItem.Options options) { - return new TodoDefaultElement(node, context, options); + return new TodoDefaultElement(node, ctx, options); } } public TodoDefaultElement(Element node, - TodoContext context, + Context ctx, TodoItem.Options options) { - super(node, context, options); + super(node, ctx, options); } public static ArrayList getAttrList(Element node) { @@ -42,7 +42,7 @@ public class TodoDefaultElement extends TodoElement { ArrayList toProcess = new ArrayList(attrList.size()); for ( Attr attr : attrList ) { TodoAttr it - = TodoAttr.getTodoAttr(attr, this.node, this.context, + = TodoAttr.getTodoAttr(attr, this.node, this.ctx, new TodoItem.Options()); if ( it != null ) toProcess.add(it); @@ -56,7 +56,7 @@ public class TodoDefaultElement extends TodoElement { for ( Node child : childList ) { if ( child.getNodeType() == Node.ELEMENT_NODE ) { TodoElement it - = TodoElement.getTodoElement((Element)child, this.context, + = TodoElement.getTodoElement((Element)child, this.ctx, new TodoItem.Options()); toProcess.add(it); } diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java index 77c7891..279b65b 100644 --- a/org/madore/damlengine/TodoElement.java +++ b/org/madore/damlengine/TodoElement.java @@ -8,7 +8,7 @@ public abstract class TodoElement extends TodoItem { public static abstract class Factory { public abstract TodoElement newItem(Element node, - TodoContext context, + Context ctx, TodoItem.Options options); } @@ -24,14 +24,14 @@ public abstract class TodoElement extends TodoItem { Element node; public TodoElement(Element node, - TodoContext context, + Context ctx, TodoItem.Options options) { - super(context, options); + super(ctx, options); this.node = node; } public static TodoElement getTodoElement(Element node, - TodoContext context, + Context ctx, TodoItem.Options options) { Factory factory = null; String nsuri = node.getNamespaceURI(); @@ -39,7 +39,7 @@ public abstract class TodoElement extends TodoItem { factory = damlFactories.get(node.getLocalName()); if ( factory == null ) factory = damlDefaultFactory; - return factory.newItem(node, context, options); + return factory.newItem(node, ctx, options); } } diff --git a/org/madore/damlengine/TodoItem.java b/org/madore/damlengine/TodoItem.java index d956800..e4669c9 100644 --- a/org/madore/damlengine/TodoItem.java +++ b/org/madore/damlengine/TodoItem.java @@ -6,11 +6,11 @@ public abstract class TodoItem { } public TodoDeque ownerDeque; - public TodoContext context; + public Context ctx; public Options options; - public TodoItem(TodoContext context, Options options) { - this.context = context; + public TodoItem(Context ctx, Options options) { + this.ctx = ctx; this.options = options; } diff --git a/org/madore/damlengine/TodoXemptyAttr.java b/org/madore/damlengine/TodoXemptyAttr.java index 2a233c4..838deb2 100644 --- a/org/madore/damlengine/TodoXemptyAttr.java +++ b/org/madore/damlengine/TodoXemptyAttr.java @@ -6,21 +6,21 @@ public class TodoXemptyAttr extends TodoAttr { public static class Factory extends TodoAttr.Factory { public TodoXemptyAttr newItem(Attr attr, Element owner, - TodoContext context, + Context ctx, TodoItem.Options options) { - return new TodoXemptyAttr(attr, owner, context, options); + return new TodoXemptyAttr(attr, owner, ctx, options); } } public TodoXemptyAttr(Attr attr, Element owner, - TodoContext context, + Context ctx, TodoItem.Options options) { - super(attr, owner, context, options); + super(attr, owner, ctx, options); } public void handle() { this.owner.removeAttribute(this.attr.getName()); - this.owner.appendChild(context.doc.createComment(" EMPTY ")); + this.owner.appendChild(ctx.doc.createComment(" EMPTY ")); } } -- cgit v1.2.3