- else if (name.equals("base64"))
- objects.setElementAt(new ByteStream(Base64.decode(new String(content.getBuf(), 0, content.size()))), objects.size() - 1);
-
- else if (name.equals("name"))
- objects.addElement(new String(content.getBuf(), 0, content.size()));
-
- else if (name.equals("value") && "".equals(objects.lastElement()))
- objects.setElementAt(new String(content.getBuf(), 0, content.size()), objects.size() - 1);
-
- else if (name.equals("dateTime.iso8601")) {
- String s = new String(content.getBuf(), 0, content.size());
-
- // strip whitespace
- int i=0;
- while(Character.isWhitespace(s.charAt(i))) i++;
- if (i > 0) s = s.substring(i);
-
- try {
- NativeDate nd = (NativeDate)Context.enter().newObject(org.xwt.util.JSObject.defaultObjects, "Date");
- double date = NativeDate.date_msecFromDate(Double.valueOf(s.substring(0, 4)).doubleValue(),
- Double.valueOf(s.substring(4, 6)).doubleValue() - 1,
- Double.valueOf(s.substring(6, 8)).doubleValue(),
- Double.valueOf(s.substring(9, 11)).doubleValue(),
- Double.valueOf(s.substring(12, 14)).doubleValue(),
- Double.valueOf(s.substring(15, 17)).doubleValue(),
- (double)0
- );
- nd.jsFunction_setTime(NativeDate.internalUTC(date));
- objects.setElementAt(nd, objects.size() - 1);
-
- } catch (Exception e) {
- if (Log.on) Log.log(this, "error parsing date : " + s);
- if (Log.on) Log.log(this, e);
+ public void startElement(XML.Element c) {
+ content.reset();
+ if (c.localName.equals("fault")) fault = true;
+ else if (c.localName.equals("struct")) objects.setElementAt(new JS.Obj(), objects.size() - 1);
+ else if (c.localName.equals("array")) objects.setElementAt(null, objects.size() - 1);
+ else if (c.localName.equals("value")) objects.addElement("");
+ }
+
+ public void endElement(XML.Element c) {
+
+ if (c.localName.equals("int") || c.localName.equals("i4"))
+ objects.setElementAt(new Integer(new String(content.getBuf(), 0, content.size())), objects.size() - 1);
+
+ else if (c.localName.equals("boolean"))
+ objects.setElementAt(content.getBuf()[0] == '1' ? Boolean.TRUE : Boolean.FALSE, objects.size() - 1);
+
+ else if (c.localName.equals("string"))
+ objects.setElementAt(new String(content.getBuf(), 0, content.size()), objects.size() - 1);
+
+ else if (c.localName.equals("double"))
+ objects.setElementAt(new Double(new String(content.getBuf(), 0, content.size())), objects.size() - 1);
+
+ else if (c.localName.equals("base64"))
+ objects.setElementAt(new Res.ByteArray(Base64.decode(new String(content.getBuf(), 0, content.size()))), objects.size() - 1);
+
+ else if (c.localName.equals("name"))
+ objects.addElement(new String(content.getBuf(), 0, content.size()));
+
+ else if (c.localName.equals("value") && "".equals(objects.lastElement()))
+ objects.setElementAt(new String(content.getBuf(), 0, content.size()), objects.size() - 1);
+
+ else if (c.localName.equals("dateTime.iso8601")) {
+ String s = new String(content.getBuf(), 0, content.size());
+
+ // strip whitespace
+ int i=0;
+ while(Character.isWhitespace(s.charAt(i))) i++;
+ if (i > 0) s = s.substring(i);
+
+ try {
+ org.xwt.js.Date nd = new org.xwt.js.Date();
+ double date = org.xwt.js.Date.date_msecFromDate(Double.valueOf(s.substring(0, 4)).doubleValue(),
+ Double.valueOf(s.substring(4, 6)).doubleValue() - 1,
+ Double.valueOf(s.substring(6, 8)).doubleValue(),
+ Double.valueOf(s.substring(9, 11)).doubleValue(),
+ Double.valueOf(s.substring(12, 14)).doubleValue(),
+ Double.valueOf(s.substring(15, 17)).doubleValue(),
+ (double)0
+ );
+ nd.jsFunction_setTime(org.xwt.js.Date.internalUTC(date));
+ objects.setElementAt(nd, objects.size() - 1);
+
+ } catch (Exception e) {
+ if (Log.on) Log.log(this, "error parsing date : " + s);
+ if (Log.on) Log.log(this, e);
+ }
+
+ } else if (c.localName.equals("member")) {
+ Object memberValue = objects.elementAt(objects.size() - 1);
+ String memberName = (String)objects.elementAt(objects.size() - 2);
+ JS struct = (JS)objects.elementAt(objects.size() - 3);
+ struct.put(memberName, memberValue);
+ objects.setSize(objects.size() - 2);
+
+ } else if (c.localName.equals("data")) {
+ int i;
+ for(i=objects.size() - 1; objects.elementAt(i) != null; i--);
+ JS.Array arr = new JS.Array();
+ for(int j = i + 1; j<objects.size(); j++) arr.put(new Integer(j - i - 1), objects.elementAt(j));
+ objects.setElementAt(arr, i);
+ objects.setSize(i + 1);
+