From 9e5e82cde20e1c102be7d1239b5d62b7bed43a16 Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 16 Sep 2011 14:24:22 +0000 Subject: [PATCH] Check if object is number in numbet getters --- .../google/gwt/query/client/Properties.java | 1 - .../google/gwt/query/client/js/JsCache.java | 22 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java index d9879488..04f6c370 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/Properties.java @@ -31,7 +31,6 @@ public class Properties extends JavaScriptObject { public static Properties create(String properties) { if (properties != null && !properties.isEmpty()) { String p = camelizePropertiesKeys(wrapPropertiesString(properties)); - System.out.println(p); try { return (Properties) createImpl(p); } catch (Exception e) { diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java index f42f3e07..afc62dd2 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/js/JsCache.java @@ -36,7 +36,8 @@ public class JsCache extends JavaScriptObject { }-*/; public final native R get(T id) /*-{ - return this[id] || null; + var r = this[id], t = typeof r; + return r && t != 'number' && t != 'boolean' ? r : null; }-*/; public final JsCache getCache(int id) { @@ -46,18 +47,19 @@ public class JsCache extends JavaScriptObject { public final native boolean getBoolean(T id) /*-{ return !!this[id]; }-*/; - - public final native float getFloat(T id) /*-{ - return this[id] || 0; - }-*/; + + public final float getFloat(T id) { + return (float)getDouble(id); + } public final native double getDouble(T id) /*-{ - return this[id] || 0; + var r = this[id]; + return r && (typeof r == 'number') ? r : 0; }-*/; - public final native int getInt(T id) /*-{ - return this[id] || 0; - }-*/; + public final int getInt(T id) { + return (int)getDouble(id); + } public final native String getString(T id) /*-{ return this[id] == null ? null : String(this[id]); @@ -65,7 +67,7 @@ public class JsCache extends JavaScriptObject { public final native JsArrayMixed getArray(T id) /*-{ var r = this[id]; - if (r != null && Object.prototype.toString.call(r) == '[object Array]') { + if (r && Object.prototype.toString.call(r) == '[object Array]') { return r; } return null; -- 2.39.5