diff options
author | Taras Hupalo <taras.hupalo@gmail.com> | 2014-08-12 15:28:41 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2014-08-26 09:51:15 +0000 |
commit | f2551a9fc03636deb5fcd3f30c761dca946c8341 (patch) | |
tree | b59bc2c5ea1f7471dec4ef59826614b4f6d0adbf /client-compiler | |
parent | c8d58261954de18ef67eaf9043bd93360202cf06 (diff) | |
download | vaadin-framework-f2551a9fc03636deb5fcd3f30c761dca946c8341.tar.gz vaadin-framework-f2551a9fc03636deb5fcd3f30c761dca946c8341.zip |
replaced all org.json.* usages with elemental.json.* (#8942)
Change-Id: I4809fbbdb48f3e36c8e1da8552ff3fa734714105
Diffstat (limited to 'client-compiler')
-rw-r--r-- | client-compiler/src/com/vaadin/tools/CvalChecker.java | 43 |
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; } } |