summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2014-09-03 11:48:47 +0300
committerTeemu Suo-Anttila <teemusa@vaadin.com>2014-09-03 15:33:01 +0300
commit927e424acc1e43a12bdbbcd971302d00717af540 (patch)
treea91f0486fb646f6d1de9a4d590e25100347cc7ec /client-compiler
parent600d5b436d7ca33840b1b697082d140a5040bdf3 (diff)
parentf6282cbe0386d03b57a65450bc163b20bfecfb70 (diff)
downloadvaadin-framework-927e424acc1e43a12bdbbcd971302d00717af540.tar.gz
vaadin-framework-927e424acc1e43a12bdbbcd971302d00717af540.zip
Merge remote-tracking branch 'origin/master' into grid
This merge needs Grid to use elemental.json instead of org.json Change-Id: Ib3c387c7e282b2502f266bafbdaad8727f5dc6ef
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/src/com/vaadin/tools/CvalChecker.java43
1 files changed, 18 insertions, 25 deletions
diff --git a/client-compiler/src/com/vaadin/tools/CvalChecker.java b/client-compiler/src/com/vaadin/tools/CvalChecker.java
index e426c5c4e6..c48aa7d9db 100644
--- a/client-compiler/src/com/vaadin/tools/CvalChecker.java
+++ b/client-compiler/src/com/vaadin/tools/CvalChecker.java
@@ -31,9 +31,10 @@ import java.util.Locale;
import java.util.ResourceBundle;
import java.util.prefs.Preferences;
+import elemental.json.JsonException;
+import elemental.json.JsonObject;
+import elemental.json.impl.JsonUtil;
import org.apache.commons.io.IOUtils;
-import org.json.JSONException;
-import org.json.JSONObject;
/**
* This class is able to validate the vaadin CVAL license.
@@ -58,9 +59,9 @@ public final class CvalChecker {
public static class CvalInfo {
public static class Product {
- private JSONObject o;
+ private JsonObject o;
- public Product(JSONObject o) {
+ public Product(JsonObject o) {
this.o = o;
}
@@ -74,40 +75,32 @@ public final class CvalChecker {
}
@SuppressWarnings("unchecked")
- private static <T> T get(JSONObject o, String k, Class<T> clz) {
+ private static <T> T get(JsonObject o, String k, Class<T> clz) {
Object ret = null;
try {
if (clz == String.class) {
ret = o.getString(k);
- } else if (clz == JSONObject.class) {
- ret = o.getJSONObject(k);
+ } else if (clz == JsonObject.class) {
+ ret = o.getObject(k);
} else if (clz == Integer.class) {
- ret = o.getInt(k);
+ ret = Integer.valueOf((int) o.getNumber(k));
} else if (clz == Date.class) {
- ret = new Date(o.getLong(k));
+ ret = new Date((long) o.getNumber(k));
} else if (clz == Boolean.class) {
ret = o.getBoolean(k);
}
- } catch (JSONException e) {
+ } catch (JsonException e) {
}
return (T) ret;
}
- private static <T> T put(JSONObject o, String k, Object v) {
- try {
- o.put(k, v);
- } catch (JSONException e) {
- }
- return null;
- }
-
- private JSONObject o;
+ private JsonObject o;
private Product product;
- public CvalInfo(JSONObject o) {
+ public CvalInfo(JsonObject o) {
this.o = o;
- product = new Product(get(o, "product", JSONObject.class));
+ product = new Product(get(o, "product", JsonObject.class));
}
public Boolean getExpired() {
@@ -139,11 +132,11 @@ public final class CvalChecker {
}
public void setExpiredEpoch(Date expiredEpoch) {
- put(o, "expiredEpoch", expiredEpoch.getTime());
+ o.put("expiredEpoch", expiredEpoch.getTime());
}
public void setMessage(String msg) {
- put(o, "message", msg);
+ o.put("message", msg);
}
@Override
@@ -327,9 +320,9 @@ public final class CvalChecker {
return null;
}
try {
- JSONObject o = new JSONObject(json);
+ JsonObject o = JsonUtil.parse(json);
return new CvalInfo(o);
- } catch (JSONException e) {
+ } catch (JsonException e) {
return null;
}
}