ibex.core updates for new api
[org.ibex.core.git] / src / org / ibex / core / Template.java
index ddbf5b0..7f342dd 100644 (file)
@@ -25,7 +25,7 @@ public class Template {
 
     String id = null;                   ///< the id of this box
     String redirect = null;             ///< the id of the redirect target; only meaningful on a root node
 
     String id = null;                   ///< the id of this box
     String redirect = null;             ///< the id of the redirect target; only meaningful on a root node
-    private String[] keys;              ///< keys to be "put" to instances of this template; elements correspond to those of vals
+    private JS[] keys;              ///< keys to be "put" to instances of this template; elements correspond to those of vals
     private JS[] vals;                  ///< values to be "put" to instances of this template; elements correspond to those of keys
     private String[] urikeys;
     private String[] urivals;
     private JS[] vals;                  ///< values to be "put" to instances of this template; elements correspond to those of keys
     private String[] urikeys;
     private String[] urivals;
@@ -101,7 +101,7 @@ public class Template {
 
         for(int i=0; keys != null && i < keys.length; i++) {
             if (keys[i] == null) continue;
 
         for(int i=0; keys != null && i < keys.length; i++) {
             if (keys[i] == null) continue;
-            String key = keys[i];
+            JS key = keys[i];
             JS val = vals[i];
 
             if ("null".equals(val)) val = null;
             JS val = vals[i];
 
             if ("null".equals(val)) val = null;
@@ -118,7 +118,7 @@ public class Template {
                     // FIXME: should we be resolving all of these in the XML-parsing code?
                 }
             }
                     // FIXME: should we be resolving all of these in the XML-parsing code?
                 }
             }
-            b.putAndTriggerTraps(JS.S(key), val);
+            b.putAndTriggerTraps(key, val);
         }
     }
 
         }
     }
 
@@ -160,7 +160,7 @@ public class Template {
             InputStream is = Stream.getInputStream(s);
             Ibex.Blessing b = Ibex.Blessing.getBlessing(s).parent;
             while(b != null) {
             InputStream is = Stream.getInputStream(s);
             Ibex.Blessing b = Ibex.Blessing.getBlessing(s).parent;
             while(b != null) {
-                if(b.parentkey != null) initial_uri = b.parentkey + (initial_uri.equals("") ? "" : "." + initial_uri);
+                if(b.parentkey != null) initial_uri = JS.toString(b.parentkey) + (initial_uri.equals("") ? "" : "." + initial_uri);
                 b = b.parent;
             }
             initial_uri = "";
                 b = b.parent;
             }
             initial_uri = "";
@@ -202,13 +202,15 @@ public class Template {
                     break;
             }
 
                     break;
             }
 
+            // FIXME: This is all wrong
             if (!("ibex://ui".equals(c.getUri()) && "box".equals(c.getLocalName()))) {
                 String tagname = (c.getUri().equals("") ? "" : (c.getUri() + ".")) + c.getLocalName();
                 // GROSS hack
                 try {
                     // GROSSER hack
                     // t.prev2 = (Template)t.ibex.resolveString(tagname, false).call(null, null, null, null, 9999);
             if (!("ibex://ui".equals(c.getUri()) && "box".equals(c.getLocalName()))) {
                 String tagname = (c.getUri().equals("") ? "" : (c.getUri() + ".")) + c.getLocalName();
                 // GROSS hack
                 try {
                     // GROSSER hack
                     // t.prev2 = (Template)t.ibex.resolveString(tagname, false).call(null, null, null, null, 9999);
-                    throw new Error("FIXME - 9999 thing"); // FIXME:9999 thing
+                    if(t.prev2 != null) throw new Error("FIXME: t.prev2 != null");
+                    t.prev2 = ((Ibex.Blessing)t.ibex.resolveString(tagname, false)).getTemplate();
                 } catch (Exception e) {
                     Log.error(Template.class, e);
                 }
                 } catch (Exception e) {
                     Log.error(Template.class, e);
                 }
@@ -253,16 +255,14 @@ public class Template {
                 return ((String)a).compareTo((String)b);
             } });
 
                 return ((String)a).compareTo((String)b);
             } });
 
-            t.keys = new String[keys.size()];
+            t.keys = new JS[keys.size()];
             t.vals = new JS[vals.size()];
             t.vals = new JS[vals.size()];
-            keys.copyInto(t.keys);
-            vals.copyInto(t.vals);
-
+            
             // convert attributes to appropriate types and intern strings
             for(int i=0; i<t.keys.length; i++) {
             // convert attributes to appropriate types and intern strings
             for(int i=0; i<t.keys.length; i++) {
-                t.keys[i] = t.keys[i].intern();
-
-                String valString = t.vals[i].toString();
+                // FEATURE: Intern
+                t.keys[i] = JS.S((String)keys.elementAt(i));
+                String valString = (String) vals.elementAt(i);
                 
                 if (valString.equals("true")) t.vals[i] = JS.T;
                 else if (valString.equals("false")) t.vals[i] = JS.F;
                 
                 if (valString.equals("true")) t.vals[i] = JS.T;
                 else if (valString.equals("false")) t.vals[i] = JS.F;