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

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,88 +124,25 @@ 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;
213
- for (int i = 0; i < array.length; i++)
214
- result.put(i, array[i]);
215
-
216
- return result;
217
- }
218
-
219
- static JSONArray generateDoubleArray(double[] array) throws JSONException {
220
- JSONArray result = new JSONArray();
221
- if(array == null) return result;
145
+ if (array == null) return result;
222
146
  for (int i = 0; i < array.length; i++)
223
147
  result.put(i, array[i]);
224
148
 
@@ -227,7 +151,7 @@ class JSONConstructor {
227
151
 
228
152
  static JSONArray generateByteArray(byte[] array) throws JSONException {
229
153
  JSONArray result = new JSONArray();
230
- if(array == null) return result;
154
+ if (array == null) return result;
231
155
  for (int i = 0; i < array.length; i++)
232
156
  result.put(i, array[i]);
233
157
 
@@ -236,33 +160,13 @@ class JSONConstructor {
236
160
 
237
161
  static JSONArray generateLongArray(long[] array) throws JSONException {
238
162
  JSONArray result = new JSONArray();
239
- if(array == null) return result;
163
+ if (array == null) return result;
240
164
  for (int i = 0; i < array.length; i++)
241
165
  result.put(i, array[i]);
242
166
 
243
167
  return result;
244
168
  }
245
169
 
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
170
  static JSONObject generateVideoEncoderCompletion(String sessionId, java.io.File file) {
267
171
  JSONObject result = new JSONObject();
268
172
 
@@ -307,8 +211,8 @@ class JSONConstructor {
307
211
  JSONObject result = new JSONObject();
308
212
  try {
309
213
  result.put("notification", notification);
310
- if(value != null)
311
- result.put("value", value.get(RFID_EXTRA_ERROR_CODE));
214
+ if (value != null)
215
+ result.put("value", value.get(RFID_EXTRA_ERROR_CODE));
312
216
  } catch (JSONException ignored) {
313
217
  }
314
218
 
@@ -332,16 +236,6 @@ class JSONConstructor {
332
236
  return new JSONObject();
333
237
  }
334
238
 
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
239
  static TccParams TCCParamsFromJSON(JSONObject input) {
346
240
  TccParams result = new TccParams();
347
241
  try {
@@ -362,13 +256,13 @@ class JSONConstructor {
362
256
  }
363
257
 
364
258
  static DocReaderConfig DocReaderConfigFromJSON(JSONObject input) {
365
- DocReaderConfig result = new DocReaderConfig(null);
259
+ DocReaderConfig result;
366
260
  byte[] license;
367
261
  try {
368
262
  if (input.has("license")) {
369
263
  license = Base64.decode(input.getString("license"), Base64.DEFAULT);
370
264
  result = new DocReaderConfig(license);
371
- } else return result;
265
+ } else return null;
372
266
  if (input.has("customDb"))
373
267
  result = new DocReaderConfig(license, Base64.decode(input.getString("customDb"), Base64.DEFAULT));
374
268
  if (input.has("licenseUpdate"))
@@ -377,28 +271,29 @@ class JSONConstructor {
377
271
  result.setDelayedNNLoad(input.getBoolean("delayedNNLoad"));
378
272
  if (input.has("blackList"))
379
273
  result.setBlackList(input.getJSONObject("blackList"));
274
+
275
+ return result;
380
276
  } catch (JSONException e) {
381
277
  e.printStackTrace();
382
278
  }
383
- return result;
279
+ return null;
384
280
  }
385
281
 
386
282
  static ImageInputData ImageInputDataFromJSON(JSONObject input) {
387
- ImageInputData result = new ImageInputData(null);
283
+ ImageInputData result = null;
388
284
  int pageIndex = 0;
389
285
  int light = 6;
390
- int type = 254;
391
286
  int width = 0;
392
287
  int height = 0;
393
288
  Bitmap bitmap;
394
289
  byte[] imgBytes;
395
290
 
396
291
  try {
397
- if(input.has("pageIndex"))
292
+ if (input.has("pageIndex"))
398
293
  pageIndex = input.optInt("pageIndex");
399
- if(input.has("light"))
294
+ if (input.has("light"))
400
295
  pageIndex = input.optInt("light");
401
- if(input.has("type"))
296
+ if (input.has("type"))
402
297
  pageIndex = input.optInt("type");
403
298
  if (input.has("bitmap")) {
404
299
  bitmap = Helpers.bitmapFromBase64(input.getString("bitmap"));
@@ -419,19 +314,11 @@ class JSONConstructor {
419
314
  return result;
420
315
  }
421
316
 
422
- static Throwable ThrowableFromJSON(JSONObject jsonObject) {
423
- return new Throwable();
424
- }
425
-
426
- static StackTraceElement StackTraceElementFromJSON(JSONObject jsonObject) {
427
- return null;
428
- }
429
-
430
317
  // To JSON
431
318
 
432
319
  static JSONObject generateDocumentReaderScenario(DocumentReaderScenario input) {
433
320
  JSONObject result = new JSONObject();
434
- if (input == null) return result;
321
+ if (input == null) return null;
435
322
  try {
436
323
  result.put("name", input.name);
437
324
  result.put("caption", input.caption);
@@ -444,7 +331,7 @@ class JSONConstructor {
444
331
 
445
332
  static JSONObject generateCoreDetailedScenario(CoreDetailedScenario input) {
446
333
  JSONObject result = new JSONObject();
447
- if (input == null) return result;
334
+ if (input == null) return null;
448
335
  try {
449
336
  result.put("uvTorch", input.uvTorch);
450
337
  result.put("frameOrientation", input.frameOrientation);
@@ -467,7 +354,7 @@ class JSONConstructor {
467
354
 
468
355
  static JSONObject generateFaceMetaData(FaceMetaData input) {
469
356
  JSONObject result = new JSONObject();
470
- if (input == null) return result;
357
+ if (input == null) return null;
471
358
  try {
472
359
  result.put("ID", input.ID);
473
360
  result.put("rollAngle", input.rollAngle);
@@ -480,7 +367,7 @@ class JSONConstructor {
480
367
 
481
368
  static JSONObject generateBounds(Bounds input) {
482
369
  JSONObject result = new JSONObject();
483
- if (input == null) return result;
370
+ if (input == null) return null;
484
371
  try {
485
372
  result.put("x", input.x);
486
373
  result.put("y", input.y);
@@ -494,7 +381,7 @@ class JSONConstructor {
494
381
 
495
382
  static JSONObject generateRect(Rect input) {
496
383
  JSONObject result = new JSONObject();
497
- if (input == null) return result;
384
+ if (input == null) return null;
498
385
  try {
499
386
  result.put("bottom", input.bottom);
500
387
  result.put("top", input.top);
@@ -508,7 +395,7 @@ class JSONConstructor {
508
395
 
509
396
  static JSONObject generateDocReaderFieldRect(DocReaderFieldRect input) {
510
397
  JSONObject result = new JSONObject();
511
- if (input == null) return result;
398
+ if (input == null) return null;
512
399
  try {
513
400
  result.put("bottom", input.bottom);
514
401
  result.put("top", input.top);
@@ -522,7 +409,7 @@ class JSONConstructor {
522
409
 
523
410
  static JSONObject generateDocumentReaderGraphicField(DocumentReaderGraphicField input, Context context) {
524
411
  JSONObject result = new JSONObject();
525
- if (input == null) return result;
412
+ if (input == null) return null;
526
413
  try {
527
414
  result.put("sourceType", input.sourceType);
528
415
  result.put("fieldType", input.fieldType);
@@ -540,7 +427,7 @@ class JSONConstructor {
540
427
 
541
428
  static JSONObject generateDocumentReaderGraphicResult(DocumentReaderGraphicResult input, Context context) {
542
429
  JSONObject result = new JSONObject();
543
- if (input == null) return result;
430
+ if (input == null) return null;
544
431
  try {
545
432
  result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderGraphicField, context));
546
433
  } catch (JSONException e) {
@@ -549,9 +436,9 @@ class JSONConstructor {
549
436
  return result;
550
437
  }
551
438
 
552
- static JSONObject generateDocumentReaderValue(DocumentReaderValue input) {
439
+ static JSONObject generateDocumentReaderValue(DocumentReaderValue input, Context context) {
553
440
  JSONObject result = new JSONObject();
554
- if (input == null) return result;
441
+ if (input == null) return null;
555
442
  try {
556
443
  result.put("pageIndex", input.pageIndex);
557
444
  result.put("sourceType", input.sourceType);
@@ -561,6 +448,8 @@ class JSONConstructor {
561
448
  result.put("originalValue", input.originalValue);
562
449
  result.put("boundRect", generateRect(input.boundRect));
563
450
  result.put("comparison", generateMap(input.comparison));
451
+ result.put("originalSymbols", generateList(input.originalSymbols, JSONConstructor::generateDocumentReaderSymbol));
452
+ result.put("rfidOrigin", generateDocumentReaderRfidOrigin(input.rfidOrigin));
564
453
  } catch (JSONException e) {
565
454
  e.printStackTrace();
566
455
  }
@@ -569,15 +458,18 @@ class JSONConstructor {
569
458
 
570
459
  static JSONObject generateDocumentReaderTextField(DocumentReaderTextField input, Context context) {
571
460
  JSONObject result = new JSONObject();
572
- if (input == null) return result;
461
+ if (input == null) return null;
573
462
  try {
574
463
  result.put("fieldType", input.fieldType);
575
464
  result.put("lcid", input.lcid);
576
465
  result.put("status", input.status);
577
466
  result.put("lcidName", input.getLcidName(context));
578
467
  result.put("fieldName", input.getFieldName(context));
579
- result.put("value", generateDocumentReaderValue(input.value()));
580
- result.put("values", generateList(input.values, JSONConstructor::generateDocumentReaderValue));
468
+ result.put("value", input.value);
469
+ result.put("getValue", generateDocumentReaderValue(input.value(), context));
470
+ result.put("values", generateList(input.values, JSONConstructor::generateDocumentReaderValue, context));
471
+ result.put("comparisonList", generateList(input.comparisonList, JSONConstructor::generateDocumentReaderComparison));
472
+ result.put("validityList", generateList(input.validityList, JSONConstructor::generateDocumentReaderValidity));
581
473
  } catch (JSONException e) {
582
474
  e.printStackTrace();
583
475
  }
@@ -586,9 +478,12 @@ class JSONConstructor {
586
478
 
587
479
  static JSONObject generateDocumentReaderTextResult(DocumentReaderTextResult input, Context context) {
588
480
  JSONObject result = new JSONObject();
589
- if (input == null) return result;
481
+ if (input == null) return null;
590
482
  try {
591
483
  result.put("status", input.status);
484
+ result.put("comparisonStatus", input.comparisonStatus);
485
+ result.put("validityStatus", input.validityStatus);
486
+ result.put("availableSourceList", generateList(input.availableSourceList, JSONConstructor::generateDocumentReaderTextSource));
592
487
  result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderTextField, context));
593
488
  } catch (JSONException e) {
594
489
  e.printStackTrace();
@@ -598,7 +493,7 @@ class JSONConstructor {
598
493
 
599
494
  static JSONObject generateCoordinate(Coordinate input) {
600
495
  JSONObject result = new JSONObject();
601
- if (input == null) return result;
496
+ if (input == null) return null;
602
497
  try {
603
498
  result.put("x", input.x);
604
499
  result.put("y", input.y);
@@ -610,7 +505,7 @@ class JSONConstructor {
610
505
 
611
506
  static JSONObject generateElementPosition(ElementPosition input) {
612
507
  JSONObject result = new JSONObject();
613
- if (input == null) return result;
508
+ if (input == null) return null;
614
509
  try {
615
510
  result.put("docFormat", input.docFormat);
616
511
  result.put("width", input.width);
@@ -636,7 +531,7 @@ class JSONConstructor {
636
531
 
637
532
  static JSONObject generateImageQuality(ImageQuality input) {
638
533
  JSONObject result = new JSONObject();
639
- if (input == null) return result;
534
+ if (input == null) return null;
640
535
  try {
641
536
  result.put("featureType", input.featureType);
642
537
  result.put("result", input.result);
@@ -649,7 +544,7 @@ class JSONConstructor {
649
544
 
650
545
  static JSONObject generateImageQualityGroup(ImageQualityGroup input) {
651
546
  JSONObject result = new JSONObject();
652
- if (input == null) return result;
547
+ if (input == null) return null;
653
548
  try {
654
549
  result.put("count", input.count);
655
550
  result.put("result", input.result);
@@ -663,7 +558,7 @@ class JSONConstructor {
663
558
 
664
559
  static JSONObject generateDocumentReaderDocumentType(DocumentReaderDocumentType input) {
665
560
  JSONObject result = new JSONObject();
666
- if (input == null) return result;
561
+ if (input == null) return null;
667
562
  try {
668
563
  result.put("pageIndex", input.pageIndex);
669
564
  result.put("documentID", input.documentID);
@@ -684,7 +579,7 @@ class JSONConstructor {
684
579
 
685
580
  static JSONObject generateDocumentReaderNotification(DocumentReaderNotification input) {
686
581
  JSONObject result = new JSONObject();
687
- if (input == null) return result;
582
+ if (input == null) return null;
688
583
  try {
689
584
  result.put("code", input.getNotificationCode());
690
585
  result.put("attachment", input.getDataFileType());
@@ -697,7 +592,7 @@ class JSONConstructor {
697
592
 
698
593
  static JSONObject generateAccessControlProcedureType(AccessControlProcedureType input) {
699
594
  JSONObject result = new JSONObject();
700
- if (input == null) return result;
595
+ if (input == null) return null;
701
596
  try {
702
597
  result.put("activeOptionIdx", input.activeOptionIdx);
703
598
  result.put("type", input.type);
@@ -711,7 +606,7 @@ class JSONConstructor {
711
606
 
712
607
  static JSONObject generateFileData(FileData input) {
713
608
  JSONObject result = new JSONObject();
714
- if (input == null) return result;
609
+ if (input == null) return null;
715
610
  try {
716
611
  result.put("length", input.length);
717
612
  result.put("type", input.type);
@@ -725,7 +620,7 @@ class JSONConstructor {
725
620
 
726
621
  static JSONObject generateCertificateData(CertificateData input) {
727
622
  JSONObject result = new JSONObject();
728
- if (input == null) return result;
623
+ if (input == null) return null;
729
624
  try {
730
625
  result.put("length", input.length);
731
626
  result.put("data", input.data);
@@ -737,7 +632,7 @@ class JSONConstructor {
737
632
 
738
633
  static JSONObject generateSecurityObjectCertificates(SecurityObjectCertificates input) {
739
634
  JSONObject result = new JSONObject();
740
- if (input == null) return result;
635
+ if (input == null) return null;
741
636
  try {
742
637
  result.put("securityObject", generateCertificateData(input.securityObject));
743
638
  } catch (JSONException e) {
@@ -748,7 +643,7 @@ class JSONConstructor {
748
643
 
749
644
  static JSONObject generateFile(File input) {
750
645
  JSONObject result = new JSONObject();
751
- if (input == null) return result;
646
+ if (input == null) return null;
752
647
  try {
753
648
  result.put("readingTime", input.readingTime);
754
649
  result.put("type", input.type);
@@ -769,7 +664,7 @@ class JSONConstructor {
769
664
 
770
665
  static JSONObject generateApplication(Application input) {
771
666
  JSONObject result = new JSONObject();
772
- if (input == null) return result;
667
+ if (input == null) return null;
773
668
  try {
774
669
  result.put("type", input.type);
775
670
  result.put("status", input.status);
@@ -786,7 +681,7 @@ class JSONConstructor {
786
681
 
787
682
  static JSONObject generateValue(Value input) {
788
683
  JSONObject result = new JSONObject();
789
- if (input == null) return result;
684
+ if (input == null) return null;
790
685
  try {
791
686
  result.put("length", input.length);
792
687
  result.put("type", input.type);
@@ -801,7 +696,7 @@ class JSONConstructor {
801
696
 
802
697
  static JSONObject generateAttribute(Attribute input) {
803
698
  JSONObject result = new JSONObject();
804
- if (input == null) return result;
699
+ if (input == null) return null;
805
700
  try {
806
701
  result.put("type", input.type);
807
702
  result.put("value", generateValue(input.value));
@@ -813,7 +708,7 @@ class JSONConstructor {
813
708
 
814
709
  static JSONObject generateAuthority(Authority input) {
815
710
  JSONObject result = new JSONObject();
816
- if (input == null) return result;
711
+ if (input == null) return null;
817
712
  try {
818
713
  result.put("data", input.data);
819
714
  result.put("friendlyName", generateValue(input.friendlyName));
@@ -826,7 +721,7 @@ class JSONConstructor {
826
721
 
827
722
  static JSONObject generateExtension(Extension input) {
828
723
  JSONObject result = new JSONObject();
829
- if (input == null) return result;
724
+ if (input == null) return null;
830
725
  try {
831
726
  result.put("data", input.data);
832
727
  result.put("type", input.type);
@@ -838,7 +733,7 @@ class JSONConstructor {
838
733
 
839
734
  static JSONObject generateValidity(Validity input) {
840
735
  JSONObject result = new JSONObject();
841
- if (input == null) return result;
736
+ if (input == null) return null;
842
737
  try {
843
738
  result.put("notAfter", generateValue(input.notAfter));
844
739
  result.put("notBefore", generateValue(input.notBefore));
@@ -850,7 +745,7 @@ class JSONConstructor {
850
745
 
851
746
  static JSONObject generateCertificateChain(CertificateChain input) {
852
747
  JSONObject result = new JSONObject();
853
- if (input == null) return result;
748
+ if (input == null) return null;
854
749
  try {
855
750
  result.put("origin", input.origin);
856
751
  result.put("type", input.type);
@@ -873,7 +768,7 @@ class JSONConstructor {
873
768
 
874
769
  static JSONObject generateSignerInfo(SignerInfo input) {
875
770
  JSONObject result = new JSONObject();
876
- if (input == null) return result;
771
+ if (input == null) return null;
877
772
  try {
878
773
  result.put("version", input.version);
879
774
  result.put("paStatus", input.paStatus);
@@ -895,7 +790,7 @@ class JSONConstructor {
895
790
 
896
791
  static JSONObject generateSecurityObject(SecurityObject input) {
897
792
  JSONObject result = new JSONObject();
898
- if (input == null) return result;
793
+ if (input == null) return null;
899
794
  try {
900
795
  result.put("fileReference", input.fileReference);
901
796
  result.put("version", input.version);
@@ -910,7 +805,7 @@ class JSONConstructor {
910
805
 
911
806
  static JSONObject generateCardProperties(CardProperties input) {
912
807
  JSONObject result = new JSONObject();
913
- if (input == null) return result;
808
+ if (input == null) return null;
914
809
  try {
915
810
  result.put("aTQA", input.aTQA);
916
811
  result.put("bitRateR", input.bitRateR);
@@ -934,7 +829,7 @@ class JSONConstructor {
934
829
 
935
830
  static JSONObject generateRFIDSessionData(RFIDSessionData input) {
936
831
  JSONObject result = new JSONObject();
937
- if (input == null) return result;
832
+ if (input == null) return null;
938
833
  try {
939
834
  result.put("totalBytesReceived", input.totalBytesReceived);
940
835
  result.put("totalBytesSent", input.totalBytesSent);
@@ -953,7 +848,7 @@ class JSONConstructor {
953
848
 
954
849
  static JSONObject generateDocumentReaderAuthenticityCheck(DocumentReaderAuthenticityCheck input, Context context) {
955
850
  JSONObject result = new JSONObject();
956
- if (input == null) return result;
851
+ if (input == null) return null;
957
852
  try {
958
853
  result.put("type", input.type);
959
854
  result.put("status", input.getStatus());
@@ -968,7 +863,7 @@ class JSONConstructor {
968
863
 
969
864
  static JSONObject generatePDF417Info(PDF417Info input) {
970
865
  JSONObject result = new JSONObject();
971
- if (input == null) return result;
866
+ if (input == null) return null;
972
867
  try {
973
868
  result.put("errorLevel", input.errorLevel);
974
869
  result.put("columns", input.columns);
@@ -981,7 +876,7 @@ class JSONConstructor {
981
876
 
982
877
  static JSONObject generateDocumentReaderBarcodeResult(DocumentReaderBarcodeResult input) {
983
878
  JSONObject result = new JSONObject();
984
- if (input == null) return result;
879
+ if (input == null) return null;
985
880
  try {
986
881
  result.put("fields", generateList(input.fields, JSONConstructor::generateDocumentReaderBarcodeField));
987
882
  } catch (JSONException e) {
@@ -992,7 +887,7 @@ class JSONConstructor {
992
887
 
993
888
  static JSONObject generateDocumentReaderBarcodeField(DocumentReaderBarcodeField input) {
994
889
  JSONObject result = new JSONObject();
995
- if (input == null) return result;
890
+ if (input == null) return null;
996
891
  try {
997
892
  result.put("barcodeType", input.barcodeType);
998
893
  result.put("status", input.status);
@@ -1007,7 +902,7 @@ class JSONConstructor {
1007
902
 
1008
903
  static JSONObject generateDocumentReaderAuthenticityResult(DocumentReaderAuthenticityResult input, Context context) {
1009
904
  JSONObject result = new JSONObject();
1010
- if (input == null) return result;
905
+ if (input == null) return null;
1011
906
  try {
1012
907
  result.put("status", input.getStatus());
1013
908
  result.put("checks", generateList(input.checks, JSONConstructor::generateDocumentReaderAuthenticityCheck, context));
@@ -1019,7 +914,7 @@ class JSONConstructor {
1019
914
 
1020
915
  static JSONObject generateDocumentReaderAuthenticityElement(DocumentReaderAuthenticityElement input, Context context) {
1021
916
  JSONObject result = new JSONObject();
1022
- if (input == null) return result;
917
+ if (input == null) return null;
1023
918
  try {
1024
919
  result.put("status", input.status);
1025
920
  result.put("elementType", input.elementType);
@@ -1034,43 +929,10 @@ class JSONConstructor {
1034
929
 
1035
930
  static JSONObject generateDocumentReaderException(DocumentReaderException input) {
1036
931
  JSONObject result = new JSONObject();
1037
- if (input == null) return result;
932
+ if (input == null) return null;
1038
933
  try {
1039
934
  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
935
  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
936
  } catch (JSONException e) {
1075
937
  e.printStackTrace();
1076
938
  }
@@ -1079,7 +941,7 @@ class JSONConstructor {
1079
941
 
1080
942
  static JSONObject generatePAResourcesIssuer(PAResourcesIssuer input) {
1081
943
  JSONObject result = new JSONObject();
1082
- if (input == null) return result;
944
+ if (input == null) return null;
1083
945
  try {
1084
946
  result.put("data", generateByteArray(input.data));
1085
947
  result.put("friendlyName", input.friendlyName);
@@ -1092,7 +954,7 @@ class JSONConstructor {
1092
954
 
1093
955
  static JSONObject generatePAAttribute(PAAttribute input) {
1094
956
  JSONObject result = new JSONObject();
1095
- if (input == null) return result;
957
+ if (input == null) return null;
1096
958
  try {
1097
959
  result.put("type", input.type);
1098
960
  result.put("value", input.value);
@@ -1104,7 +966,7 @@ class JSONConstructor {
1104
966
 
1105
967
  static JSONObject generateTAChallenge(TAChallenge input) {
1106
968
  JSONObject result = new JSONObject();
1107
- if (input == null) return result;
969
+ if (input == null) return null;
1108
970
  try {
1109
971
  result.put("data", generateByteArray(input.data));
1110
972
  result.put("auxPCD", input.auxPCD);
@@ -1119,7 +981,7 @@ class JSONConstructor {
1119
981
 
1120
982
  static JSONObject generateDocumentReaderResultsStatus(DocumentReaderResultsStatus input) {
1121
983
  JSONObject result = new JSONObject();
1122
- if (input == null) return result;
984
+ if (input == null) return null;
1123
985
  try {
1124
986
  result.put("overallStatus", input.getOverallStatus());
1125
987
  result.put("optical", input.getOptical());
@@ -1136,7 +998,7 @@ class JSONConstructor {
1136
998
 
1137
999
  static JSONObject generateDetailsOptical(DocumentReaderResultsStatus.DetailsOptical input) {
1138
1000
  JSONObject result = new JSONObject();
1139
- if (input == null) return result;
1001
+ if (input == null) return null;
1140
1002
  try {
1141
1003
  result.put("overallStatus", input.getOverallStatus());
1142
1004
  result.put("mrz", input.getMrz());
@@ -1155,7 +1017,7 @@ class JSONConstructor {
1155
1017
 
1156
1018
  static JSONObject generateDetailsRFID(DocumentReaderResultsStatus.DetailsRFID input) {
1157
1019
  JSONObject result = new JSONObject();
1158
- if (input == null) return result;
1020
+ if (input == null) return null;
1159
1021
  try {
1160
1022
  result.put("pa", input.getPA());
1161
1023
  result.put("ca", input.getCA());
@@ -1172,7 +1034,7 @@ class JSONConstructor {
1172
1034
 
1173
1035
  static JSONObject generateVDSNCData(VDSNCData input) {
1174
1036
  JSONObject result = new JSONObject();
1175
- if (input == null) return result;
1037
+ if (input == null) return null;
1176
1038
  try {
1177
1039
  result.put("type", input.getType());
1178
1040
  result.put("version", input.getVersion());
@@ -1191,7 +1053,7 @@ class JSONConstructor {
1191
1053
 
1192
1054
  static JSONObject generateBytesData(BytesData input) {
1193
1055
  JSONObject result = new JSONObject();
1194
- if (input == null) return result;
1056
+ if (input == null) return null;
1195
1057
  try {
1196
1058
  result.put("data", input.getData());
1197
1059
  result.put("length", input.getLength());
@@ -1203,1174 +1065,117 @@ class JSONConstructor {
1203
1065
  return result;
1204
1066
  }
1205
1067
 
1206
- static JSONObject generateDocumentReaderUvFiberElement(DocumentReaderUvFiberElement input, Context context) {
1068
+ static JSONObject generateDocReaderDocumentsDatabase(DocReaderDocumentsDatabase input) {
1207
1069
  JSONObject result = new JSONObject();
1208
- if (input == null) return result;
1070
+ if (input == null) return null;
1209
1071
  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));
1072
+ result.put("databaseID", input.databaseID);
1073
+ result.put("version", input.version);
1074
+ result.put("date", input.date);
1075
+ result.put("databaseDescription", input.databaseDescription);
1076
+ result.put("countriesNumber", input.countriesNumber);
1077
+ result.put("documentsNumber", input.documentsNumber);
1222
1078
  } catch (JSONException e) {
1223
1079
  e.printStackTrace();
1224
1080
  }
1225
1081
  return result;
1226
1082
  }
1227
1083
 
1228
- static JSONObject generateImageInputData(ImageInputData input) {
1084
+ static JSONObject generateDocumentReaderComparison(DocumentReaderComparison input) {
1229
1085
  JSONObject result = new JSONObject();
1230
- if (input == null) return result;
1086
+ if (input == null) return null;
1231
1087
  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()));
1088
+ result.put("sourceTypeLeft", input.sourceTypeLeft);
1089
+ result.put("sourceTypeRight", input.sourceTypeRight);
1090
+ result.put("status", input.status);
1239
1091
  } catch (JSONException e) {
1240
1092
  e.printStackTrace();
1241
1093
  }
1242
1094
  return result;
1243
1095
  }
1244
1096
 
1245
- static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Context context) {
1097
+ static JSONObject generateDocumentReaderRfidOrigin(DocumentReaderRfidOrigin input) {
1246
1098
  JSONObject result = new JSONObject();
1247
- if (input == null) return result;
1099
+ if (input == null) return null;
1248
1100
  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));
1101
+ result.put("dg", input.dg);
1102
+ result.put("dgTag", input.dgTag);
1103
+ result.put("entryView", input.entryView);
1104
+ result.put("tagEntry", input.tagEntry);
1270
1105
  } catch (JSONException e) {
1271
1106
  e.printStackTrace();
1272
1107
  }
1273
1108
  return result;
1274
1109
  }
1275
1110
 
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) {
1111
+ static JSONObject generateDocumentReaderTextSource(DocumentReaderTextSource input) {
1112
+ JSONObject result = new JSONObject();
1113
+ if (input == null) return null;
1485
1114
  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;
1115
+ result.put("sourceType", input.sourceType);
1116
+ result.put("source", input.source);
1117
+ result.put("validityStatus", input.validityStatus);
1497
1118
  } catch (JSONException e) {
1498
1119
  e.printStackTrace();
1499
1120
  }
1500
- return null;
1121
+ return result;
1501
1122
  }
1502
1123
 
1503
- static Coordinate CoordinateFromJSON(JSONObject input) {
1124
+ static JSONObject generateDocumentReaderSymbol(DocumentReaderSymbol input) {
1125
+ JSONObject result = new JSONObject();
1126
+ if (input == null) return null;
1504
1127
  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;
1128
+ result.put("code", input.code);
1129
+ result.put("rect", generateRect(input.rect));
1130
+ result.put("probability", input.probability);
1511
1131
  } catch (JSONException e) {
1512
1132
  e.printStackTrace();
1513
1133
  }
1514
- return null;
1134
+ return result;
1515
1135
  }
1516
1136
 
1517
- static ElementPosition ElementPositionFromJSON(JSONObject input) {
1137
+ static JSONObject generateDocumentReaderValidity(DocumentReaderValidity input) {
1138
+ JSONObject result = new JSONObject();
1139
+ if (input == null) return null;
1518
1140
  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;
1141
+ result.put("sourceType", input.sourceType);
1142
+ result.put("status", input.status);
1553
1143
  } catch (JSONException e) {
1554
1144
  e.printStackTrace();
1555
1145
  }
1556
- return null;
1146
+ return result;
1557
1147
  }
1558
1148
 
1559
- static ImageQuality ImageQualityFromJSON(JSONObject input) {
1149
+ static JSONObject generateDocumentReaderResults(DocumentReaderResults input, Context context) {
1150
+ JSONObject result = new JSONObject();
1151
+ if (input == null) return null;
1560
1152
  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;
1153
+ result.put("chipPage", input.chipPage);
1154
+ result.put("processingFinishedStatus", input.processingFinishedStatus);
1155
+ result.put("elapsedTime", input.elapsedTime);
1156
+ result.put("elapsedTimeRFID", input.elapsedTimeRFID);
1157
+ result.put("morePagesAvailable", input.morePagesAvailable);
1158
+ result.put("rfidResult", input.rfidResult);
1159
+ result.put("highResolution", input.highResolution);
1160
+ result.put("graphicResult", generateDocumentReaderGraphicResult(input.graphicResult, context));
1161
+ result.put("textResult", generateDocumentReaderTextResult(input.textResult, context));
1162
+ result.put("documentPosition", generateList(input.documentPosition, JSONConstructor::generateElementPosition));
1163
+ result.put("barcodePosition", generateList(input.barcodePosition, JSONConstructor::generateElementPosition));
1164
+ result.put("mrzPosition", generateList(input.mrzPosition, JSONConstructor::generateElementPosition));
1165
+ result.put("imageQuality", generateList(input.imageQuality, JSONConstructor::generateImageQualityGroup));
1166
+ result.put("rawResult", input.rawResult);
1167
+ result.put("documentReaderNotification", generateDocumentReaderNotification(input.documentReaderNotification));
1168
+ result.put("rfidSessionData", generateRFIDSessionData(input.rfidSessionData));
1169
+ result.put("authenticityResult", generateDocumentReaderAuthenticityResult(input.authenticityResult, context));
1170
+ result.put("barcodeResult", generateDocumentReaderBarcodeResult(input.barcodeResult));
1171
+ result.put("documentType", generateList(input.documentType, JSONConstructor::generateDocumentReaderDocumentType));
1172
+ result.put("status", generateDocumentReaderResultsStatus(input.status));
1173
+ result.put("vdsncData", generateVDSNCData(input.vdsncData));
1569
1174
  } catch (JSONException e) {
1570
1175
  e.printStackTrace();
1571
1176
  }
1572
- return null;
1177
+ return result;
1573
1178
  }
1574
1179
 
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
- }
1180
+ // From JSON
2376
1181
  }