preliminary core conversion
[org.ibex.core.git] / src / org / ibex / graphics / HTML.java
index 47de2e0..e34704e 100644 (file)
@@ -50,6 +50,21 @@ public class HTML {
     /** true iff we have encountered an LI more recently than the last OL/UL */
     private static boolean withinLI = false;
 
+    // FEATURE: This is ugly
+    private static class JS extends org.ibex.js.JS.O {
+        public void put(String key, Object value) throws JSExn {
+            if(value instanceof String) put(JS.S(key),JS.S((String)value));
+            else if(value instanceof Number) put(JS.S(key), JS.N((Number)value));
+            else if(value == null) put(JS.S(key),null);
+            else throw new Error("FIXME");
+        }
+        public Object _get(String key) throws JSExn {
+            org.ibex.js.JS js = get(JS.S(key));
+            if(JS.isInt(js)) return new Integer(JS.toInt(js));
+            return JS.toString(js);
+        }
+    }
+    
     public static synchronized JS parseReader(Reader r) throws IOException, JSExn {
         CharStream cs = new CharStream(r);
         JS h = new JS();
@@ -137,7 +152,7 @@ public class HTML {
      */
     private static String parseBody(CharStream cs, JS h, String elementName) throws IOException, JSExn {
         String cdata = "";
-        int length = h.get("$numchildren") == null ? 0 : Integer.parseInt(h.get("$numchildren").toString());
+        int length = h._get("$numchildren") == null ? 0 : Integer.parseInt(h._get("$numchildren").toString());
         while(true) {
             String closetag = null;