X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fgraphics%2FHTML.java;h=419c9d1c38d7fd4eb967d556b994104e6355b969;hb=559d1e3e071d2204c05c91f36a9349e57a7e7a91;hp=8896e6f0749e0ebd82e08f039c52d5f489d17c15;hpb=fffcafc33aa4066bdf85da7a32e1a1cdb9db2d6f;p=org.ibex.core.git diff --git a/src/org/ibex/graphics/HTML.java b/src/org/ibex/graphics/HTML.java index 8896e6f..419c9d1 100644 --- a/src/org/ibex/graphics/HTML.java +++ b/src/org/ibex/graphics/HTML.java @@ -1,4 +1,7 @@ -// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the GNU General Public License version 2 ("the License"). +// You may not use this file except in compliance with the License. + package org.ibex.graphics; import java.util.*; @@ -50,9 +53,24 @@ 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.Obj { + public void put(String key, Object value) throws JSExn { + if(value instanceof String) put(JSU.S(key),JSU.S((String)value)); + else if(value instanceof Number) put(JSU.S(key), JSU.N((Number)value)); + else if(value == null) put(JSU.S(key), (JS)null); + else throw new Error("FIXME"); + } + public Object _get(String key) throws JSExn { + org.ibex.js.JS js = get(JSU.S(key)); + if(JSU.isInt(js)) return new Integer(JSU.toInt(js)); + return JSU.toString(js); + } + } + public static synchronized JS parseReader(Reader r) throws IOException, JSExn { CharStream cs = new CharStream(r); - JS h = new JS.O(); + JS h = new JS(); withinLI = false; h.put("$name", "html"); @@ -137,7 +155,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; @@ -163,7 +181,7 @@ public class HTML { try { // scan subelement if (cs.peek() != '/') { - JS kid = new JS.O(); + JS kid = new JS(); closetag = parseElement(cs, kid); h.put(String.valueOf(length), kid); h.put("$numchildren", new Integer(++length));