X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2FTemplate.java;fp=src%2Forg%2Fxwt%2FTemplate.java;h=00e580a707a1f5515e05ae02606b8e9dce977992;hp=2cc62420e61021993a5953448a3eb93b2588140c;hb=3591b88b94a6bb378af3d4abe6eb5233ce583104;hpb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f diff --git a/src/org/xwt/Template.java b/src/org/ibex/Template.java similarity index 87% rename from src/org/xwt/Template.java rename to src/org/ibex/Template.java index 2cc6242..00e580a 100644 --- a/src/org/xwt/Template.java +++ b/src/org/ibex/Template.java @@ -1,17 +1,14 @@ // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] -package org.xwt; +package org.ibex; import java.io.*; -import java.util.zip.*; import java.util.*; -import java.lang.*; -import org.xwt.js.*; -import org.xwt.translators.*; -import org.xwt.util.*; +import org.ibex.js.*; +import org.ibex.util.*; /** * Encapsulates a template node (the <template/> element of a - * .xwt file, or any child element thereof). + * .ibex file, or any child element thereof). * * Note that the Template instance corresponding to the * <template/> node carries all the header information -- hence @@ -19,7 +16,7 @@ import org.xwt.util.*; * Template instances. We refer to these non-root instances as * anonymous templates. * - * See the XWT reference for information on the order in which + * See the Ibex reference for information on the order in which * templates are applied, attributes are put, and scripts are run. */ public class Template { @@ -43,14 +40,14 @@ public class Template { private StringBuffer content = null; ///< during XML parsing, this holds partially-read character data; null otherwise private int content_start = 0; ///< line number of the first line of content private int startLine = -1; ///< the line number that this element starts on - private XWT xwt; + private Ibex ibex; // Static data/methods /////////////////////////////////////////////////////////////////// // for non-root nodes - private Template(Template t, int startLine) { prev = t; this.xwt = t.xwt; this.startLine = startLine; } - private Template(XWT xwt) { this.xwt = xwt; } + private Template(Template t, int startLine) { prev = t; this.ibex = t.ibex; this.startLine = startLine; } + private Template(Ibex ibex) { this.ibex = ibex; } // Methods to apply templates //////////////////////////////////////////////////////// @@ -82,10 +79,10 @@ public class Template { // FIXME this dollar stuff is all wrong if (id != null) parentPis.putDollar(id, b); - PerInstantiationScope pis = new PerInstantiationScope(b, xwt, parentPis, staticScope); + PerInstantiationScope pis = new PerInstantiationScope(b, ibex, parentPis, staticScope); for(int i=0; i", XML.Exn.SCHEMA, getLine(), getCol()); if (c.getAttrLen() != 0) throw new XML.Exn("root element must not have attributes", XML.Exn.SCHEMA, getLine(), getCol()); - state = STATE_IN_XWT_NODE; + state = STATE_IN_Ibex_NODE; return; - case STATE_IN_XWT_NODE: + case STATE_IN_Ibex_NODE: if ("meta".equals(c.getPrefix())) { state = STATE_IN_META_NODE; meta = 0; return; } state = STATE_IN_TEMPLATE_NODE; - t = (t == null) ? new Template(xwt) : new Template(t, getLine()); + t = (t == null) ? new Template(ibex) : new Template(t, getLine()); break; case STATE_IN_TEMPLATE_NODE: nodeStack.addElement(t); - t = new Template(xwt); + t = new Template(ibex); break; } @@ -191,7 +188,7 @@ public class Template { String tagname = (c.getUri().equals("") ? "" : (c.getUri() + ".")) + c.getLocalName(); // GROSS hack try { - t.prev = (Template)t.xwt.resolveString(tagname, false).call(null, null, null, null, 9999); + t.prev = (Template)t.ibex.resolveString(tagname, false).call(null, null, null, null, 9999); } catch (Exception e) { Log.error(Template.class, e); } @@ -268,11 +265,11 @@ public class Template { public void endElement(XML.Element c) throws XML.Exn, IOException { switch(state) { - case STATE_IN_META_NODE: if (meta-- < 0) state = STATE_IN_XWT_NODE; return; - case STATE_IN_XWT_NODE: return; + case STATE_IN_META_NODE: if (meta-- < 0) state = STATE_IN_Ibex_NODE; return; + case STATE_IN_Ibex_NODE: return; case STATE_IN_TEMPLATE_NODE: { if (t.content != null) { t.script = parseScript(t.content, t.content_start); t.content = null; } - if (nodeStack.size() == 0) { state = STATE_IN_XWT_NODE; return; } + if (nodeStack.size() == 0) { state = STATE_IN_Ibex_NODE; return; } Template oldt = t; t = (Template)nodeStack.lastElement(); nodeStack.setSize(nodeStack.size() - 1); @@ -285,7 +282,7 @@ public class Template { public void characters(char[] ch, int start, int length) throws XML.Exn { for (int i=0; length >i; i++) if (ch[start+i] == '\t') - Log.error(Template.class, "tabs are not allowed in XWT files ("+getLine()+":"+getCol()+")"); + Log.error(Template.class, "tabs are not allowed in Ibex files ("+getLine()+":"+getCol()+")"); switch(state) { case STATE_IN_TEMPLATE_NODE: if (t.content == null) { @@ -294,7 +291,7 @@ public class Template { } t.content.append(ch, start, length); return; - case STATE_IN_XWT_NODE: + case STATE_IN_Ibex_NODE: if (static_content == null) { static_content_start = getLine(); static_content = new StringBuffer(); @@ -308,7 +305,7 @@ public class Template { } private static class PerInstantiationScope extends JSScope { - XWT xwt = null; + Ibex ibex = null; PerInstantiationScope parentBoxPis = null; JSScope myStatic = null; void putDollar(String key, Box target) throws JSExn { @@ -316,16 +313,16 @@ public class Template { declare("$" + key); put("$" + key, target); } - public PerInstantiationScope(JSScope parentScope, XWT xwt, PerInstantiationScope parentBoxPis, JSScope myStatic) { + public PerInstantiationScope(JSScope parentScope, Ibex ibex, PerInstantiationScope parentBoxPis, JSScope myStatic) { super(parentScope); this.parentBoxPis = parentBoxPis; - this.xwt = xwt; + this.ibex = ibex; this.myStatic = myStatic; } public Object get(Object key) throws JSExn { if (super.has(key)) return super.get(key); - if (key.equals("xwt")) return xwt; - if (key.equals("")) return xwt.get(""); + if (key.equals("ibex")) return ibex; + if (key.equals("")) return ibex.get(""); if (key.equals("static")) return myStatic; return super.get(key); }