Package org.sgx.gwtjavatools.overlay.model

Examples of org.sgx.gwtjavatools.overlay.model.JsValue


//  typesUtil = new JsTypes();
//}
 
public JsValue build(Object o) throws JSONException {
  String type = JsTypes.getInstance().typeOf(o);
  JsValue t = new JsValue(type);
 
  //primitives
  if(type.equals(JsTypes.TYPE_BOOLEAN) ||
      type.equals(JsTypes.TYPE_STRING) ||
      type.equals(JsTypes.TYPE_NUMBER)) {
   
    t.setValue(o);
  }
 
  else if(type.equals(JsTypes.TYPE_ARRAY)) {
    List<JsValue> values = new LinkedList<JsValue>();
    JSONArray arr = (org.json.JSONArray)o;
    for (int i = 0; i < arr.length(); i++) {
      Object itemJsonVal = arr.get(i);
      JsValue itemJsValue = build(itemJsonVal);
      values.add(itemJsValue);
    }
    t.setValues(values);
  }
 
  else if(type.equals(JsTypes.TYPE_OBJECT)) {
    Map<String, JsValue> properties = new HashMap<String, JsValue>();
    t.setProperties(properties);
    JSONObject propJsObj = (JSONObject)o;
    Iterator it = propJsObj.keys();
    while (it.hasNext()) {
      String propName = (String) it.next();
      Object propVal = propJsObj.get(propName);
      JsValue propJsValue = build(propVal);
      properties.put(propName, propJsValue);
    }
  }
 
 
View Full Code Here


    OverlayRenderer renderer = new OverlayRenderer();
   
    String json1 = "{obj1: {name: 'foo'}, arr1: [1,2,3], str1: 'hello', int1: 1234}";
    JsValueBuilder jsValueBuilder = new JsValueBuilder();
    JsValue jsval = jsValueBuilder.build(new JSONObject(json1)); // new JsValue(JsTypes.TYPE_OBJECT);
   
   
    JavaClassInfo ci = new JavaClassInfo("MyFirstClass1", "org.sgx.ppp");
   
   
View Full Code Here

TOP

Related Classes of org.sgx.gwtjavatools.overlay.model.JsValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.