@regulaforensics/cordova-plugin-document-reader-api 6.5.0 → 6.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,6 @@ import static com.regula.documentreader.api.completions.IRfidNotificationComplet
4
4
 
5
5
  import android.content.Context;
6
6
  import android.graphics.Bitmap;
7
- import android.graphics.BitmapFactory;
8
7
  import android.graphics.Rect;
9
8
  import android.os.Bundle;
10
9
  import android.util.Base64;
@@ -25,18 +24,24 @@ import com.regula.documentreader.api.params.rfid.authorization.TAChallenge;
25
24
  import com.regula.documentreader.api.results.Bounds;
26
25
  import com.regula.documentreader.api.results.BytesData;
27
26
  import com.regula.documentreader.api.results.Coordinate;
27
+ import com.regula.documentreader.api.results.DocReaderDocumentsDatabase;
28
28
  import com.regula.documentreader.api.results.DocReaderFieldRect;
29
29
  import com.regula.documentreader.api.results.DocumentReaderBarcodeField;
30
30
  import com.regula.documentreader.api.results.DocumentReaderBarcodeResult;
31
+ import com.regula.documentreader.api.results.DocumentReaderComparison;
31
32
  import com.regula.documentreader.api.results.DocumentReaderDocumentType;
32
33
  import com.regula.documentreader.api.results.DocumentReaderGraphicField;
33
34
  import com.regula.documentreader.api.results.DocumentReaderGraphicResult;
34
35
  import com.regula.documentreader.api.results.DocumentReaderNotification;
35
36
  import com.regula.documentreader.api.results.DocumentReaderResults;
36
37
  import com.regula.documentreader.api.results.DocumentReaderResultsStatus;
38
+ import com.regula.documentreader.api.results.DocumentReaderRfidOrigin;
37
39
  import com.regula.documentreader.api.results.DocumentReaderScenario;
40
+ import com.regula.documentreader.api.results.DocumentReaderSymbol;
38
41
  import com.regula.documentreader.api.results.DocumentReaderTextField;
39
42
  import com.regula.documentreader.api.results.DocumentReaderTextResult;
43
+ import com.regula.documentreader.api.results.DocumentReaderTextSource;
44
+ import com.regula.documentreader.api.results.DocumentReaderValidity;
40
45
  import com.regula.documentreader.api.results.DocumentReaderValue;
41
46
  import com.regula.documentreader.api.results.ElementPosition;
42
47
  import com.regula.documentreader.api.results.ImageQuality;
@@ -45,7 +50,6 @@ import com.regula.documentreader.api.results.VDSNCData;
45
50
  import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityCheck;
46
51
  import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityElement;
47
52
  import com.regula.documentreader.api.results.authenticity.DocumentReaderAuthenticityResult;
48
- import com.regula.documentreader.api.results.authenticity.DocumentReaderUvFiberElement;
49
53
  import com.regula.documentreader.api.results.rfid.AccessControlProcedureType;
50
54
  import com.regula.documentreader.api.results.rfid.Application;
51
55
  import com.regula.documentreader.api.results.rfid.Attribute;
@@ -67,12 +71,9 @@ import org.json.JSONArray;
67
71
  import org.json.JSONException;
68
72
  import org.json.JSONObject;
69
73
 
70
- import java.io.ByteArrayOutputStream;
71
- import java.util.ArrayList;
72
74
  import java.util.List;
73
75
  import java.util.Map;
74
76
 
75
- @SuppressWarnings({"ConstantConditions", "unused", "RedundantSuppression"})
76
77
  class JSONConstructor {
77
78
  interface JSONObjectGeneratorWithContext<T> {
78
79
  JSONObject generateJSONObject(T param, Context context) throws JSONException;
@@ -82,13 +83,9 @@ class JSONConstructor {
82
83
  JSONObject generateJSONObject(T param) throws JSONException;
83
84
  }
84
85
 
85
- interface StringGenerator<T> {
86
- String generateString(T param);
87
- }
88
-
89
86
  static <T> JSONArray generateList(List<T> list) {
90
87
  JSONArray result = new JSONArray();
91
- if(list == null) return result;
88
+ if (list == null) return result;
92
89
  for (T t : list)
93
90
  if (t != null)
94
91
  result.put(t);
@@ -98,7 +95,7 @@ class JSONConstructor {
98
95
 
99
96
  static <T> JSONArray generateList(List<T> list, JSONObjectGenerator<T> generator) throws JSONException {
100
97
  JSONArray result = new JSONArray();
101
- if(list == null) return result;
98
+ if (list == null) return result;
102
99
  for (T t : list)
103
100
  if (t != null)
104
101
  result.put(generator.generateJSONObject(t));
@@ -106,19 +103,9 @@ class JSONConstructor {
106
103
  return result;
107
104
  }
108
105
 
109
- static <T> JSONArray generateList(List<T> list, StringGenerator<T> generator) {
110
- JSONArray result = new JSONArray();
111
- if(list == null) return result;
112
- for (T t : list)
113
- if (t != null)
114
- result.put(generator.generateString(t));
115
-
116
- return result;
117
- }
118
-
119
106
  static <T> JSONArray generateList(List<T> list, JSONObjectGeneratorWithContext<T> generator, Context context) throws JSONException {
120
107
  JSONArray result = new JSONArray();
121
- if(list == null) return result;
108
+ if (list == null) return result;
122
109
  for (T t : list)
123
110
  if (t != null)
124
111
  result.put(generator.generateJSONObject(t, context));
@@ -128,7 +115,7 @@ class JSONConstructor {
128
115
 
129
116
  static <T> JSONArray generateArray(T[] array) throws JSONException {
130
117
  JSONArray result = new JSONArray();
131
- if(array == null) return result;
118
+ if (array == null) return result;
132
119
  for (int i = 0; i < array.length; i++)
133
120
  result.put(i, array[i]);
134
121
 
@@ -137,97 +124,42 @@ class JSONConstructor {
137
124
 
138
125
  static <T> JSONArray generateArray(T[] array, JSONObjectGenerator<T> generator) throws JSONException {
139
126
  JSONArray result = new JSONArray();
140
- if(array == null) return result;
127
+ if (array == null) return result;
141
128
  for (int i = 0; i < array.length; i++)
142
129
  result.put(i, generator.generateJSONObject(array[i]));
143
130
 
144
131
  return result;
145
132
  }
146
133
 
147
- static <T> JSONArray generateArray(T[] array, StringGenerator<T> generator) throws JSONException {
148
- JSONArray result = new JSONArray();
149
- if(array == null) return result;
150
- for (int i = 0; i < array.length; i++)
151
- result.put(i, generator.generateString(array[i]));
152
-
153
- return result;
154
- }
155
-
156
- static <T> JSONArray generateArray(T[] array, JSONObjectGeneratorWithContext<T> generator, Context context) throws JSONException {
157
- JSONArray result = new JSONArray();
158
- if(array == null) return result;
159
- for (int i = 0; i < array.length; i++)
160
- result.put(i, generator.generateJSONObject(array[i], context));
161
-
162
- return result;
163
- }
164
-
165
134
  static <T, V> JSONObject generateMap(Map<T, V> map) throws JSONException {
166
135
  JSONObject result = new JSONObject();
167
- if(map == null) return result;
136
+ if (map == null) return result;
168
137
  for (Map.Entry<T, V> entry : map.entrySet())
169
138
  if (entry != null)
170
139
  result.put(entry.getKey().toString(), entry.getValue());
171
140
  return result;
172
141
  }
173
142
 
174
- static <T, V> JSONObject generateMap(Map<T, V> map, JSONObjectGenerator<V> generator) throws JSONException {
175
- JSONObject result = new JSONObject();
176
- if(map == null) return result;
177
- for (Map.Entry<T, V> entry : map.entrySet())
178
- if (entry != null)
179
- result.put(entry.getKey().toString(), generator.generateJSONObject(entry.getValue()));
180
- return result;
181
- }
182
-
183
- static <T, V> JSONObject generateMap(Map<T, V> map, StringGenerator<V> generator) throws JSONException {
184
- JSONObject result = new JSONObject();
185
- if(map == null) return result;
186
- for (Map.Entry<T, V> entry : map.entrySet())
187
- if (entry != null)
188
- result.put(entry.getKey().toString(), generator.generateString(entry.getValue()));
189
- return result;
190
- }
191
-
192
- static <T, V> JSONObject generateMap(Map<T, V> map, JSONObjectGeneratorWithContext<V> generator, Context context) throws JSONException {
193
- JSONObject result = new JSONObject();
194
- if(map == null) return result;
195
- for (Map.Entry<T, V> entry : map.entrySet())
196
- if (entry != null)
197
- result.put(entry.getKey().toString(), generator.generateJSONObject(entry.getValue(), context));
198
- return result;
199
- }
200
-
201
143
  static JSONArray generateIntArray(int[] array) throws JSONException {
202
144
  JSONArray result = new JSONArray();
203
- if(array == null) return result;
204
- for (int i = 0; i < array.length; i++)
205
- result.put(i, array[i]);
206
-
207
- return result;
208
- }
209
-
210
- static JSONArray generateBooleanArray(boolean[] array) throws JSONException {
211
- JSONArray result = new JSONArray();
212
- if(array == null) return result;
145
+ if (array == null) return result;
213
146
  for (int i = 0; i < array.length; i++)
214
147
  result.put(i, array[i]);
215
148
 
216
149
  return result;
217
150
  }
218
151
 
219
- static JSONArray generateDoubleArray(double[] array) throws JSONException {
220
- JSONArray result = new JSONArray();
221
- if(array == null) return result;
222
- for (int i = 0; i < array.length; i++)
223
- result.put(i, array[i]);
152
+ static int[] intArrayFromJSON(JSONArray input) throws JSONException {
153
+ int[] result = new int[input.length()];
154
+ for (int i = 0; i < input.length(); i++)
155
+ result[i] = input.getInt(i);
224
156
 
225
157
  return result;
226
158
  }
227
159
 
228
160
  static JSONArray generateByteArray(byte[] array) throws JSONException {
229
161
  JSONArray result = new JSONArray();
230
- if(array == null) return result;
162
+ if (array == null) return result;
231
163
  for (int i = 0; i < array.length; i++)
232
164
  result.put(i, array[i]);
233
165
 
@@ -236,33 +168,13 @@ class JSONConstructor {
236
168
 
237
169
  static JSONArray generateLongArray(long[] array) throws JSONException {
238
170
  JSONArray result = new JSONArray();
239
- if(array == null) return result;
171
+ if (array == null) return result;
240
172
  for (int i = 0; i < array.length; i++)
241
173
  result.put(i, array[i]);
242
174
 
243
175
  return result;
244
176
  }
245
177
 
246
- static String generateBitmap(Bitmap bitmap) {
247
- if (bitmap == null) return "";
248
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
249
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream);
250
- byte[] byteArray = byteArrayOutputStream.toByteArray();
251
-
252
- return Base64.encodeToString(byteArray, Base64.DEFAULT);
253
- }
254
-
255
- static Bitmap BitmapFromJSON(String base64) {
256
- byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
257
- BitmapFactory.Options options = new BitmapFactory.Options();
258
- options.inPreferredConfig = Bitmap.Config.RGB_565;
259
- Bitmap result = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length, options);
260
- int sizeMultiplier = result.getByteCount() / 5000000;
261
- if (result.getByteCount() > 5000000)
262
- result = Bitmap.createScaledBitmap(result, result.getWidth() / (int) Math.sqrt(sizeMultiplier), result.getHeight() / (int) Math.sqrt(sizeMultiplier), false);
263
- return result;
264
- }
265
-
266
178
  static JSONObject generateVideoEncoderCompletion(String sessionId, java.io.File file) {
267
179
  JSONObject result = new JSONObject();
268
180
 
@@ -307,8 +219,8 @@ class JSONConstructor {
307
219
  JSONObject result = new JSONObject();
308
220
  try {
309
221
  result.put("notification", notification);
310
- if(value != null)
311
- result.put("value", value.get(RFID_EXTRA_ERROR_CODE));
222
+ if (value != null)
223
+ result.put("value", value.get(RFID_EXTRA_ERROR_CODE));
312
224
  } catch (JSONException ignored) {
313
225
  }
314
226
 
@@ -332,16 +244,6 @@ class JSONConstructor {
332
244
  return new JSONObject();
333
245
  }
334
246
 
335
- static DocumentReaderNotification DocumentReaderNotificationFromJSON(JSONObject jsonObject) {
336
- DocumentReaderNotification result = new DocumentReaderNotification();
337
- try {
338
- if (jsonObject.has("value"))
339
- result.value = jsonObject.getInt("value");
340
- } catch (JSONException ignored) {
341
- }
342
- return result;
343
- }
344
-
345
247
  static TccParams TCCParamsFromJSON(JSONObject input) {
346
248
  TccParams result = new TccParams();
347
249
  try {
@@ -362,13 +264,13 @@ class JSONConstructor {
362
264
  }
363
265
 
364
266
  static DocReaderConfig DocReaderConfigFromJSON(JSONObject input) {
365
- DocReaderConfig result = new DocReaderConfig(null);
267
+ DocReaderConfig result;
366
268
  byte[] license;
367
269
  try {
368
270
  if (input.has("license")) {
369
271
  license = Base64.decode(input.getString("license"), Base64.DEFAULT);
370
272
  result = new DocReaderConfig(license);
371
- } else return result;
273
+ } else return null;
372
274
  if (input.has("customDb"))
373
275
  result = new DocReaderConfig(license, Base64.decode(input.getString("customDb"), Base64.DEFAULT));
374
276
  if (input.has("licenseUpdate"))
@@ -377,28 +279,29 @@ class JSONConstructor {
377
279
  result.setDelayedNNLoad(input.getBoolean("delayedNNLoad"));
378
280
  if (input.has("blackList"))
379
281
  result.setBlackList(input.getJSONObject("blackList"));
282
+
283
+ return result;
380
284
  } catch (JSONException e) {
381
285
  e.printStackTrace();
382
286
  }
383
- return result;
287
+ return null;
384
288
  }
385
289
 
386
290
  static ImageInputData ImageInputDataFromJSON(JSONObject input) {
387
- ImageInputData result = new ImageInputData(null);
291
+ ImageInputData result = null;
388
292
  int pageIndex = 0;
389
293
  int light = 6;
390
- int type = 254;
391
294
  int width = 0;
392
295
  int height = 0;
393
296
  Bitmap bitmap;
394
297
  byte[] imgBytes;
395
298
 
396
299
  try {
397
- if(input.has("pageIndex"))
300
+ if (input.has("pageIndex"))
398
301
  pageIndex = input.optInt("pageIndex");
399
- if(input.has("light"))
302
+ if (input.has("light"))
400
303
  pageIndex = input.optInt("light");
401
- if(input.has("type"))
304
+ if (input.has("type"))
402
305
  pageIndex = input.optInt("type");
403
306
  if (input.has("bitmap")) {
404
307
  bitmap = Helpers.bitmapFromBase64(input.getString("bitmap"));
@@ -419,19 +322,11 @@ class JSONConstructor {
419
322
  return result;
420
323
  }
421
324
 
422
- static Throwable ThrowableFromJSON(JSONObject jsonObject) {
423
- return new Throwable();
424
- }
425
-
426
- static StackTraceElement StackTraceElementFromJSON(JSONObject jsonObject) {
427
- return null;
428
- }
429
-
430
325
  // To JSON
431
326
 
432
327
  static JSONObject generateDocumentReaderScenario(DocumentReaderScenario input) {
433
328
  JSONObject result = new JSONObject();
434
- if (input == null) return result;
329
+ if (input == null) return null;
435
330
  try {
436
331
  result.put("name", input.name);
437
332
  result.put("caption", input.caption);
@@ -444,7 +339,7 @@ class JSONConstructor {
444
339
 
445
340
  static JSONObject generateCoreDetailedScenario(CoreDetailedScenario input) {
446
341
  JSONObject result = new JSONObject();
447
- if (input == null) return result;
342
+ if (input == null) return null;
448
343
  try {
449
344
  result.put("uvTorch", input.uvTorch);
450
345
  result.put("frameOrientation", input.frameOrientation);
@@ -467,7 +362,7 @@ class JSONConstructor {
467
362
 
468
363
  static JSONObject generateFaceMetaData(FaceMetaData input) {
469
364
  JSONObject result = new JSONObject();
470
- if (input == null) return result;
365
+ if (input == null) return null;
471
366
  try {
472
367
  result.put("ID", input.ID);
473
368
  result.put("rollAngle", input.rollAngle);
@@ -480,7 +375,7 @@ class JSONConstructor {
480
375
 
481
376
  static JSONObject generateBounds(Bounds input) {
482
377
  JSONObject result = new JSONObject();
483
- if (input == null) return result;
378
+ if (input == null) return null;
484
379
  try {
485
380
  result.put("x", input.x);
486
381
  result.put("y", input.y);
@@ -494,7 +389,7 @@ class JSONConstructor {
494
389
 
495
390
  static JSONObject generateRect(Rect input) {
496
391
  JSONObject result = new JSONObject();
497
- if (input == null) return result;
392
+ if (input == null) return null;
498
393
  try {
499
394
  result.put("bottom", input.bottom);
500
395
  result.put("top", input.top);
@@ -508,7 +403,7 @@ class JSONConstructor {
508
403
 
509
404
  static JSONObject generateDocReaderFieldRect(DocReaderFieldRect input) {
510
405
  JSONObject result = new JSONObject();
511
- if (input == null) return result;
406
+ if (input == null) return null;
512
407
  try {
513
408
  result.put("bottom", input.bottom);
514
409
  result.put("top", input.top);
@@ -522,7 +417,7 @@ class JSONConstructor {
522
417
 
523
418
  static JSONObject generateDocumentReaderGraphicField(DocumentReaderGraphicField input, Context context) {
524
419
  JSONObject result = new JSONObject();
525
- if (input == null) return result;
420
+ if (input == null) return null;
526
421
  try {
527
422
  result.put("sourceType", input.sourceType);
528
423
  result.put("fieldType", input.fieldType);
@@ -540,7 +435,7 @@ class JSONConstructor {
540
435
 
541
436
  static JSONObject generateDocumentReaderGraphicResult(DocumentReaderGraphicResult input, Context context) {
542
437
  JSONObject result = new JSONObject();
543
- if (input == null) return result;
438
+ if (input == null) return null;
544
439
  try {
545
440
  result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderGraphicField, context));
546
441
  } catch (JSONException e) {
@@ -549,9 +444,9 @@ class JSONConstructor {
549
444
  return result;
550
445
  }
551
446
 
552
- static JSONObject generateDocumentReaderValue(DocumentReaderValue input) {
447
+ static JSONObject generateDocumentReaderValue(DocumentReaderValue input, Context context) {
553
448
  JSONObject result = new JSONObject();
554
- if (input == null) return result;
449
+ if (input == null) return null;
555
450
  try {
556
451
  result.put("pageIndex", input.pageIndex);
557
452
  result.put("sourceType", input.sourceType);
@@ -561,6 +456,8 @@ class JSONConstructor {
561
456
  result.put("originalValue", input.originalValue);
562
457
  result.put("boundRect", generateRect(input.boundRect));
563
458
  result.put("comparison", generateMap(input.comparison));
459
+ result.put("originalSymbols", generateList(input.originalSymbols, JSONConstructor::generateDocumentReaderSymbol));
460
+ result.put("rfidOrigin", generateDocumentReaderRfidOrigin(input.rfidOrigin));
564
461
  } catch (JSONException e) {
565
462
  e.printStackTrace();
566
463
  }
@@ -569,15 +466,18 @@ class JSONConstructor {
569
466
 
570
467
  static JSONObject generateDocumentReaderTextField(DocumentReaderTextField input, Context context) {
571
468
  JSONObject result = new JSONObject();
572
- if (input == null) return result;
469
+ if (input == null) return null;
573
470
  try {
574
471
  result.put("fieldType", input.fieldType);
575
472
  result.put("lcid", input.lcid);
576
473
  result.put("status", input.status);
577
474
  result.put("lcidName", input.getLcidName(context));
578
475
  result.put("fieldName", input.getFieldName(context));
579
- result.put("value", generateDocumentReaderValue(input.value()));
580
- result.put("values", generateList(input.values, JSONConstructor::generateDocumentReaderValue));
476
+ result.put("value", input.value);
477
+ result.put("getValue", generateDocumentReaderValue(input.value(), context));
478
+ result.put("values", generateList(input.values, JSONConstructor::generateDocumentReaderValue, context));
479
+ result.put("comparisonList", generateList(input.comparisonList, JSONConstructor::generateDocumentReaderComparison));
480
+ result.put("validityList", generateList(input.validityList, JSONConstructor::generateDocumentReaderValidity));
581
481
  } catch (JSONException e) {
582
482
  e.printStackTrace();
583
483
  }
@@ -586,9 +486,12 @@ class JSONConstructor {
586
486
 
587
487
  static JSONObject generateDocumentReaderTextResult(DocumentReaderTextResult input, Context context) {
588
488
  JSONObject result = new JSONObject();
589
- if (input == null) return result;
489
+ if (input == null) return null;
590
490
  try {
591
491
  result.put("status", input.status);
492
+ result.put("comparisonStatus", input.comparisonStatus);
493
+ result.put("validityStatus", input.validityStatus);
494
+ result.put("availableSourceList", generateList(input.availableSourceList, JSONConstructor::generateDocumentReaderTextSource));
592
495
  result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderTextField, context));
593
496
  } catch (JSONException e) {
594
497
  e.printStackTrace();
@@ -598,7 +501,7 @@ class JSONConstructor {
598
501
 
599
502
  static JSONObject generateCoordinate(Coordinate input) {
600
503
  JSONObject result = new JSONObject();
601
- if (input == null) return result;
504
+ if (input == null) return null;
602
505
  try {
603
506
  result.put("x", input.x);
604
507
  result.put("y", input.y);
@@ -610,7 +513,7 @@ class JSONConstructor {
610
513
 
611
514
  static JSONObject generateElementPosition(ElementPosition input) {
612
515
  JSONObject result = new JSONObject();
613
- if (input == null) return result;
516
+ if (input == null) return null;
614
517
  try {
615
518
  result.put("docFormat", input.docFormat);
616
519
  result.put("width", input.width);
@@ -636,7 +539,7 @@ class JSONConstructor {
636
539
 
637
540
  static JSONObject generateImageQuality(ImageQuality input) {
638
541
  JSONObject result = new JSONObject();
639
- if (input == null) return result;
542
+ if (input == null) return null;
640
543
  try {
641
544
  result.put("featureType", input.featureType);
642
545
  result.put("result", input.result);
@@ -649,7 +552,7 @@ class JSONConstructor {
649
552
 
650
553
  static JSONObject generateImageQualityGroup(ImageQualityGroup input) {
651
554
  JSONObject result = new JSONObject();
652
- if (input == null) return result;
555
+ if (input == null) return null;
653
556
  try {
654
557
  result.put("count", input.count);
655
558
  result.put("result", input.result);
@@ -663,7 +566,7 @@ class JSONConstructor {
663
566
 
664
567
  static JSONObject generateDocumentReaderDocumentType(DocumentReaderDocumentType input) {
665
568
  JSONObject result = new JSONObject();
666
- if (input == null) return result;
569
+ if (input == null) return null;
667
570
  try {
668
571
  result.put("pageIndex", input.pageIndex);
669
572
  result.put("documentID", input.documentID);
@@ -684,7 +587,7 @@ class JSONConstructor {
684
587
 
685
588
  static JSONObject generateDocumentReaderNotification(DocumentReaderNotification input) {
686
589
  JSONObject result = new JSONObject();
687
- if (input == null) return result;
590
+ if (input == null) return null;
688
591
  try {
689
592
  result.put("code", input.getNotificationCode());
690
593
  result.put("attachment", input.getDataFileType());
@@ -697,7 +600,7 @@ class JSONConstructor {
697
600
 
698
601
  static JSONObject generateAccessControlProcedureType(AccessControlProcedureType input) {
699
602
  JSONObject result = new JSONObject();
700
- if (input == null) return result;
603
+ if (input == null) return null;
701
604
  try {
702
605
  result.put("activeOptionIdx", input.activeOptionIdx);
703
606
  result.put("type", input.type);
@@ -711,7 +614,7 @@ class JSONConstructor {
711
614
 
712
615
  static JSONObject generateFileData(FileData input) {
713
616
  JSONObject result = new JSONObject();
714
- if (input == null) return result;
617
+ if (input == null) return null;
715
618
  try {
716
619
  result.put("length", input.length);
717
620
  result.put("type", input.type);
@@ -725,7 +628,7 @@ class JSONConstructor {
725
628
 
726
629
  static JSONObject generateCertificateData(CertificateData input) {
727
630
  JSONObject result = new JSONObject();
728
- if (input == null) return result;
631
+ if (input == null) return null;
729
632
  try {
730
633
  result.put("length", input.length);
731
634
  result.put("data", input.data);
@@ -737,7 +640,7 @@ class JSONConstructor {
737
640
 
738
641
  static JSONObject generateSecurityObjectCertificates(SecurityObjectCertificates input) {
739
642
  JSONObject result = new JSONObject();
740
- if (input == null) return result;
643
+ if (input == null) return null;
741
644
  try {
742
645
  result.put("securityObject", generateCertificateData(input.securityObject));
743
646
  } catch (JSONException e) {
@@ -748,7 +651,7 @@ class JSONConstructor {
748
651
 
749
652
  static JSONObject generateFile(File input) {
750
653
  JSONObject result = new JSONObject();
751
- if (input == null) return result;
654
+ if (input == null) return null;
752
655
  try {
753
656
  result.put("readingTime", input.readingTime);
754
657
  result.put("type", input.type);
@@ -769,7 +672,7 @@ class JSONConstructor {
769
672
 
770
673
  static JSONObject generateApplication(Application input) {
771
674
  JSONObject result = new JSONObject();
772
- if (input == null) return result;
675
+ if (input == null) return null;
773
676
  try {
774
677
  result.put("type", input.type);
775
678
  result.put("status", input.status);
@@ -786,7 +689,7 @@ class JSONConstructor {
786
689
 
787
690
  static JSONObject generateValue(Value input) {
788
691
  JSONObject result = new JSONObject();
789
- if (input == null) return result;
692
+ if (input == null) return null;
790
693
  try {
791
694
  result.put("length", input.length);
792
695
  result.put("type", input.type);
@@ -801,7 +704,7 @@ class JSONConstructor {
801
704
 
802
705
  static JSONObject generateAttribute(Attribute input) {
803
706
  JSONObject result = new JSONObject();
804
- if (input == null) return result;
707
+ if (input == null) return null;
805
708
  try {
806
709
  result.put("type", input.type);
807
710
  result.put("value", generateValue(input.value));
@@ -813,7 +716,7 @@ class JSONConstructor {
813
716
 
814
717
  static JSONObject generateAuthority(Authority input) {
815
718
  JSONObject result = new JSONObject();
816
- if (input == null) return result;
719
+ if (input == null) return null;
817
720
  try {
818
721
  result.put("data", input.data);
819
722
  result.put("friendlyName", generateValue(input.friendlyName));
@@ -826,7 +729,7 @@ class JSONConstructor {
826
729
 
827
730
  static JSONObject generateExtension(Extension input) {
828
731
  JSONObject result = new JSONObject();
829
- if (input == null) return result;
732
+ if (input == null) return null;
830
733
  try {
831
734
  result.put("data", input.data);
832
735
  result.put("type", input.type);
@@ -838,7 +741,7 @@ class JSONConstructor {
838
741
 
839
742
  static JSONObject generateValidity(Validity input) {
840
743
  JSONObject result = new JSONObject();
841
- if (input == null) return result;
744
+ if (input == null) return null;
842
745
  try {
843
746
  result.put("notAfter", generateValue(input.notAfter));
844
747
  result.put("notBefore", generateValue(input.notBefore));
@@ -850,7 +753,7 @@ class JSONConstructor {
850
753
 
851
754
  static JSONObject generateCertificateChain(CertificateChain input) {
852
755
  JSONObject result = new JSONObject();
853
- if (input == null) return result;
756
+ if (input == null) return null;
854
757
  try {
855
758
  result.put("origin", input.origin);
856
759
  result.put("type", input.type);
@@ -873,7 +776,7 @@ class JSONConstructor {
873
776
 
874
777
  static JSONObject generateSignerInfo(SignerInfo input) {
875
778
  JSONObject result = new JSONObject();
876
- if (input == null) return result;
779
+ if (input == null) return null;
877
780
  try {
878
781
  result.put("version", input.version);
879
782
  result.put("paStatus", input.paStatus);
@@ -895,7 +798,7 @@ class JSONConstructor {
895
798
 
896
799
  static JSONObject generateSecurityObject(SecurityObject input) {
897
800
  JSONObject result = new JSONObject();
898
- if (input == null) return result;
801
+ if (input == null) return null;
899
802
  try {
900
803
  result.put("fileReference", input.fileReference);
901
804
  result.put("version", input.version);
@@ -910,7 +813,7 @@ class JSONConstructor {
910
813
 
911
814
  static JSONObject generateCardProperties(CardProperties input) {
912
815
  JSONObject result = new JSONObject();
913
- if (input == null) return result;
816
+ if (input == null) return null;
914
817
  try {
915
818
  result.put("aTQA", input.aTQA);
916
819
  result.put("bitRateR", input.bitRateR);
@@ -934,7 +837,7 @@ class JSONConstructor {
934
837
 
935
838
  static JSONObject generateRFIDSessionData(RFIDSessionData input) {
936
839
  JSONObject result = new JSONObject();
937
- if (input == null) return result;
840
+ if (input == null) return null;
938
841
  try {
939
842
  result.put("totalBytesReceived", input.totalBytesReceived);
940
843
  result.put("totalBytesSent", input.totalBytesSent);
@@ -953,7 +856,7 @@ class JSONConstructor {
953
856
 
954
857
  static JSONObject generateDocumentReaderAuthenticityCheck(DocumentReaderAuthenticityCheck input, Context context) {
955
858
  JSONObject result = new JSONObject();
956
- if (input == null) return result;
859
+ if (input == null) return null;
957
860
  try {
958
861
  result.put("type", input.type);
959
862
  result.put("status", input.getStatus());
@@ -968,7 +871,7 @@ class JSONConstructor {
968
871
 
969
872
  static JSONObject generatePDF417Info(PDF417Info input) {
970
873
  JSONObject result = new JSONObject();
971
- if (input == null) return result;
874
+ if (input == null) return null;
972
875
  try {
973
876
  result.put("errorLevel", input.errorLevel);
974
877
  result.put("columns", input.columns);
@@ -981,7 +884,7 @@ class JSONConstructor {
981
884
 
982
885
  static JSONObject generateDocumentReaderBarcodeResult(DocumentReaderBarcodeResult input) {
983
886
  JSONObject result = new JSONObject();
984
- if (input == null) return result;
887
+ if (input == null) return null;
985
888
  try {
986
889
  result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderBarcodeField));
987
890
  } catch (JSONException e) {
@@ -992,7 +895,7 @@ class JSONConstructor {
992
895
 
993
896
  static JSONObject generateDocumentReaderBarcodeField(DocumentReaderBarcodeField input) {
994
897
  JSONObject result = new JSONObject();
995
- if (input == null) return result;
898
+ if (input == null) return null;
996
899
  try {
997
900
  result.put("barcodeType", input.barcodeType);
998
901
  result.put("status", input.status);
@@ -1007,7 +910,7 @@ class JSONConstructor {
1007
910
 
1008
911
  static JSONObject generateDocumentReaderAuthenticityResult(DocumentReaderAuthenticityResult input, Context context) {
1009
912
  JSONObject result = new JSONObject();
1010
- if (input == null) return result;
913
+ if (input == null) return null;
1011
914
  try {
1012
915
  result.put("status", input.getStatus());
1013
916
  result.put("checks", generateList(input.checks, JSONConstructor::generateDocumentReaderAuthenticityCheck, context));
@@ -1019,7 +922,7 @@ class JSONConstructor {
1019
922
 
1020
923
  static JSONObject generateDocumentReaderAuthenticityElement(DocumentReaderAuthenticityElement input, Context context) {
1021
924
  JSONObject result = new JSONObject();
1022
- if (input == null) return result;
925
+ if (input == null) return null;
1023
926
  try {
1024
927
  result.put("status", input.status);
1025
928
  result.put("elementType", input.elementType);
@@ -1034,43 +937,10 @@ class JSONConstructor {
1034
937
 
1035
938
  static JSONObject generateDocumentReaderException(DocumentReaderException input) {
1036
939
  JSONObject result = new JSONObject();
1037
- if (input == null) return result;
940
+ if (input == null) return null;
1038
941
  try {
1039
942
  result.put("errorCode", input.getErrorCode());
1040
- result.put("localizedMessage", input.getLocalizedMessage());
1041
- result.put("message", input.getMessage());
1042
- result.put("string", input.toString());
1043
- result.put("stackTrace", generateArray(input.getStackTrace(), JSONConstructor::generateStackTraceElement));
1044
- } catch (JSONException e) {
1045
- e.printStackTrace();
1046
- }
1047
- return result;
1048
- }
1049
-
1050
- static JSONObject generateThrowable(Throwable input) {
1051
- JSONObject result = new JSONObject();
1052
- if (input == null) return result;
1053
- try {
1054
- result.put("localizedMessage", input.getLocalizedMessage());
1055
943
  result.put("message", input.getMessage());
1056
- result.put("string", input.toString());
1057
- result.put("stackTrace", generateArray(input.getStackTrace(), JSONConstructor::generateStackTraceElement));
1058
- } catch (JSONException e) {
1059
- e.printStackTrace();
1060
- }
1061
- return result;
1062
- }
1063
-
1064
- static JSONObject generateStackTraceElement(StackTraceElement input) {
1065
- JSONObject result = new JSONObject();
1066
- if (input == null) return result;
1067
- try {
1068
- result.put("lineNumber", input.getLineNumber());
1069
- result.put("isNativeMethod", input.isNativeMethod());
1070
- result.put("className", input.getClassName());
1071
- result.put("fileName", input.getFileName());
1072
- result.put("methodName", input.getMethodName());
1073
- result.put("string", input.toString());
1074
944
  } catch (JSONException e) {
1075
945
  e.printStackTrace();
1076
946
  }
@@ -1079,7 +949,7 @@ class JSONConstructor {
1079
949
 
1080
950
  static JSONObject generatePAResourcesIssuer(PAResourcesIssuer input) {
1081
951
  JSONObject result = new JSONObject();
1082
- if (input == null) return result;
952
+ if (input == null) return null;
1083
953
  try {
1084
954
  result.put("data", generateByteArray(input.data));
1085
955
  result.put("friendlyName", input.friendlyName);
@@ -1092,7 +962,7 @@ class JSONConstructor {
1092
962
 
1093
963
  static JSONObject generatePAAttribute(PAAttribute input) {
1094
964
  JSONObject result = new JSONObject();
1095
- if (input == null) return result;
965
+ if (input == null) return null;
1096
966
  try {
1097
967
  result.put("type", input.type);
1098
968
  result.put("value", input.value);
@@ -1104,7 +974,7 @@ class JSONConstructor {
1104
974
 
1105
975
  static JSONObject generateTAChallenge(TAChallenge input) {
1106
976
  JSONObject result = new JSONObject();
1107
- if (input == null) return result;
977
+ if (input == null) return null;
1108
978
  try {
1109
979
  result.put("data", generateByteArray(input.data));
1110
980
  result.put("auxPCD", input.auxPCD);
@@ -1119,7 +989,7 @@ class JSONConstructor {
1119
989
 
1120
990
  static JSONObject generateDocumentReaderResultsStatus(DocumentReaderResultsStatus input) {
1121
991
  JSONObject result = new JSONObject();
1122
- if (input == null) return result;
992
+ if (input == null) return null;
1123
993
  try {
1124
994
  result.put("overallStatus", input.getOverallStatus());
1125
995
  result.put("optical", input.getOptical());
@@ -1136,7 +1006,7 @@ class JSONConstructor {
1136
1006
 
1137
1007
  static JSONObject generateDetailsOptical(DocumentReaderResultsStatus.DetailsOptical input) {
1138
1008
  JSONObject result = new JSONObject();
1139
- if (input == null) return result;
1009
+ if (input == null) return null;
1140
1010
  try {
1141
1011
  result.put("overallStatus", input.getOverallStatus());
1142
1012
  result.put("mrz", input.getMrz());
@@ -1155,7 +1025,7 @@ class JSONConstructor {
1155
1025
 
1156
1026
  static JSONObject generateDetailsRFID(DocumentReaderResultsStatus.DetailsRFID input) {
1157
1027
  JSONObject result = new JSONObject();
1158
- if (input == null) return result;
1028
+ if (input == null) return null;
1159
1029
  try {
1160
1030
  result.put("pa", input.getPA());
1161
1031
  result.put("ca", input.getCA());
@@ -1172,7 +1042,7 @@ class JSONConstructor {
1172
1042
 
1173
1043
  static JSONObject generateVDSNCData(VDSNCData input) {
1174
1044
  JSONObject result = new JSONObject();
1175
- if (input == null) return result;
1045
+ if (input == null) return null;
1176
1046
  try {
1177
1047
  result.put("type", input.getType());
1178
1048
  result.put("version", input.getVersion());
@@ -1191,7 +1061,7 @@ class JSONConstructor {
1191
1061
 
1192
1062
  static JSONObject generateBytesData(BytesData input) {
1193
1063
  JSONObject result = new JSONObject();
1194
- if (input == null) return result;
1064
+ if (input == null) return null;
1195
1065
  try {
1196
1066
  result.put("data", input.getData());
1197
1067
  result.put("length", input.getLength());
@@ -1203,1174 +1073,117 @@ class JSONConstructor {
1203
1073
  return result;
1204
1074
  }
1205
1075
 
1206
- static JSONObject generateDocumentReaderUvFiberElement(DocumentReaderUvFiberElement input, Context context) {
1076
+ static JSONObject generateDocReaderDocumentsDatabase(DocReaderDocumentsDatabase input) {
1207
1077
  JSONObject result = new JSONObject();
1208
- if (input == null) return result;
1078
+ if (input == null) return null;
1209
1079
  try {
1210
- result.put("rectArray", generateList(input.rectArray, JSONConstructor::generateDocReaderFieldRect));
1211
- result.put("rectCount", input.rectCount);
1212
- result.put("expectedCount", input.expectedCount);
1213
- result.put("width", generateIntArray(input.width));
1214
- result.put("length", generateIntArray(input.length));
1215
- result.put("area", generateIntArray(input.area));
1216
- result.put("colorValues", generateIntArray(input.colorValues));
1217
- result.put("status", input.status);
1218
- result.put("elementType", input.elementType);
1219
- result.put("elementDiagnose", input.elementDiagnose);
1220
- result.put("elementTypeName", input.getElementTypeName(context));
1221
- result.put("elementDiagnoseName", input.getElementDiagnoseName(context));
1080
+ result.put("databaseID", input.databaseID);
1081
+ result.put("version", input.version);
1082
+ result.put("date", input.date);
1083
+ result.put("databaseDescription", input.databaseDescription);
1084
+ result.put("countriesNumber", input.countriesNumber);
1085
+ result.put("documentsNumber", input.documentsNumber);
1222
1086
  } catch (JSONException e) {
1223
1087
  e.printStackTrace();
1224
1088
  }
1225
1089
  return result;
1226
1090
  }
1227
1091
 
1228
- static JSONObject generateImageInputData(ImageInputData input) {
1092
+ static JSONObject generateDocumentReaderComparison(DocumentReaderComparison input) {
1229
1093
  JSONObject result = new JSONObject();
1230
- if (input == null) return result;
1094
+ if (input == null) return null;
1231
1095
  try {
1232
- result.put("pageIndex", input.getPageIndex());
1233
- result.put("light", input.getLight());
1234
- result.put("type", input.getType());
1235
- result.put("width", input.getWidth());
1236
- result.put("height", input.getHeight());
1237
- result.put("bitmap", generateBitmap(input.getBitmap()));
1238
- result.put("imgBytes", generateByteArray(input.getImgBytes()));
1096
+ result.put("sourceTypeLeft", input.sourceTypeLeft);
1097
+ result.put("sourceTypeRight", input.sourceTypeRight);
1098
+ result.put("status", input.status);
1239
1099
  } catch (JSONException e) {
1240
1100
  e.printStackTrace();
1241
1101
  }
1242
1102
  return result;
1243
1103
  }
1244
1104
 
1245
- static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Context context) {
1105
+ static JSONObject generateDocumentReaderRfidOrigin(DocumentReaderRfidOrigin input) {
1246
1106
  JSONObject result = new JSONObject();
1247
- if (input == null) return result;
1107
+ if (input == null) return null;
1248
1108
  try {
1249
- result.put("chipPage", input.chipPage);
1250
- result.put("processingFinishedStatus", input.processingFinishedStatus);
1251
- result.put("elapsedTime", input.elapsedTime);
1252
- result.put("elapsedTimeRFID", input.elapsedTimeRFID);
1253
- result.put("morePagesAvailable", input.morePagesAvailable);
1254
- result.put("rfidResult", input.rfidResult);
1255
- result.put("highResolution", input.highResolution);
1256
- result.put("graphicResult", generateDocumentReaderGraphicResult(input.graphicResult, context));
1257
- result.put("textResult", generateDocumentReaderTextResult(input.textResult, context));
1258
- result.put("documentPosition", generateList(input.documentPosition, JSONConstructor::generateElementPosition));
1259
- result.put("barcodePosition", generateList(input.barcodePosition, JSONConstructor::generateElementPosition));
1260
- result.put("mrzPosition", generateList(input.mrzPosition, JSONConstructor::generateElementPosition));
1261
- result.put("imageQuality", generateList(input.imageQuality, JSONConstructor::generateImageQualityGroup));
1262
- result.put("rawResult", input.rawResult);
1263
- result.put("documentReaderNotification", generateDocumentReaderNotification(input.documentReaderNotification));
1264
- result.put("rfidSessionData", generateRFIDSessionData(input.rfidSessionData));
1265
- result.put("authenticityResult", generateDocumentReaderAuthenticityResult(input.authenticityResult, context));
1266
- result.put("barcodeResult", generateDocumentReaderBarcodeResult(input.barcodeResult));
1267
- result.put("documentType", generateList(input.documentType, JSONConstructor::generateDocumentReaderDocumentType));
1268
- result.put("status", generateDocumentReaderResultsStatus(input.status));
1269
- result.put("vdsncData", generateVDSNCData(input.vdsncData));
1109
+ result.put("dg", input.dg);
1110
+ result.put("dgTag", input.dgTag);
1111
+ result.put("entryView", input.entryView);
1112
+ result.put("tagEntry", input.tagEntry);
1270
1113
  } catch (JSONException e) {
1271
1114
  e.printStackTrace();
1272
1115
  }
1273
1116
  return result;
1274
1117
  }
1275
1118
 
1276
- // From JSON
1277
-
1278
- static DocumentReaderScenario DocumentReaderScenarioFromJSON(JSONObject input) {
1279
- try {
1280
- DocumentReaderScenario result = new DocumentReaderScenario();
1281
- if (input.has("name"))
1282
- result.name = input.getString("name");
1283
- if (input.has("caption"))
1284
- result.caption = input.getString("caption");
1285
- if (input.has("description"))
1286
- result.description = input.getString("description");
1287
- return result;
1288
- } catch (JSONException e) {
1289
- e.printStackTrace();
1290
- }
1291
- return null;
1292
- }
1293
-
1294
- static CoreDetailedScenario CoreDetailedScenarioFromJSON(JSONObject input) {
1295
- try {
1296
- CoreDetailedScenario result = new CoreDetailedScenario();
1297
- if (input.has("uvTorch"))
1298
- result.uvTorch = input.getBoolean("uvTorch");
1299
- if (input.has("frameOrientation"))
1300
- result.frameOrientation = input.getInt("frameOrientation");
1301
- if (input.has("faceExt"))
1302
- result.faceExt = input.getBoolean("faceExt");
1303
- if (input.has("multiPageOff"))
1304
- result.multiPageOff = input.getInt("multiPageOff");
1305
- if (input.has("seriesProcessMode"))
1306
- result.seriesProcessMode = input.getBoolean("seriesProcessMode");
1307
- if (input.has("frameKWHLandscape"))
1308
- result.frameKWHLandscape = input.getDouble("frameKWHLandscape");
1309
- if (input.has("frameKWHPortrait"))
1310
- result.frameKWHPortrait = input.getDouble("frameKWHPortrait");
1311
- if (input.has("frameKWHDoublePageSpreadPortrait"))
1312
- result.frameKWHDoublePageSpreadPortrait = input.getDouble("frameKWHDoublePageSpreadPortrait");
1313
- if (input.has("frameKWHDoublePageSpreadLandscape"))
1314
- result.frameKWHDoublePageSpreadLandscape = input.getDouble("frameKWHDoublePageSpreadLandscape");
1315
- if (input.has("name"))
1316
- result.name = input.getString("name");
1317
- if (input.has("caption"))
1318
- result.caption = input.getString("caption");
1319
- if (input.has("description"))
1320
- result.description = input.getString("description");
1321
- if (input.has("manualCrop"))
1322
- result.manualCrop = input.getBoolean("manualCrop");
1323
- return result;
1324
- } catch (JSONException e) {
1325
- e.printStackTrace();
1326
- }
1327
- return null;
1328
- }
1329
-
1330
- static FaceMetaData FaceMetaDataFromJSON(JSONObject input) {
1331
- try {
1332
- FaceMetaData result = new FaceMetaData();
1333
- if (input.has("ID"))
1334
- result.ID = input.getInt("ID");
1335
- if (input.has("rollAngle"))
1336
- result.rollAngle = input.getInt("rollAngle");
1337
- if (input.has("bounds"))
1338
- result.bounds = BoundsFromJSON(input.getJSONObject("bounds"));
1339
- return result;
1340
- } catch (JSONException e) {
1341
- e.printStackTrace();
1342
- }
1343
- return null;
1344
- }
1345
-
1346
- static Bounds BoundsFromJSON(JSONObject input) {
1347
- try {
1348
- Bounds result = new Bounds();
1349
- if (input.has("x"))
1350
- result.x = input.getInt("x");
1351
- if (input.has("y"))
1352
- result.y = input.getInt("y");
1353
- if (input.has("width"))
1354
- result.width = input.getInt("width");
1355
- if (input.has("height"))
1356
- result.height = input.getInt("height");
1357
- return result;
1358
- } catch (JSONException e) {
1359
- e.printStackTrace();
1360
- }
1361
- return null;
1362
- }
1363
-
1364
- static Rect RectFromJSON(JSONObject input) {
1365
- try {
1366
- Rect result = new Rect();
1367
- if (input.has("bottom"))
1368
- result.bottom = input.getInt("bottom");
1369
- if (input.has("top"))
1370
- result.top = input.getInt("top");
1371
- if (input.has("left"))
1372
- result.left = input.getInt("left");
1373
- if (input.has("right"))
1374
- result.right = input.getInt("right");
1375
- return result;
1376
- } catch (JSONException e) {
1377
- e.printStackTrace();
1378
- }
1379
- return null;
1380
- }
1381
-
1382
- static DocReaderFieldRect DocReaderFieldRectFromJSON(JSONObject input) {
1383
- try {
1384
- DocReaderFieldRect result = new DocReaderFieldRect();
1385
- if (input.has("bottom"))
1386
- result.bottom = input.getInt("bottom");
1387
- if (input.has("top"))
1388
- result.top = input.getInt("top");
1389
- if (input.has("left"))
1390
- result.left = input.getInt("left");
1391
- if (input.has("right"))
1392
- result.right = input.getInt("right");
1393
- return result;
1394
- } catch (JSONException e) {
1395
- e.printStackTrace();
1396
- }
1397
- return null;
1398
- }
1399
-
1400
- static DocumentReaderGraphicField DocumentReaderGraphicFieldFromJSON(JSONObject input) {
1401
- try {
1402
- DocumentReaderGraphicField result = new DocumentReaderGraphicField();
1403
- if (input.has("sourceType"))
1404
- result.sourceType = input.getInt("sourceType");
1405
- if (input.has("fieldType"))
1406
- result.fieldType = input.getInt("fieldType");
1407
- if (input.has("lightType"))
1408
- result.light = input.getInt("lightType");
1409
- if (input.has("pageIndex"))
1410
- result.pageIndex = input.getInt("pageIndex");
1411
- if (input.has("fieldRect"))
1412
- result.boundRect = DocReaderFieldRectFromJSON(input.getJSONObject("fieldRect"));
1413
- return result;
1414
- } catch (JSONException e) {
1415
- e.printStackTrace();
1416
- }
1417
- return null;
1418
- }
1419
-
1420
- static DocumentReaderGraphicResult DocumentReaderGraphicResultFromJSON(JSONObject input) {
1421
- try {
1422
- DocumentReaderGraphicResult result = new DocumentReaderGraphicResult();
1423
- if (input.has("fields")){
1424
- JSONArray jsonArray_fields = input.getJSONArray("fields");
1425
- List<DocumentReaderGraphicField> fields = new ArrayList<>();
1426
- for (int i = 0; i < jsonArray_fields.length(); i++)
1427
- fields.add(DocumentReaderGraphicFieldFromJSON(jsonArray_fields.getJSONObject(i)));
1428
- result.fields = fields;
1429
- }
1430
- return result;
1431
- } catch (JSONException e) {
1432
- e.printStackTrace();
1433
- }
1434
- return null;
1435
- }
1436
-
1437
- static DocumentReaderValue DocumentReaderValueFromJSON(JSONObject input) {
1438
- try {
1439
- DocumentReaderValue result = new DocumentReaderValue();
1440
- if (input.has("pageIndex"))
1441
- result.pageIndex = input.getInt("pageIndex");
1442
- if (input.has("sourceType"))
1443
- result.sourceType = input.getInt("sourceType");
1444
- if (input.has("validity"))
1445
- result.validity = input.getInt("validity");
1446
- if (input.has("probability"))
1447
- result.probability = input.getInt("probability");
1448
- if (input.has("value"))
1449
- result.value = input.getString("value");
1450
- if (input.has("originalValue"))
1451
- result.originalValue = input.getString("originalValue");
1452
- if (input.has("boundRect"))
1453
- result.boundRect = RectFromJSON(input.getJSONObject("boundRect"));
1454
- return result;
1455
- } catch (JSONException e) {
1456
- e.printStackTrace();
1457
- }
1458
- return null;
1459
- }
1460
-
1461
- static DocumentReaderTextField DocumentReaderTextFieldFromJSON(JSONObject input) {
1462
- try {
1463
- DocumentReaderTextField result = new DocumentReaderTextField();
1464
- if (input.has("fieldType"))
1465
- result.fieldType = input.getInt("fieldType");
1466
- if (input.has("lcid"))
1467
- result.lcid = input.getInt("lcid");
1468
- if (input.has("status"))
1469
- result.status = input.getInt("status");
1470
- if (input.has("values")){
1471
- JSONArray jsonArray_values = input.getJSONArray("values");
1472
- List<DocumentReaderValue> values = new ArrayList<>();
1473
- for (int i = 0; i < jsonArray_values.length(); i++)
1474
- values.add(DocumentReaderValueFromJSON(jsonArray_values.getJSONObject(i)));
1475
- result.values = values;
1476
- }
1477
- return result;
1478
- } catch (JSONException e) {
1479
- e.printStackTrace();
1480
- }
1481
- return null;
1482
- }
1483
-
1484
- static DocumentReaderTextResult DocumentReaderTextResultFromJSON(JSONObject input) {
1119
+ static JSONObject generateDocumentReaderTextSource(DocumentReaderTextSource input) {
1120
+ JSONObject result = new JSONObject();
1121
+ if (input == null) return null;
1485
1122
  try {
1486
- DocumentReaderTextResult result = new DocumentReaderTextResult();
1487
- if (input.has("status"))
1488
- result.status = input.getInt("status");
1489
- if (input.has("fields")){
1490
- JSONArray jsonArray_fields = input.getJSONArray("fields");
1491
- List<DocumentReaderTextField> fields = new ArrayList<>();
1492
- for (int i = 0; i < jsonArray_fields.length(); i++)
1493
- fields.add(DocumentReaderTextFieldFromJSON(jsonArray_fields.getJSONObject(i)));
1494
- result.fields = fields;
1495
- }
1496
- return result;
1123
+ result.put("sourceType", input.sourceType);
1124
+ result.put("source", input.source);
1125
+ result.put("validityStatus", input.validityStatus);
1497
1126
  } catch (JSONException e) {
1498
1127
  e.printStackTrace();
1499
1128
  }
1500
- return null;
1129
+ return result;
1501
1130
  }
1502
1131
 
1503
- static Coordinate CoordinateFromJSON(JSONObject input) {
1132
+ static JSONObject generateDocumentReaderSymbol(DocumentReaderSymbol input) {
1133
+ JSONObject result = new JSONObject();
1134
+ if (input == null) return null;
1504
1135
  try {
1505
- Coordinate result = new Coordinate();
1506
- if (input.has("x"))
1507
- result.x = input.getInt("x");
1508
- if (input.has("y"))
1509
- result.y = input.getInt("y");
1510
- return result;
1136
+ result.put("code", input.code);
1137
+ result.put("rect", generateRect(input.rect));
1138
+ result.put("probability", input.probability);
1511
1139
  } catch (JSONException e) {
1512
1140
  e.printStackTrace();
1513
1141
  }
1514
- return null;
1142
+ return result;
1515
1143
  }
1516
1144
 
1517
- static ElementPosition ElementPositionFromJSON(JSONObject input) {
1145
+ static JSONObject generateDocumentReaderValidity(DocumentReaderValidity input) {
1146
+ JSONObject result = new JSONObject();
1147
+ if (input == null) return null;
1518
1148
  try {
1519
- ElementPosition result = new ElementPosition();
1520
- if (input.has("docFormat"))
1521
- result.docFormat = input.getInt("docFormat");
1522
- if (input.has("width"))
1523
- result.width = input.getInt("width");
1524
- if (input.has("height"))
1525
- result.height = input.getInt("height");
1526
- if (input.has("dpi"))
1527
- result.dpi = input.getInt("dpi");
1528
- if (input.has("pageIndex"))
1529
- result.pageIndex = input.getInt("pageIndex");
1530
- if (input.has("inverse"))
1531
- result.inverse = input.getInt("inverse");
1532
- if (input.has("perspectiveTr"))
1533
- result.perspectiveTr = input.getInt("perspectiveTr");
1534
- if (input.has("objArea"))
1535
- result.objArea = input.getInt("objArea");
1536
- if (input.has("objIntAngleDev"))
1537
- result.objIntAngleDev = input.getInt("objIntAngleDev");
1538
- if (input.has("resultStatus"))
1539
- result.resultStatus = input.getInt("resultStatus");
1540
- if (input.has("angle"))
1541
- result.angle = input.getDouble("angle");
1542
- if (input.has("center"))
1543
- result.center = CoordinateFromJSON(input.getJSONObject("center"));
1544
- if (input.has("leftTop"))
1545
- result.leftTop = CoordinateFromJSON(input.getJSONObject("leftTop"));
1546
- if (input.has("leftBottom"))
1547
- result.leftBottom = CoordinateFromJSON(input.getJSONObject("leftBottom"));
1548
- if (input.has("rightTop"))
1549
- result.rightTop = CoordinateFromJSON(input.getJSONObject("rightTop"));
1550
- if (input.has("rightBottom"))
1551
- result.rightBottom = CoordinateFromJSON(input.getJSONObject("rightBottom"));
1552
- return result;
1149
+ result.put("sourceType", input.sourceType);
1150
+ result.put("status", input.status);
1553
1151
  } catch (JSONException e) {
1554
1152
  e.printStackTrace();
1555
1153
  }
1556
- return null;
1154
+ return result;
1557
1155
  }
1558
1156
 
1559
- static ImageQuality ImageQualityFromJSON(JSONObject input) {
1157
+ static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Context context) {
1158
+ JSONObject result = new JSONObject();
1159
+ if (input == null) return null;
1560
1160
  try {
1561
- ImageQuality result = new ImageQuality();
1562
- if (input.has("featureType"))
1563
- result.featureType = input.getInt("featureType");
1564
- if (input.has("result"))
1565
- result.result = input.getInt("result");
1566
- if (input.has("type"))
1567
- result.type = input.getInt("type");
1568
- return result;
1161
+ result.put("chipPage", input.chipPage);
1162
+ result.put("processingFinishedStatus", input.processingFinishedStatus);
1163
+ result.put("elapsedTime", input.elapsedTime);
1164
+ result.put("elapsedTimeRFID", input.elapsedTimeRFID);
1165
+ result.put("morePagesAvailable", input.morePagesAvailable);
1166
+ result.put("rfidResult", input.rfidResult);
1167
+ result.put("highResolution", input.highResolution);
1168
+ result.put("graphicResult", generateDocumentReaderGraphicResult(input.graphicResult, context));
1169
+ result.put("textResult", generateDocumentReaderTextResult(input.textResult, context));
1170
+ result.put("documentPosition", generateList(input.documentPosition, JSONConstructor::generateElementPosition));
1171
+ result.put("barcodePosition", generateList(input.barcodePosition, JSONConstructor::generateElementPosition));
1172
+ result.put("mrzPosition", generateList(input.mrzPosition, JSONConstructor::generateElementPosition));
1173
+ result.put("imageQuality", generateList(input.imageQuality, JSONConstructor::generateImageQualityGroup));
1174
+ result.put("rawResult", input.rawResult);
1175
+ result.put("documentReaderNotification", generateDocumentReaderNotification(input.documentReaderNotification));
1176
+ result.put("rfidSessionData", generateRFIDSessionData(input.rfidSessionData));
1177
+ result.put("authenticityResult", generateDocumentReaderAuthenticityResult(input.authenticityResult, context));
1178
+ result.put("barcodeResult", generateDocumentReaderBarcodeResult(input.barcodeResult));
1179
+ result.put("documentType", generateList(input.documentType, JSONConstructor::generateDocumentReaderDocumentType));
1180
+ result.put("status", generateDocumentReaderResultsStatus(input.status));
1181
+ result.put("vdsncData", generateVDSNCData(input.vdsncData));
1569
1182
  } catch (JSONException e) {
1570
1183
  e.printStackTrace();
1571
1184
  }
1572
- return null;
1185
+ return result;
1573
1186
  }
1574
1187
 
1575
- static ImageQualityGroup ImageQualityGroupFromJSON(JSONObject input) {
1576
- try {
1577
- ImageQualityGroup result = new ImageQualityGroup();
1578
- if (input.has("count"))
1579
- result.count = input.getInt("count");
1580
- if (input.has("result"))
1581
- result.result = input.getInt("result");
1582
- if (input.has("imageQualityList")){
1583
- JSONArray jsonArray_imageQualityList = input.getJSONArray("imageQualityList");
1584
- List<ImageQuality> imageQualityList = new ArrayList<>();
1585
- for (int i = 0; i < jsonArray_imageQualityList.length(); i++)
1586
- imageQualityList.add(ImageQualityFromJSON(jsonArray_imageQualityList.getJSONObject(i)));
1587
- result.imageQualityList = imageQualityList;
1588
- }
1589
- if (input.has("pageIndex"))
1590
- result.pageIndex = input.getInt("pageIndex");
1591
- return result;
1592
- } catch (JSONException e) {
1593
- e.printStackTrace();
1594
- }
1595
- return null;
1596
- }
1597
-
1598
- static DocumentReaderDocumentType DocumentReaderDocumentTypeFromJSON(JSONObject input) {
1599
- try {
1600
- DocumentReaderDocumentType result = new DocumentReaderDocumentType();
1601
- if (input.has("pageIndex"))
1602
- result.pageIndex = input.getInt("pageIndex");
1603
- if (input.has("documentID"))
1604
- result.documentID = input.getInt("documentID");
1605
- if (input.has("dType"))
1606
- result.dType = input.getInt("dType");
1607
- if (input.has("dFormat"))
1608
- result.dFormat = input.getInt("dFormat");
1609
- if (input.has("dMRZ"))
1610
- result.dMRZ = input.getBoolean("dMRZ");
1611
- if (input.has("name"))
1612
- result.name = input.getString("name");
1613
- if (input.has("ICAOCode"))
1614
- result.ICAOCode = input.getString("ICAOCode");
1615
- if (input.has("dDescription"))
1616
- result.dDescription = input.getString("dDescription");
1617
- if (input.has("dYear"))
1618
- result.dYear = input.getString("dYear");
1619
- if (input.has("dCountryName"))
1620
- result.dCountryName = input.getString("dCountryName");
1621
- if (input.has("FDSID")){
1622
- JSONArray jsonArray_FDSID = input.getJSONArray("FDSID");
1623
- int[] FDSID = new int[jsonArray_FDSID.length()];
1624
- for (int i = 0; i < jsonArray_FDSID.length(); i++)
1625
- FDSID[i] = jsonArray_FDSID.getInt(i);
1626
- result.FDSID = FDSID;
1627
- }
1628
- return result;
1629
- } catch (JSONException e) {
1630
- e.printStackTrace();
1631
- }
1632
- return null;
1633
- }
1634
-
1635
- static AccessControlProcedureType AccessControlProcedureTypeFromJSON(JSONObject input) {
1636
- try {
1637
- AccessControlProcedureType result = new AccessControlProcedureType();
1638
- if (input.has("activeOptionIdx"))
1639
- result.activeOptionIdx = input.getInt("activeOptionIdx");
1640
- if (input.has("type"))
1641
- result.type = input.getInt("type");
1642
- if (input.has("status"))
1643
- result.status = input.getInt("status");
1644
- if (input.has("notifications")){
1645
- JSONArray jsonArray_notifications = input.getJSONArray("notifications");
1646
- List<Long> notifications = new ArrayList<>();
1647
- for (int i = 0; i < jsonArray_notifications.length(); i++)
1648
- notifications.add(jsonArray_notifications.getLong(i));
1649
- result.notifications = notifications;
1650
- }
1651
- return result;
1652
- } catch (JSONException e) {
1653
- e.printStackTrace();
1654
- }
1655
- return null;
1656
- }
1657
-
1658
- static FileData FileDataFromJSON(JSONObject input) {
1659
- try {
1660
- FileData result = new FileData();
1661
- if (input.has("length"))
1662
- result.length = input.getInt("length");
1663
- if (input.has("type"))
1664
- result.type = input.getInt("type");
1665
- if (input.has("status"))
1666
- result.status = input.getInt("status");
1667
- if (input.has("data"))
1668
- result.data = input.getString("data");
1669
- return result;
1670
- } catch (JSONException e) {
1671
- e.printStackTrace();
1672
- }
1673
- return null;
1674
- }
1675
-
1676
- static CertificateData CertificateDataFromJSON(JSONObject input) {
1677
- try {
1678
- CertificateData result = new CertificateData();
1679
- if (input.has("length"))
1680
- result.length = input.getInt("length");
1681
- if (input.has("data"))
1682
- result.data = input.getString("data");
1683
- return result;
1684
- } catch (JSONException e) {
1685
- e.printStackTrace();
1686
- }
1687
- return null;
1688
- }
1689
-
1690
- static SecurityObjectCertificates SecurityObjectCertificatesFromJSON(JSONObject input) {
1691
- try {
1692
- SecurityObjectCertificates result = new SecurityObjectCertificates();
1693
- if (input.has("securityObject"))
1694
- result.securityObject = CertificateDataFromJSON(input.getJSONObject("securityObject"));
1695
- return result;
1696
- } catch (JSONException e) {
1697
- e.printStackTrace();
1698
- }
1699
- return null;
1700
- }
1701
-
1702
- static File FileFromJSON(JSONObject input) {
1703
- try {
1704
- File result = new File();
1705
- if (input.has("readingTime"))
1706
- result.readingTime = input.getInt("readingTime");
1707
- if (input.has("type"))
1708
- result.type = input.getInt("type");
1709
- if (input.has("pAStatus"))
1710
- result.pAStatus = input.getInt("pAStatus");
1711
- if (input.has("readingStatus"))
1712
- result.readingStatus = input.getInt("readingStatus");
1713
- if (input.has("fileID"))
1714
- result.fileID = input.getString("fileID");
1715
- if (input.has("fileData"))
1716
- result.fileData = FileDataFromJSON(input.getJSONObject("fileData"));
1717
- if (input.has("certificates"))
1718
- result.certificates = SecurityObjectCertificatesFromJSON(input.getJSONObject("certificates"));
1719
- if (input.has("docFieldsText")){
1720
- JSONArray jsonArray_docFieldsText = input.getJSONArray("docFieldsText");
1721
- List<Integer> docFieldsText = new ArrayList<>();
1722
- for (int i = 0; i < jsonArray_docFieldsText.length(); i++)
1723
- docFieldsText.add(jsonArray_docFieldsText.getInt(i));
1724
- result.docFieldsText = docFieldsText;
1725
- }
1726
- if (input.has("docFieldsGraphics")){
1727
- JSONArray jsonArray_docFieldsGraphics = input.getJSONArray("docFieldsGraphics");
1728
- List<Integer> docFieldsGraphics = new ArrayList<>();
1729
- for (int i = 0; i < jsonArray_docFieldsGraphics.length(); i++)
1730
- docFieldsGraphics.add(jsonArray_docFieldsGraphics.getInt(i));
1731
- result.docFieldsGraphics = docFieldsGraphics;
1732
- }
1733
- if (input.has("docFieldsOriginals")){
1734
- JSONArray jsonArray_docFieldsOriginals = input.getJSONArray("docFieldsOriginals");
1735
- List<Integer> docFieldsOriginals = new ArrayList<>();
1736
- for (int i = 0; i < jsonArray_docFieldsOriginals.length(); i++)
1737
- docFieldsOriginals.add(jsonArray_docFieldsOriginals.getInt(i));
1738
- result.docFieldsOriginals = docFieldsOriginals;
1739
- }
1740
- if (input.has("notifications")){
1741
- JSONArray jsonArray_notifications = input.getJSONArray("notifications");
1742
- List<Long> notifications = new ArrayList<>();
1743
- for (int i = 0; i < jsonArray_notifications.length(); i++)
1744
- notifications.add(jsonArray_notifications.getLong(i));
1745
- result.notifications = notifications;
1746
- }
1747
- return result;
1748
- } catch (JSONException e) {
1749
- e.printStackTrace();
1750
- }
1751
- return null;
1752
- }
1753
-
1754
- static Application ApplicationFromJSON(JSONObject input) {
1755
- try {
1756
- Application result = new Application();
1757
- if (input.has("type"))
1758
- result.type = input.getInt("type");
1759
- if (input.has("status"))
1760
- result.status = input.getInt("status");
1761
- if (input.has("applicationID"))
1762
- result.applicationID = input.getString("applicationID");
1763
- if (input.has("dataHashAlgorithm"))
1764
- result.dataHashAlgorithm = input.getString("dataHashAlgorithm");
1765
- if (input.has("unicodeVersion"))
1766
- result.unicodeVersion = input.getString("unicodeVersion");
1767
- if (input.has("version"))
1768
- result.version = input.getString("version");
1769
- if (input.has("files")){
1770
- JSONArray jsonArray_files = input.getJSONArray("files");
1771
- List<File> files = new ArrayList<>();
1772
- for (int i = 0; i < jsonArray_files.length(); i++)
1773
- files.add(FileFromJSON(jsonArray_files.getJSONObject(i)));
1774
- result.files = files;
1775
- }
1776
- return result;
1777
- } catch (JSONException e) {
1778
- e.printStackTrace();
1779
- }
1780
- return null;
1781
- }
1782
-
1783
- static Value ValueFromJSON(JSONObject input) {
1784
- try {
1785
- Value result = new Value();
1786
- if (input.has("length"))
1787
- result.length = input.getInt("length");
1788
- if (input.has("type"))
1789
- result.type = input.getInt("type");
1790
- if (input.has("status"))
1791
- result.status = input.getInt("status");
1792
- if (input.has("data"))
1793
- result.data = input.getString("data");
1794
- if (input.has("format"))
1795
- result.format = input.getString("format");
1796
- return result;
1797
- } catch (JSONException e) {
1798
- e.printStackTrace();
1799
- }
1800
- return null;
1801
- }
1802
-
1803
- static Attribute AttributeFromJSON(JSONObject input) {
1804
- try {
1805
- Attribute result = new Attribute();
1806
- if (input.has("type"))
1807
- result.type = input.getString("type");
1808
- if (input.has("value"))
1809
- result.value = ValueFromJSON(input.getJSONObject("value"));
1810
- return result;
1811
- } catch (JSONException e) {
1812
- e.printStackTrace();
1813
- }
1814
- return null;
1815
- }
1816
-
1817
- static Authority AuthorityFromJSON(JSONObject input) {
1818
- try {
1819
- Authority result = new Authority();
1820
- if (input.has("data"))
1821
- result.data = input.getString("data");
1822
- if (input.has("friendlyName"))
1823
- result.friendlyName = ValueFromJSON(input.getJSONObject("friendlyName"));
1824
- if (input.has("attributes")){
1825
- JSONArray jsonArray_attributes = input.getJSONArray("attributes");
1826
- List<Attribute> attributes = new ArrayList<>();
1827
- for (int i = 0; i < jsonArray_attributes.length(); i++)
1828
- attributes.add(AttributeFromJSON(jsonArray_attributes.getJSONObject(i)));
1829
- result.attributes = attributes;
1830
- }
1831
- return result;
1832
- } catch (JSONException e) {
1833
- e.printStackTrace();
1834
- }
1835
- return null;
1836
- }
1837
-
1838
- static Extension ExtensionFromJSON(JSONObject input) {
1839
- try {
1840
- Extension result = new Extension();
1841
- if (input.has("data"))
1842
- result.data = input.getString("data");
1843
- if (input.has("type"))
1844
- result.type = input.getString("type");
1845
- return result;
1846
- } catch (JSONException e) {
1847
- e.printStackTrace();
1848
- }
1849
- return null;
1850
- }
1851
-
1852
- static Validity ValidityFromJSON(JSONObject input) {
1853
- try {
1854
- Validity result = new Validity();
1855
- if (input.has("notAfter"))
1856
- result.notAfter = ValueFromJSON(input.getJSONObject("notAfter"));
1857
- if (input.has("notBefore"))
1858
- result.notBefore = ValueFromJSON(input.getJSONObject("notBefore"));
1859
- return result;
1860
- } catch (JSONException e) {
1861
- e.printStackTrace();
1862
- }
1863
- return null;
1864
- }
1865
-
1866
- static CertificateChain CertificateChainFromJSON(JSONObject input) {
1867
- try {
1868
- CertificateChain result = new CertificateChain();
1869
- if (input.has("origin"))
1870
- result.origin = input.getInt("origin");
1871
- if (input.has("type"))
1872
- result.type = input.getInt("type");
1873
- if (input.has("version"))
1874
- result.version = input.getInt("version");
1875
- if (input.has("paStatus"))
1876
- result.paStatus = input.getInt("paStatus");
1877
- if (input.has("serialNumber"))
1878
- result.serialNumber = input.getString("serialNumber");
1879
- if (input.has("signatureAlgorithm"))
1880
- result.signatureAlgorithm = input.getString("signatureAlgorithm");
1881
- if (input.has("subjectPKAlgorithm"))
1882
- result.subjectPKAlgorithm = input.getString("subjectPKAlgorithm");
1883
- if (input.has("fileName"))
1884
- result.fileName = ValueFromJSON(input.getJSONObject("fileName"));
1885
- if (input.has("validity"))
1886
- result.validity = ValidityFromJSON(input.getJSONObject("validity"));
1887
- if (input.has("issuer"))
1888
- result.issuer = AuthorityFromJSON(input.getJSONObject("issuer"));
1889
- if (input.has("subject"))
1890
- result.subject = AuthorityFromJSON(input.getJSONObject("subject"));
1891
- if (input.has("notifications")){
1892
- JSONArray jsonArray_notifications = input.getJSONArray("notifications");
1893
- List<Long> notifications = new ArrayList<>();
1894
- for (int i = 0; i < jsonArray_notifications.length(); i++)
1895
- notifications.add(jsonArray_notifications.getLong(i));
1896
- result.notifications = notifications;
1897
- }
1898
- if (input.has("extensions")){
1899
- JSONArray jsonArray_extensions = input.getJSONArray("extensions");
1900
- List<Extension> extensions = new ArrayList<>();
1901
- for (int i = 0; i < jsonArray_extensions.length(); i++)
1902
- extensions.add(ExtensionFromJSON(jsonArray_extensions.getJSONObject(i)));
1903
- result.extensions = extensions;
1904
- }
1905
- return result;
1906
- } catch (JSONException e) {
1907
- e.printStackTrace();
1908
- }
1909
- return null;
1910
- }
1911
-
1912
- static SignerInfo SignerInfoFromJSON(JSONObject input) {
1913
- try {
1914
- SignerInfo result = new SignerInfo();
1915
- if (input.has("version"))
1916
- result.version = input.getInt("version");
1917
- if (input.has("paStatus"))
1918
- result.paStatus = input.getInt("paStatus");
1919
- if (input.has("dataToHash"))
1920
- result.dataToHash = input.getString("dataToHash");
1921
- if (input.has("digestAlgorithm"))
1922
- result.digestAlgorithm = input.getString("digestAlgorithm");
1923
- if (input.has("signatureAlgorithm"))
1924
- result.signatureAlgorithm = input.getString("signatureAlgorithm");
1925
- if (input.has("serialNumber"))
1926
- result.serialNumber = ValueFromJSON(input.getJSONObject("serialNumber"));
1927
- if (input.has("signature"))
1928
- result.signature = ValueFromJSON(input.getJSONObject("signature"));
1929
- if (input.has("subjectKeyIdentifier"))
1930
- result.subjectKeyIdentifier = ValueFromJSON(input.getJSONObject("subjectKeyIdentifier"));
1931
- if (input.has("issuer"))
1932
- result.issuer = AuthorityFromJSON(input.getJSONObject("issuer"));
1933
- if (input.has("notifications")){
1934
- JSONArray jsonArray_notifications = input.getJSONArray("notifications");
1935
- List<Long> notifications = new ArrayList<>();
1936
- for (int i = 0; i < jsonArray_notifications.length(); i++)
1937
- notifications.add(jsonArray_notifications.getLong(i));
1938
- result.notifications = notifications;
1939
- }
1940
- if (input.has("signedAttributes")){
1941
- JSONArray jsonArray_signedAttributes = input.getJSONArray("signedAttributes");
1942
- List<Extension> signedAttributes = new ArrayList<>();
1943
- for (int i = 0; i < jsonArray_signedAttributes.length(); i++)
1944
- signedAttributes.add(ExtensionFromJSON(jsonArray_signedAttributes.getJSONObject(i)));
1945
- result.signedAttributes = signedAttributes;
1946
- }
1947
- if (input.has("certificateChain")){
1948
- JSONArray jsonArray_certificateChain = input.getJSONArray("certificateChain");
1949
- List<CertificateChain> certificateChain = new ArrayList<>();
1950
- for (int i = 0; i < jsonArray_certificateChain.length(); i++)
1951
- certificateChain.add(CertificateChainFromJSON(jsonArray_certificateChain.getJSONObject(i)));
1952
- result.certificateChain = certificateChain;
1953
- }
1954
- return result;
1955
- } catch (JSONException e) {
1956
- e.printStackTrace();
1957
- }
1958
- return null;
1959
- }
1960
-
1961
- static SecurityObject SecurityObjectFromJSON(JSONObject input) {
1962
- try {
1963
- SecurityObject result = new SecurityObject();
1964
- if (input.has("fileReference"))
1965
- result.fileReference = input.getInt("fileReference");
1966
- if (input.has("version"))
1967
- result.version = input.getInt("version");
1968
- if (input.has("objectType"))
1969
- result.objectType = input.getString("objectType");
1970
- if (input.has("notifications")){
1971
- JSONArray jsonArray_notifications = input.getJSONArray("notifications");
1972
- List<Long> notifications = new ArrayList<>();
1973
- for (int i = 0; i < jsonArray_notifications.length(); i++)
1974
- notifications.add(jsonArray_notifications.getLong(i));
1975
- result.notifications = notifications;
1976
- }
1977
- if (input.has("signerInfos")){
1978
- JSONArray jsonArray_signerInfos = input.getJSONArray("signerInfos");
1979
- List<SignerInfo> signerInfos = new ArrayList<>();
1980
- for (int i = 0; i < jsonArray_signerInfos.length(); i++)
1981
- signerInfos.add(SignerInfoFromJSON(jsonArray_signerInfos.getJSONObject(i)));
1982
- result.signerInfos = signerInfos;
1983
- }
1984
- return result;
1985
- } catch (JSONException e) {
1986
- e.printStackTrace();
1987
- }
1988
- return null;
1989
- }
1990
-
1991
- static CardProperties CardPropertiesFromJSON(JSONObject input) {
1992
- try {
1993
- CardProperties result = new CardProperties();
1994
- if (input.has("aTQA"))
1995
- result.aTQA = input.getInt("aTQA");
1996
- if (input.has("bitRateR"))
1997
- result.bitRateR = input.getInt("bitRateR");
1998
- if (input.has("bitRateS"))
1999
- result.bitRateS = input.getInt("bitRateS");
2000
- if (input.has("chipTypeA"))
2001
- result.chipTypeA = input.getInt("chipTypeA");
2002
- if (input.has("mifareMemory"))
2003
- result.mifareMemory = input.getInt("mifareMemory");
2004
- if (input.has("rfidType"))
2005
- result.rfidType = input.getInt("rfidType");
2006
- if (input.has("sAK"))
2007
- result.sAK = input.getInt("sAK");
2008
- if (input.has("support4"))
2009
- result.support4 = input.getBoolean("support4");
2010
- if (input.has("supportMifare"))
2011
- result.supportMifare = input.getBoolean("supportMifare");
2012
- if (input.has("aTQB"))
2013
- result.aTQB = input.getString("aTQB");
2014
- if (input.has("aTR"))
2015
- result.aTR = input.getString("aTR");
2016
- if (input.has("baudrate1"))
2017
- result.baudrate1 = input.getString("baudrate1");
2018
- if (input.has("baudrate2"))
2019
- result.baudrate2 = input.getString("baudrate2");
2020
- if (input.has("uID"))
2021
- result.uID = input.getString("uID");
2022
- return result;
2023
- } catch (JSONException e) {
2024
- e.printStackTrace();
2025
- }
2026
- return null;
2027
- }
2028
-
2029
- static RFIDSessionData RFIDSessionDataFromJSON(JSONObject input) {
2030
- try {
2031
- RFIDSessionData result = new RFIDSessionData();
2032
- if (input.has("totalBytesReceived"))
2033
- result.totalBytesReceived = input.getInt("totalBytesReceived");
2034
- if (input.has("totalBytesSent"))
2035
- result.totalBytesSent = input.getInt("totalBytesSent");
2036
- if (input.has("status"))
2037
- result.status = input.getInt("status");
2038
- if (input.has("extLeSupport"))
2039
- result.extLeSupport = input.getInt("extLeSupport");
2040
- if (input.has("processTime"))
2041
- result.processTime = input.getInt("processTime");
2042
- if (input.has("cardProperties"))
2043
- result.cardProperties = CardPropertiesFromJSON(input.getJSONObject("cardProperties"));
2044
- if (input.has("accessControls")){
2045
- JSONArray jsonArray_accessControls = input.getJSONArray("accessControls");
2046
- List<AccessControlProcedureType> accessControls = new ArrayList<>();
2047
- for (int i = 0; i < jsonArray_accessControls.length(); i++)
2048
- accessControls.add(AccessControlProcedureTypeFromJSON(jsonArray_accessControls.getJSONObject(i)));
2049
- result.accessControls = accessControls;
2050
- }
2051
- if (input.has("applications")){
2052
- JSONArray jsonArray_applications = input.getJSONArray("applications");
2053
- List<Application> applications = new ArrayList<>();
2054
- for (int i = 0; i < jsonArray_applications.length(); i++)
2055
- applications.add(ApplicationFromJSON(jsonArray_applications.getJSONObject(i)));
2056
- result.applications = applications;
2057
- }
2058
- if (input.has("securityObjects")){
2059
- JSONArray jsonArray_securityObjects = input.getJSONArray("securityObjects");
2060
- List<SecurityObject> securityObjects = new ArrayList<>();
2061
- for (int i = 0; i < jsonArray_securityObjects.length(); i++)
2062
- securityObjects.add(SecurityObjectFromJSON(jsonArray_securityObjects.getJSONObject(i)));
2063
- result.securityObjects = securityObjects;
2064
- }
2065
- return result;
2066
- } catch (JSONException e) {
2067
- e.printStackTrace();
2068
- }
2069
- return null;
2070
- }
2071
-
2072
- static DocumentReaderAuthenticityCheck DocumentReaderAuthenticityCheckFromJSON(JSONObject input) {
2073
- try {
2074
- DocumentReaderAuthenticityCheck result = new DocumentReaderAuthenticityCheck();
2075
- if (input.has("type"))
2076
- result.type = input.getInt("type");
2077
- if (input.has("pageIndex"))
2078
- result.pageIndex = input.getInt("pageIndex");
2079
- if (input.has("elements")){
2080
- JSONArray jsonArray_elements = input.getJSONArray("elements");
2081
- List<DocumentReaderAuthenticityElement> elements = new ArrayList<>();
2082
- for (int i = 0; i < jsonArray_elements.length(); i++)
2083
- elements.add(DocumentReaderAuthenticityElementFromJSON(jsonArray_elements.getJSONObject(i)));
2084
- result.elements = elements;
2085
- }
2086
- return result;
2087
- } catch (JSONException e) {
2088
- e.printStackTrace();
2089
- }
2090
- return null;
2091
- }
2092
-
2093
- static PDF417Info PDF417InfoFromJSON(JSONObject input) {
2094
- try {
2095
- PDF417Info result = new PDF417Info();
2096
- if (input.has("errorLevel"))
2097
- result.errorLevel = input.getInt("errorLevel");
2098
- if (input.has("columns"))
2099
- result.columns = input.getInt("columns");
2100
- if (input.has("rows"))
2101
- result.rows = input.getInt("rows");
2102
- return result;
2103
- } catch (JSONException e) {
2104
- e.printStackTrace();
2105
- }
2106
- return null;
2107
- }
2108
-
2109
- static DocumentReaderBarcodeResult DocumentReaderBarcodeResultFromJSON(JSONObject input) {
2110
- try {
2111
- DocumentReaderBarcodeResult result = new DocumentReaderBarcodeResult();
2112
- if (input.has("fields")){
2113
- JSONArray jsonArray_fields = input.getJSONArray("fields");
2114
- List<DocumentReaderBarcodeField> fields = new ArrayList<>();
2115
- for (int i = 0; i < jsonArray_fields.length(); i++)
2116
- fields.add(DocumentReaderBarcodeFieldFromJSON(jsonArray_fields.getJSONObject(i)));
2117
- result.fields = fields;
2118
- }
2119
- return result;
2120
- } catch (JSONException e) {
2121
- e.printStackTrace();
2122
- }
2123
- return null;
2124
- }
2125
-
2126
- static DocumentReaderBarcodeField DocumentReaderBarcodeFieldFromJSON(JSONObject input) {
2127
- try {
2128
- DocumentReaderBarcodeField result = new DocumentReaderBarcodeField();
2129
- if (input.has("barcodeType"))
2130
- result.barcodeType = input.getInt("barcodeType");
2131
- if (input.has("status"))
2132
- result.status = input.getInt("status");
2133
- if (input.has("pageIndex"))
2134
- result.pageIndex = input.getInt("pageIndex");
2135
- if (input.has("pdf417Info"))
2136
- result.pdf417Info = PDF417InfoFromJSON(input.getJSONObject("pdf417Info"));
2137
- if (input.has("data")){
2138
- JSONArray jsonArray_data = input.getJSONArray("data");
2139
- byte[] data = new byte[jsonArray_data.length()];
2140
- for (int i = 0; i < jsonArray_data.length(); i++)
2141
- data[i] = (byte) jsonArray_data.get(i);
2142
- result.data = data;
2143
- }
2144
- return result;
2145
- } catch (JSONException e) {
2146
- e.printStackTrace();
2147
- }
2148
- return null;
2149
- }
2150
-
2151
- static DocumentReaderAuthenticityResult DocumentReaderAuthenticityResultFromJSON(JSONObject input) {
2152
- try {
2153
- DocumentReaderAuthenticityResult result = new DocumentReaderAuthenticityResult();
2154
- if (input.has("checks")){
2155
- JSONArray jsonArray_checks = input.getJSONArray("checks");
2156
- List<DocumentReaderAuthenticityCheck> checks = new ArrayList<>();
2157
- for (int i = 0; i < jsonArray_checks.length(); i++)
2158
- checks.add(DocumentReaderAuthenticityCheckFromJSON(jsonArray_checks.getJSONObject(i)));
2159
- result.checks = checks;
2160
- }
2161
- return result;
2162
- } catch (JSONException e) {
2163
- e.printStackTrace();
2164
- }
2165
- return null;
2166
- }
2167
-
2168
- static DocumentReaderAuthenticityElement DocumentReaderAuthenticityElementFromJSON(JSONObject input) {
2169
- try {
2170
- DocumentReaderAuthenticityElement result = new DocumentReaderAuthenticityElement();
2171
- if (input.has("status"))
2172
- result.status = input.getInt("status");
2173
- if (input.has("elementType"))
2174
- result.elementType = input.getInt("elementType");
2175
- if (input.has("elementDiagnose"))
2176
- result.elementDiagnose = input.getInt("elementDiagnose");
2177
- return result;
2178
- } catch (JSONException e) {
2179
- e.printStackTrace();
2180
- }
2181
- return null;
2182
- }
2183
-
2184
- static PAResourcesIssuer PAResourcesIssuerFromJSON(JSONObject input) {
2185
- try {
2186
- PAResourcesIssuer result = new PAResourcesIssuer();
2187
- if (input.has("data")){
2188
- JSONArray jsonArray_data = input.getJSONArray("data");
2189
- byte[] data = new byte[jsonArray_data.length()];
2190
- for (int i = 0; i < jsonArray_data.length(); i++)
2191
- data[i] = (byte) jsonArray_data.get(i);
2192
- result.data = data;
2193
- }
2194
- if (input.has("friendlyName"))
2195
- result.friendlyName = input.getString("friendlyName");
2196
- if (input.has("attributes")){
2197
- JSONArray jsonArray_attributes = input.getJSONArray("attributes");
2198
- PAAttribute[] attributes = new PAAttribute[jsonArray_attributes.length()];
2199
- for (int i = 0; i < jsonArray_attributes.length(); i++)
2200
- attributes[i] = PAAttributeFromJSON(jsonArray_attributes.getJSONObject(i));
2201
- result.attributes = attributes;
2202
- }
2203
- return result;
2204
- } catch (JSONException e) {
2205
- e.printStackTrace();
2206
- }
2207
- return null;
2208
- }
2209
-
2210
- static PAAttribute PAAttributeFromJSON(JSONObject input) {
2211
- try {
2212
- PAAttribute result = new PAAttribute();
2213
- if (input.has("type"))
2214
- result.type = input.getString("type");
2215
- if (input.has("value"))
2216
- result.value = input.getString("value");
2217
- return result;
2218
- } catch (JSONException e) {
2219
- e.printStackTrace();
2220
- }
2221
- return null;
2222
- }
2223
-
2224
- static TAChallenge TAChallengeFromJSON(JSONObject input) {
2225
- try {
2226
- TAChallenge result = new TAChallenge();
2227
- if (input.has("data")){
2228
- JSONArray jsonArray_data = input.getJSONArray("data");
2229
- byte[] data = new byte[jsonArray_data.length()];
2230
- for (int i = 0; i < jsonArray_data.length(); i++)
2231
- data[i] = (byte) jsonArray_data.get(i);
2232
- result.data = data;
2233
- }
2234
- if (input.has("auxPCD"))
2235
- result.auxPCD = input.getString("auxPCD");
2236
- if (input.has("challengePICC"))
2237
- result.challengePICC = input.getString("challengePICC");
2238
- if (input.has("hashPK"))
2239
- result.hashPK = input.getString("hashPK");
2240
- if (input.has("idPICC"))
2241
- result.idPICC = input.getString("idPICC");
2242
- return result;
2243
- } catch (JSONException e) {
2244
- e.printStackTrace();
2245
- }
2246
- return null;
2247
- }
2248
-
2249
- static DocumentReaderUvFiberElement DocumentReaderUvFiberElementFromJSON(JSONObject input) {
2250
- try {
2251
- DocumentReaderUvFiberElement result = new DocumentReaderUvFiberElement();
2252
- if (input.has("rectArray")){
2253
- JSONArray jsonArray_rectArray = input.getJSONArray("rectArray");
2254
- List<DocReaderFieldRect> rectArray = new ArrayList<>();
2255
- for (int i = 0; i < jsonArray_rectArray.length(); i++)
2256
- rectArray.add(DocReaderFieldRectFromJSON(jsonArray_rectArray.getJSONObject(i)));
2257
- result.rectArray = rectArray;
2258
- }
2259
- if (input.has("rectCount"))
2260
- result.rectCount = input.getInt("rectCount");
2261
- if (input.has("expectedCount"))
2262
- result.expectedCount = input.getInt("expectedCount");
2263
- if (input.has("width")){
2264
- JSONArray jsonArray_width = input.getJSONArray("width");
2265
- int[] width = new int[jsonArray_width.length()];
2266
- for (int i = 0; i < jsonArray_width.length(); i++)
2267
- width[i] = jsonArray_width.getInt(i);
2268
- result.width = width;
2269
- }
2270
- if (input.has("length")){
2271
- JSONArray jsonArray_length = input.getJSONArray("length");
2272
- int[] length = new int[jsonArray_length.length()];
2273
- for (int i = 0; i < jsonArray_length.length(); i++)
2274
- length[i] = jsonArray_length.getInt(i);
2275
- result.length = length;
2276
- }
2277
- if (input.has("area")){
2278
- JSONArray jsonArray_area = input.getJSONArray("area");
2279
- int[] area = new int[jsonArray_area.length()];
2280
- for (int i = 0; i < jsonArray_area.length(); i++)
2281
- area[i] = jsonArray_area.getInt(i);
2282
- result.area = area;
2283
- }
2284
- if (input.has("colorValues")){
2285
- JSONArray jsonArray_colorValues = input.getJSONArray("colorValues");
2286
- int[] colorValues = new int[jsonArray_colorValues.length()];
2287
- for (int i = 0; i < jsonArray_colorValues.length(); i++)
2288
- colorValues[i] = jsonArray_colorValues.getInt(i);
2289
- result.colorValues = colorValues;
2290
- }
2291
- if (input.has("status"))
2292
- result.status = input.getInt("status");
2293
- if (input.has("elementType"))
2294
- result.elementType = input.getInt("elementType");
2295
- if (input.has("elementDiagnose"))
2296
- result.elementDiagnose = input.getInt("elementDiagnose");
2297
- return result;
2298
- } catch (JSONException e) {
2299
- e.printStackTrace();
2300
- }
2301
- return null;
2302
- }
2303
-
2304
- static DocumentReaderResults DocumentReaderResultsFromJSON(JSONObject input) {
2305
- try {
2306
- DocumentReaderResults result = new DocumentReaderResults();
2307
- if (input.has("chipPage"))
2308
- result.chipPage = input.getInt("chipPage");
2309
- if (input.has("processingFinishedStatus"))
2310
- result.processingFinishedStatus = input.getInt("processingFinishedStatus");
2311
- if (input.has("elapsedTime"))
2312
- result.elapsedTime = input.getInt("elapsedTime");
2313
- if (input.has("elapsedTimeRFID"))
2314
- result.elapsedTimeRFID = input.getInt("elapsedTimeRFID");
2315
- if (input.has("morePagesAvailable"))
2316
- result.morePagesAvailable = input.getInt("morePagesAvailable");
2317
- if (input.has("rfidResult"))
2318
- result.rfidResult = input.getInt("rfidResult");
2319
- if (input.has("highResolution"))
2320
- result.highResolution = input.getBoolean("highResolution");
2321
- if (input.has("graphicResult"))
2322
- result.graphicResult = DocumentReaderGraphicResultFromJSON(input.getJSONObject("graphicResult"));
2323
- if (input.has("textResult"))
2324
- result.textResult = DocumentReaderTextResultFromJSON(input.getJSONObject("textResult"));
2325
- if (input.has("documentPosition")){
2326
- JSONArray jsonArray_documentPosition = input.getJSONArray("documentPosition");
2327
- List<ElementPosition> documentPosition = new ArrayList<>();
2328
- for (int i = 0; i < jsonArray_documentPosition.length(); i++)
2329
- documentPosition.add(ElementPositionFromJSON(jsonArray_documentPosition.getJSONObject(i)));
2330
- result.documentPosition = documentPosition;
2331
- }
2332
- if (input.has("barcodePosition")){
2333
- JSONArray jsonArray_barcodePosition = input.getJSONArray("barcodePosition");
2334
- List<ElementPosition> barcodePosition = new ArrayList<>();
2335
- for (int i = 0; i < jsonArray_barcodePosition.length(); i++)
2336
- barcodePosition.add(ElementPositionFromJSON(jsonArray_barcodePosition.getJSONObject(i)));
2337
- result.barcodePosition = barcodePosition;
2338
- }
2339
- if (input.has("mrzPosition")){
2340
- JSONArray jsonArray_mrzPosition = input.getJSONArray("mrzPosition");
2341
- List<ElementPosition> mrzPosition = new ArrayList<>();
2342
- for (int i = 0; i < jsonArray_mrzPosition.length(); i++)
2343
- mrzPosition.add(ElementPositionFromJSON(jsonArray_mrzPosition.getJSONObject(i)));
2344
- result.mrzPosition = mrzPosition;
2345
- }
2346
- if (input.has("imageQuality")){
2347
- JSONArray jsonArray_imageQuality = input.getJSONArray("imageQuality");
2348
- List<ImageQualityGroup> imageQuality = new ArrayList<>();
2349
- for (int i = 0; i < jsonArray_imageQuality.length(); i++)
2350
- imageQuality.add(ImageQualityGroupFromJSON(jsonArray_imageQuality.getJSONObject(i)));
2351
- result.imageQuality = imageQuality;
2352
- }
2353
- if (input.has("rawResult"))
2354
- result.rawResult = input.getString("rawResult");
2355
- if (input.has("documentReaderNotification"))
2356
- result.documentReaderNotification = DocumentReaderNotificationFromJSON(input.getJSONObject("documentReaderNotification"));
2357
- if (input.has("rfidSessionData"))
2358
- result.rfidSessionData = RFIDSessionDataFromJSON(input.getJSONObject("rfidSessionData"));
2359
- if (input.has("authenticityResult"))
2360
- result.authenticityResult = DocumentReaderAuthenticityResultFromJSON(input.getJSONObject("authenticityResult"));
2361
- if (input.has("barcodeResult"))
2362
- result.barcodeResult = DocumentReaderBarcodeResultFromJSON(input.getJSONObject("barcodeResult"));
2363
- if (input.has("documentType")){
2364
- JSONArray jsonArray_documentType = input.getJSONArray("documentType");
2365
- List<DocumentReaderDocumentType> documentType = new ArrayList<>();
2366
- for (int i = 0; i < jsonArray_documentType.length(); i++)
2367
- documentType.add(DocumentReaderDocumentTypeFromJSON(jsonArray_documentType.getJSONObject(i)));
2368
- result.documentType = documentType;
2369
- }
2370
- return result;
2371
- } catch (JSONException e) {
2372
- e.printStackTrace();
2373
- }
2374
- return null;
2375
- }
1188
+ // From JSON
2376
1189
  }