public class MrzParser extends Object
| Modifier and Type | Field and Description |
|---|---|
static char |
FILLER
The filler character, '<'.
|
| Constructor and Description |
|---|
MrzParser(String mrz)
Creates new parser which parses given MRZ record.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkDigit(int col,
int row,
MrzRange strRange,
String fieldName)
Verifies the check digit.
|
boolean |
checkDigit(int col,
int row,
String str,
String fieldName)
Verifies the check digit.
|
void |
checkValidCharacters(MrzRange range)
Checks that given range contains valid characters.
|
static int |
computeCheckDigit(String str)
Computes MRZ check digit for given string of characters.
|
static char |
computeCheckDigitChar(String str)
Computes MRZ check digit for given string of characters.
|
MrzFormat |
getFormat() |
String |
getMrz() |
String[] |
getRows() |
static String |
nameToMrz(String surname,
String givenNames,
int length)
Converts a surname and given names to a MRZ string, shortening them as per Doc 9303 Part 3 Vol 1 Section 6.7 of the MRZ specification when
necessary.
|
static MrzRecord |
parse(String mrz)
Factory method, which parses the MRZ and returns appropriate record class.
|
MrzDate |
parseDate(MrzRange range)
Parses MRZ date.
|
String[] |
parseName(MrzRange range)
Parses the MRZ name in form of SURNAME <<FIRSTNAME<.
|
MrzSex |
parseSex(int col,
int row)
Parses the "sex" value from given column/row.
|
String |
parseString(MrzRange range)
Parses a string in given range.
|
String |
rawValue(MrzRange... range)
Returns a raw MRZ value from given range.
|
static String |
toMrz(String input,
int length)
Converts given string to a MRZ string: removes all accents, converts the string to upper-case and replaces all spaces and invalid characters
with '<'.
|
public static final char FILLER
public MrzParser(String mrz) throws MrzParseException
mrz - the MRZ record, not null.MrzParseException - could not parse MRZpublic String getMrz()
public String[] getRows()
public MrzFormat getFormat()
public String[] parseName(MrzRange range) throws MrzParseException
range - the rangeMrzParseException - could not parse rangepublic String rawValue(MrzRange... range)
range - the ranges, not null.public void checkValidCharacters(MrzRange range) throws MrzParseException
range - the range to check.MrzParseException - could not parse rangepublic String parseString(MrzRange range) throws MrzParseException
range - the rangeMrzParseException - could not parse rangepublic boolean checkDigit(int col,
int row,
MrzRange strRange,
String fieldName)
col - the 0-based column of the check digit.row - the 0-based column of the check digit.strRange - the range for which the check digit is computed.fieldName - (optional) field name. Used only when validity check fails.public boolean checkDigit(int col,
int row,
String str,
String fieldName)
col - the 0-based column of the check digit.row - the 0-based column of the check digit.str - the raw MRZ substring.fieldName - (optional) field name. Used only when validity check fails.public MrzDate parseDate(MrzRange range)
range - the range containing the date, in the YYMMDD format. The range must be 6 characters long.IllegalArgumentException - if the range is not 6 characters long.public MrzSex parseSex(int col, int row)
col - the 0-based columnrow - the 0-based rowpublic static int computeCheckDigit(String str)
str - the stringpublic static char computeCheckDigitChar(String str)
str - the stringpublic static MrzRecord parse(String mrz) throws MrzParseException
mrz - MRZ to parse.MrzParseException - could not parse MRZpublic static String toMrz(String input, int length)
Several characters are expanded:
| Character | Expand to |
|---|---|
| Ä | AE |
| Å | AA |
| Æ | AE |
| IJ | IJ |
| IJ | IJ |
| Ö | OE |
| Ø | OE |
| Ü | UE |
| ß | SS |
toMrz("Sedím na konári", 20) yields "SEDIM<NA<KONARI<<<<<"toMrz("Pat, Mat", 8) yields "PAT<<MAT"toMrz("foo/bar baz", 4) yields "FOO<"toMrz("*$()&/\", 8) yields "<<<<<<<<"input - the string to convert. Passing null is the same as passing in an empty string.length - required length of the string. If given string is longer, it is truncated. If given string is shorter than given length, '<'
characters are appended at the end. If -1, the string is neither truncated nor enlarged.public static String nameToMrz(String surname, String givenNames, int length)
surname - the surname, not blank.givenNames - given names, not blank.length - required length of the string. If given string is longer, it is shortened. If given string is shorter than given length, '<'
characters are appended at the end.Copyright © 2011–2022 Innovatrics. All rights reserved.