Package com.google.gwt.json.client

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


    }
    else if (value instanceof Boolean) {
      return JSONBoolean.getInstance((Boolean) value);
    }
    else if (value instanceof Number) {
      return new JSONNumber(((Number) value).doubleValue());
    }
    else if (value instanceof Enum) {
      return new JSONString(((Enum<?>) value).name());
    }
    else if (value instanceof Date) {  // covers java.sql.[Date,Time,Timestamp]
View Full Code Here


    else if (v1.isNull() != null) {
      // this case should never be triggered, because of the getClass() precheck above
      return v2.isNull() != null;
    }
    else if (v1.isNumber() != null) {
      JSONNumber n1 = v1.isNumber();
      JSONNumber n2 = v2.isNumber();
      return n1.doubleValue() == n2.doubleValue();
    }
    else if (v1.isObject() != null) {
      JSONObject o1 = v1.isObject();
      JSONObject o2 = v2.isObject();
      if (!o1.keySet().equals(o2.keySet())) {
View Full Code Here

        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
View Full Code Here

   * @return the Long object extracted from JSON (can be null if the value does
   *         not exist or is invalid.
   */
  private static Long getJsonLongValue(JSONObject json, String key) {
    JSONValue value = json.get(key);
    JSONNumber number = (value == null) ? null : value.isNumber();
    if (number != null) {
      return Math.round(number.doubleValue());
    } else {
      return null;
    }
  }
View Full Code Here

        JSONValue value = get( MARGIN_KEY );
        if ( value == null )
        {
            return null;
        }
        JSONNumber number = value.isNumber();
        if ( null != number )
        {
            return new Double[] { number.doubleValue() };
        }
        JSONArray array = value.isArray();
        if ( null != array )
        {
            return new Double[] { array.get( 0 ).isNumber().doubleValue(), array.get( 1 ).isNumber().doubleValue() };
View Full Code Here

        JSONString str = value.isString();
        if ( str != null )
        {
            return str.stringValue();
        }
        JSONNumber number = value.isNumber();
        if ( number != null )
        {
            return new Double( number.doubleValue() ).toString();
        }
        return null;
    }
View Full Code Here

    protected void set( int index, Number value )
    {
        JSONValue val = JSONNull.getInstance();
        if ( value != null )
        {
            val = new JSONNumber( value.doubleValue() );
        }
        set( index, val );
    }
View Full Code Here

    protected void push( Number value )
    {
        JSONValue val = JSONNull.getInstance();
        if ( value != null )
        {
            val = new JSONNumber( value.doubleValue() );
        }
        set( ++m_currentIndex, val );
    }
View Full Code Here

        }
    }

    protected Double getDouble( int index )
    {
        JSONNumber num = getNumber( index );
        return num == null ? null : new Double( num.doubleValue() );
    }
View Full Code Here

        return num == null ? null : new Double( num.doubleValue() );
    }

    protected Integer getInteger( int index )
    {
        JSONNumber num = getNumber( index );
        return num == null ? null : new Integer( (int) num.doubleValue() );
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.json.client.JSONNumber

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.