|
1 | 1 | package com.regula.documentreader.webclient.model.ext;
|
2 | 2 |
|
| 3 | +import com.regula.documentreader.webclient.model.LCID; |
| 4 | + |
| 5 | +import java.util.Objects; |
3 | 6 | import javax.annotation.Nullable;
|
4 | 7 |
|
5 | 8 | public class Text extends com.regula.documentreader.webclient.model.Text {
|
6 | 9 |
|
7 | 10 | @Nullable
|
8 |
| - public TextField getField(int fieldType, int lcid) { |
| 11 | + public TextField getField(int fieldType) { |
| 12 | + TextField result = null; |
9 | 13 | for (TextField field : getFieldList()) {
|
10 |
| - if (field.getFieldType() == fieldType && field.getLcid() == lcid) { |
| 14 | + if (field.getFieldType() == fieldType && field.getLcid() == LCID.LATIN) { |
11 | 15 | return field;
|
12 | 16 | }
|
| 17 | + if (result == null && field.getFieldType() == fieldType) { |
| 18 | + result = field; |
| 19 | + } |
13 | 20 | }
|
14 |
| - return null; |
| 21 | + return result; |
15 | 22 | }
|
16 | 23 |
|
17 | 24 | @Nullable
|
18 |
| - public TextField getField(int fieldType) { |
19 |
| - return getField(fieldType, 0); |
20 |
| - } |
21 |
| - |
22 |
| - @Nullable |
23 |
| - public String getFieldValue(int fieldType, int lcid) { |
24 |
| - TextField field = getField(fieldType, lcid); |
25 |
| - if (field != null) { |
26 |
| - return field.getValue(); |
| 25 | + public TextField getField(int fieldType, int lcid) { |
| 26 | + for (TextField field : getFieldList()) { |
| 27 | + if (field.getFieldType() == fieldType && field.getLcid() == lcid) { |
| 28 | + return field; |
| 29 | + } |
27 | 30 | }
|
28 | 31 | return null;
|
29 | 32 | }
|
30 | 33 |
|
31 | 34 | @Nullable
|
32 |
| - public String getFieldValue(int fieldType) { |
33 |
| - return getFieldValue(fieldType, 0); |
| 35 | + public TextField getField(String fieldName) { |
| 36 | + TextField result = null; |
| 37 | + for (TextField field : getFieldList()) { |
| 38 | + if (Objects.equals(field.getFieldName(), fieldName) && field.getLcid() == LCID.LATIN) { |
| 39 | + return field; |
| 40 | + } |
| 41 | + if (result == null && Objects.equals(field.getFieldName(), fieldName)) { |
| 42 | + result = field; |
| 43 | + } |
| 44 | + } |
| 45 | + return result; |
34 | 46 | }
|
35 | 47 |
|
36 | 48 | @Nullable
|
37 |
| - public TextField getFieldByName(String fieldName, int lcid) { |
| 49 | + public TextField getField(String fieldName, int lcid) { |
38 | 50 | for (TextField field : getFieldList()) {
|
39 |
| - if (field.getFieldName().equals(fieldName) && field.getLcid() == lcid) { |
| 51 | + if (Objects.equals(field.getFieldName(), fieldName) && field.getLcid() == lcid) { |
40 | 52 | return field;
|
41 | 53 | }
|
42 | 54 | }
|
43 | 55 | return null;
|
44 | 56 | }
|
45 | 57 |
|
46 | 58 | @Nullable
|
47 |
| - public TextField getFieldByName(String fieldName) { |
48 |
| - return getFieldByName(fieldName, 0); |
| 59 | + public String getFieldValue(int fieldType) { |
| 60 | + TextField field = getField(fieldType); |
| 61 | + if (field != null) return field.getValue(); |
| 62 | + return null; |
| 63 | + } |
| 64 | + |
| 65 | + @Nullable |
| 66 | + public String getFieldValue(int fieldType, int lcid) { |
| 67 | + TextField field = getField(fieldType, lcid); |
| 68 | + if (field != null) return field.getValue(); |
| 69 | + return null; |
49 | 70 | }
|
50 | 71 |
|
51 | 72 | @Nullable
|
52 |
| - public String getFieldValueByName(String fieldName, int lcid) { |
53 |
| - TextField field = getFieldByName(fieldName, lcid); |
54 |
| - if (field != null) { |
55 |
| - return field.getValue(); |
56 |
| - } |
| 73 | + public String getFieldValue(String fieldName) { |
| 74 | + TextField field = getField(fieldName); |
| 75 | + if (field != null) return field.getValue(); |
57 | 76 | return null;
|
58 | 77 | }
|
59 | 78 |
|
60 | 79 | @Nullable
|
61 |
| - public String getFieldValueByName(String fieldName) { |
62 |
| - return getFieldValueByName(fieldName, 0); |
| 80 | + public String getFieldValue(String fieldName, int lcid) { |
| 81 | + TextField field = getField(fieldName, lcid); |
| 82 | + if (field != null) return field.getValue(); |
| 83 | + return null; |
63 | 84 | }
|
64 | 85 | }
|
0 commit comments