Examples of JSONString


Examples of com.google.gwt.json.client.JSONString

        int initSize = knownMarkers.size();
        List<String> markersFromThisUpdate = new ArrayList<String>();

        for (int i = 0; i < array.size(); i++) {
          JSONObject jsMarker;
          JSONString jsMID, jsTitle, jsIcon;
          JSONNumber jsLat, jsLng;
          JSONBoolean jsVisible, jsHasInfo, jsDraggable;
          Marker marker = null;
          boolean isOldMarker = false;
          boolean replaceMarker = false;

          if ((jsMarker = array.get(i).isObject()) == null) {
            continue;
          }

          // Read marker id
          if ((value = jsMarker.get("mid")) == null) {
            continue;
          }
          if ((jsMID = value.isString()) == null) {
            continue;
          }

          if ((value = jsMarker.get("draggable")) == null) {
            continue;
          } else {
            if (knownMarkers.containsKey(jsMID.toString())) {
              marker = knownMarkers.get(jsMID.toString());
              marker.setDraggingEnabled((((JSONBoolean) jsMarker
                  .get("draggable")).booleanValue()));
              isOldMarker = true;
            }
          }

          // Add maker to list of markers in this update
          markersFromThisUpdate.add(jsMID.toString());

          // Read marker latitude
          if ((value = jsMarker.get("lat")) == null) {
            if (!isOldMarker)
              continue;
          }
          if ((jsLat = value.isNumber()) == null) {
            if (!isOldMarker)
              continue;
          }

          // Read marker longitude
          if ((value = jsMarker.get("lng")) == null) {
            if (!isOldMarker)
              continue;
          }
          if ((jsLng = value.isNumber()) == null) {
            if (!isOldMarker)
              continue;
          } else {
            // marker.setLatLng(jsLng.doubleValue());
          }

          // Read marker title
          if ((value = jsMarker.get("title")) == null) {
            if (!isOldMarker)
              continue;
          }
          if ((jsTitle = value.isString()) == null) {
            if (!isOldMarker)
              continue;
          } else {
            if (isOldMarker && marker != null) {
              String title = marker.getTitle();

              // if title is changed
              if (!jsTitle.stringValue().equals(title)) {
                replaceMarker = true;
                log(1, "Title changed: " + marker.getTitle());
              }
            }
          }

          // Read marker visibility
          if ((value = jsMarker.get("visible")) == null) {
            if (!isOldMarker)
              continue;
          }
          if ((jsVisible = value.isBoolean()) == null) {
            if (!isOldMarker)
              continue;
          } else {
            if (marker != null) {
              boolean old = marker.isVisible();

              marker.setVisible(jsVisible.booleanValue());

              if (old != marker.isVisible()) {
                log(1,
                    "Toggled marker '" + marker.getTitle()
                        + "' visibility to "
                        + jsVisible.booleanValue());
              }
            }
          }

          // Read marker draggability (is that a word? :)
          if ((value = jsMarker.get("draggable")) == null) {
            if (!isOldMarker)
              continue;
          }

          if ((jsDraggable = value.isBoolean()) == null) {
            if (!isOldMarker)
              continue;
          }

          // Change position, if changed
          if (marker != null && jsLat != null && jsLng != null
              && marker.getLatLng() != null) {
            LatLng llang = marker.getLatLng();

            LatLng llang2 = LatLng.newInstance(jsLat.doubleValue(),
                jsLng.doubleValue());
            if (!llang.isEquals(llang2)) {
              marker.setLatLng(llang2);
            }
          }

          // Read marker icon
          if ((value = jsMarker.get("icon")) == null) {
            jsIcon = null;
            if (marker != null) {
              String currentURL = getMarkerIconURL(marker);
              if (!currentURL
                  .startsWith("http://maps.gstatic.com")
                  && currentURL != null && currentURL != "") {
                replaceMarker = true;
                log(1, "Icon url changed " + marker.getTitle()
                    + " from '" + currentURL + "'");
              }
            }
          } else if ((jsIcon = value.isString()) == null) {
            if (!isOldMarker)
              continue;
          } else {
            if (marker != null
                && getMarkerIconURL(marker) != jsIcon
                    .toString()) {
              replaceMarker = true;
              log(1, "Icon url changed 2 " + marker.getTitle());
            }
          }

          int iconAnchorX = 0;
          if ((value = jsMarker.get("iconAnchorX")) != null) {
            JSONNumber jsAnchorX;
            if ((jsAnchorX = value.isNumber()) != null) {
              log(1, "Anchor X: " + jsAnchorX.toString());
              iconAnchorX = (int) Math.round(jsAnchorX
                  .doubleValue());
            } else {
              log(1, "Anchor X NaN");
            }
          }

          int iconAnchorY = 0;
          if ((value = jsMarker.get("iconAnchorY")) != null) {
            JSONNumber jsAnchorY;
            if ((jsAnchorY = value.isNumber()) != null) {
              iconAnchorY = (int) Math.round(jsAnchorY
                  .doubleValue());
            }
          }

          // do not create new one if old found (only if we want to
          // replace it)
          if (isOldMarker && !replaceMarker)
            continue;

          if (!isOldMarker)
            replaceMarker = false; // Never replace a marker if
                        // there is no previous one

          if (replaceMarker) {
            log(1, "Replacing marker " + marker.getTitle());
            map.removeOverlay(marker);
            markersFromThisUpdate.remove(marker);
          }

          marker = createMarker(jsLat, jsLng, jsTitle, jsVisible,
              jsIcon, iconAnchorX, iconAnchorY, jsDraggable);

          if (marker != null) {
            map.addOverlay(marker);

            // Add dragEnd handlers to marker
            marker.addMarkerDragEndHandler(VGoogleMap.this);

            // Read boolean telling if marker has a info window
            if ((value = jsMarker.get("info")) != null) {
              if ((jsHasInfo = value.isBoolean()) != null
                  && jsHasInfo.booleanValue()) {
                marker.addMarkerClickHandler(new InfoWindowOpener(
                    jsMID.stringValue()));

              }
            }

            knownMarkers.put(jsMID.toString(), marker);
          }
        }

        int newMarkers = knownMarkers.size() - initSize;
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

  protected static JSONObject encodeMap(Map<String, Object> data) {
    JSONObject jsobj = new JSONObject();
    for (String key : data.keySet()) {
      Object val = data.get(key);
      if (val instanceof String) {
        jsobj.put(key, new JSONString(encodeValue(val)));
      } else if (val instanceof Date) {
        jsobj.put(key, new JSONString(encodeValue(val)));
      } else if (val instanceof Number) {
        jsobj.put(key, new JSONString(encodeValue(val)));
      } else if (val instanceof Boolean) {
        jsobj.put(key, JSONBoolean.getInstance((Boolean) val));
      } else if (val == null) {
        jsobj.put(key, JSONNull.getInstance());
      } else if (val instanceof Map) {
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

      } else if (val instanceof Map) {
        jsona.set(i, encodeMap((Map<String, Object>) val));
      } else if (val instanceof List) {
        jsona.set(i, encodeList((List<Object>) val));
      } else if (val instanceof String) {
        jsona.set(i, new JSONString(encodeValue(val)));
      } else if (val instanceof Number) {
        jsona.set(i, new JSONString(encodeValue(val)));
      } else if (val instanceof Boolean) {
        jsona.set(i, JSONBoolean.getInstance((Boolean) val));
      } else if (val == null) {
        jsona.set(i, JSONNull.getInstance());
      } else if (val instanceof Date) {
        jsona.set(i, new JSONString(encodeValue(val)));
      }
    }
    return jsona;
  }
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

        "//0" + GADGET_SERVER + "/gadgets/ifr?url=http://test.com/gadget.xml&view=canvas";
    JSONObject canvasViewData = new JSONObject();
    JSONObject viewData = new JSONObject();
    viewData.put(VIEW_NAME, canvasViewData);
    JSONObject jsonData = new JSONObject();
    jsonData.put("iframeUrl", new JSONString(iFrameUrl));
    jsonData.put("views", viewData);
    jsonData.put("url", new JSONString(xmlSource));
    jsonData.put("userPrefs", new JSONObject());
    return new GadgetMetadata(jsonData);
  }
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

   * @return the string object extracted from JSON (can be null if the value
   *         does not exist or is invalid.
   */
  private static String getJsonStringValue(JSONObject json, String key) {
    JSONValue value = json.get(key);
    JSONString string = (value == null) ? null : value.isString();
    if (string != null) {
      return string.stringValue();
    } else {
      return null;
    }
  }
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

    JSONObject request = new JSONObject();
    JSONObject requestContext = new JSONObject();
    JSONArray gadgets = new JSONArray();
    JSONObject gadget = new JSONObject();
    try {
      gadget.put("url", new JSONString(gadgetSpecUrl));
      gadgets.set(0, gadget);
      requestContext.put("container", new JSONString("wave"));
      request.put("context", requestContext);
      request.put("gadgets", gadgets);
      RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, GADGET_METADATA_PATH);
      builder.sendRequest(request.toString(), new RequestCallback() {
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

   * @see #toJson()
   * @return a JSON object that represents this key. Never null.
   */
  public JSONObject toJsonObject() {
    JSONObject keyJson = new JSONObject();
    keyJson.put("entityType", new JSONString(entityType.getJavaType().getName()));
    keyJson.put("id", JsonUtil.basicValueToJson(id));
    return keyJson;
  }
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

    public static void changeBehavior(String object, String behavior, String value) {
        String text = createXMLCommand(object, behavior, value);
        if (cb.isConnected()) {
            String queue = "/queue/app.events.sensors.behavior.request.objects";
            JSONObject header = new JSONObject();
            header.put("transformation", new JSONString("jms-object-xml"));
            //Message msg = Message.create(text);         
            sc.send(queue, text, header.getJavaScriptObject());
        } else {
            GWT.log("no conected");
        }
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

    public void subscribe() {
        String q = "/topic/VirtualTopic.app.event.sensor.object.behavior.change";
        //String q= "/queue/test";   
        if (q != null) {
            JSONObject header = new JSONObject();
            header.put("transformation", new JSONString("jms-object-xml"));
            sc.subscribe(q, new ACStompListener(sc), header.getJavaScriptObject());
            //sc.subscribe(q, new ACStompListener(sc));
            GWT.log("subscribed to queue " + q);
            //Window.alert("subscribed to queue " + q);
View Full Code Here

Examples of com.google.gwt.json.client.JSONString

    String text = createXMLCommand(object, behavior, value);       
    if (cb.isConnected())
    { 
      String queue = "/queue/app.events.sensors.behavior.request.objects";
      JSONObject header = new JSONObject();
      header.put("transformation", new JSONString("jms-object-xml"));           
      //Message msg = Message.create(text);         
      sc.send(queue, text,header.getJavaScriptObject());       
    }
    else
    {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.