pass correct range to sort()
[org.ibex.core.git] / src / org / ibex / core / Template.java
index aca83ba..a59e99d 100644 (file)
@@ -207,7 +207,8 @@ public class Template {
 
             // FIXME: This is all wrong
             if (!("ibex://ui".equals(c.getUri()) && "box".equals(c.getLocalName()))) {
 
             // FIXME: This is all wrong
             if (!("ibex://ui".equals(c.getUri()) && "box".equals(c.getLocalName()))) {
-                String tagname = (c.getUri().equals("") ? "" : (c.getUri() + ".")) + c.getLocalName();
+                String tagname = (c.getUri() == null || "".equals(c.getUri()) ? "" :
+                                 (c.getUri() + ".")) + c.getLocalName();
                 // GROSS hack
                 try {
                     // GROSSER hack
                 // GROSS hack
                 try {
                     // GROSSER hack
@@ -248,7 +249,7 @@ public class Template {
                 }
 
                 // treat value starting with '.' as resource reference
                 }
 
                 // treat value starting with '.' as resource reference
-                String uri = a.getUri(i); if (!uri.equals("")) uri = '.' + uri;
+                String uri = a.getUri(i); if (uri != null && !uri.equals("")) uri = '.' + uri;
                 keys.add(a.getKey(i));
                 vals.add((a.getVal(i).startsWith(".") ? uri : "") + a.getVal(i));
             }
                 keys.add(a.getKey(i));
                 vals.add((a.getVal(i).startsWith(".") ? uri : "") + a.getVal(i));
             }
@@ -258,7 +259,7 @@ public class Template {
             // sort the attributes lexicographically
             Basket.Array.sort(keys, vals, new Basket.CompareFunc() {
                 public int compare(Object a, Object b) { return ((String)a).compareTo((String)b); }
             // sort the attributes lexicographically
             Basket.Array.sort(keys, vals, new Basket.CompareFunc() {
                 public int compare(Object a, Object b) { return ((String)a).compareTo((String)b); }
-            }, 0, keys.size());
+            }, 0, keys.size() - 1);
 
             t.keys = new JS[keys.size()];
             t.vals = new JS[vals.size()];
 
             t.keys = new JS[keys.size()];
             t.vals = new JS[vals.size()];