Class encapsulating data read from a machine-readable zone (MRZ)
This class encapsulates raw data read from an MRZ, and provides low-level parsing and checking facilities. It is intended for use with ICAO 9303 MRZs, but does not require compliance; the only real limitations on this class are that it only supports up to 3 lines, and up to MaxLineSize characters per line.
While this class does provide basic detection of MRZ data formats (see MRZ_Format for details), it does not provide guarantees of validity, field parsing support, or validation of check digits and field contents. Support for those operations is provided by the ValidatedMRZ class.
The raw text contained within an MRZ is set at construction, or via the setText() method. It may be read back by the line1(), line2() and line3() methods. Note that this class does not provide ICAO 9303 conformance as an invariant - that is, invalid or incomplete MRZ scans will still generate text and that will still be returned.
Thread safety:
Public Member Functions | |
MRZ_Data () | |
Construct with empty MRZ contents and unknown type ID. | |
MRZ_Data (@NonNull String initText) | |
[DEPRECATED] Construction - sets stored text More... | |
MRZ_Data (@NonNull String initLine1, @NonNull String initLine2, @NonNull String initLine3) | |
Construct from MRZ text lines. More... | |
MRZ_Format | format () |
Query the format of the MRZ. More... | |
String | line1 () |
Read the first line of text, if present. More... | |
String | line2 () |
Read the second line of text, if present. More... | |
String | line3 () |
Read the third line of text, if present. More... | |
void | setLine1 (@NonNull String newLine) |
Set the first line of the MRZ data. More... | |
void | setLine2 (@NonNull String newLine) |
Set the second line of the MRZ data. More... | |
void | setLine3 (@NonNull String newLine) |
Set the third line of the MRZ data. More... | |
void | setText (@NonNull String newText) |
[DEPRECATED] Set the stored text More... | |
void | setText (@NonNull String newLine1, @NonNull String newLine2, @NonNull String newLine3) |
Set the MRZ text as per given line data. More... | |
String | text () |
[DEPRECATED] Text from a successful read of an MRZ More... | |
Static Public Attributes | |
static final short | MaxLineSize |
Maximum supported size of each line. | |
MRZ_Data | ( | @NonNull String | initText | ) |
[DEPRECATED] Construction - sets stored text
This is an older form of the constructor for this class, provided solely for backward compatibility purposes. Use the three-parameter constructor instead.
initText | Initial value of the stored text; see text() for details of the format |
MRZ_Data | ( | @NonNull String | initLine1, |
@NonNull String | initLine2, | ||
@NonNull String | initLine3 | ||
) |
Construct from MRZ text lines.
For successful reads of compliant MRZs, the length of each line should be identical, and the data should match one of the formats defined in ICAO 9303 (e.g. the passport format, TD3, contains 2 lines of 44 characters apiece). However, construction with non-compliant MRZ text is permitted.
initLine1 | New value of line 1 text; will be truncated to MaxLineSize if it exceeds that |
initLine2 | New value of line 2 text; will be truncated to MaxLineSize if it exceeds that |
initLine3 | New value of line 3 text; will be truncated to MaxLineSize if it exceeds that. For two-line MRZ formats, this should be set to an empty string. |
MRZ_Format format | ( | ) |
Query the format of the MRZ.
This performs the following checks:
If all of the checks pass, then the relevant format is returned. If any of the checks fail, then UNKNOWN will be returned.
String line1 | ( | ) |
Read the first line of text, if present.
Asterisk characters ('*') will be used as placeholders for any characters which were not read clearly.
String line2 | ( | ) |
Read the second line of text, if present.
Asterisk characters ('*') will be used as placeholders for any characters which were not read clearly.
String line3 | ( | ) |
Read the third line of text, if present.
Asterisk characters ('*') will be used as placeholders for any characters which were not read clearly.
void setLine1 | ( | @NonNull String | newLine | ) |
Set the first line of the MRZ data.
newLine | New value of the line's text; will be truncated to MaxLineSize if it exceeds that |
void setLine2 | ( | @NonNull String | newLine | ) |
Set the second line of the MRZ data.
newLine | New value of the line's text; will be truncated to MaxLineSize if it exceeds that |
void setLine3 | ( | @NonNull String | newLine | ) |
Set the third line of the MRZ data.
newLine | New value of the line's text; will be truncated to MaxLineSize if it exceeds that. For two-line MRZ formats, this should be set to an empty string. |
void setText | ( | @NonNull String | newText | ) |
[DEPRECATED] Set the stored text
This is a deprecated form of the set-text method, provided solely for backward compatibility. Use the three-parameter form of this function instead.
newText | New value of the stored text; see text() for details of the format |
void setText | ( | @NonNull String | newLine1, |
@NonNull String | newLine2, | ||
@NonNull String | newLine3 | ||
) |
Set the MRZ text as per given line data.
For successful reads of compliant MRZs, the length of each line should be identical, and the data should match one of the formats defined in ICAO 9303 (e.g. the passport format, TD3, contains 2 lines of 44 characters apiece). However, setting of non-compliant MRZ text is permitted.
newLine1 | New value of line 1 text; will be truncated to MaxLineSize if it exceeds that |
newLine2 | New value of line 2 text; will be truncated to MaxLineSize if it exceeds that |
newLine3 | New value of line 3 text; will be truncated to MaxLineSize if it exceeds that. For two-line MRZ formats, this should be set to an empty string. |
String text | ( | ) |
[DEPRECATED] Text from a successful read of an MRZ
This is an older form of the text-access method, provided solely for backward compatibility purposes. Use the line1(), line2() and line3() methods instead.