summaryrefslogtreecommitdiffstats
path: root/client-compiler/src/com/vaadin/tools/CvalChecker.java
diff options
context:
space:
mode:
Diffstat (limited to 'client-compiler/src/com/vaadin/tools/CvalChecker.java')
-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;
}
}
ption> Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/package.json
blob: 884a4ee929226a2c4c2e97f29ad9fa89ee25c71a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139