MCPcopy Create free account
hub / github.com/ZsBT/mrz-java / get

Method get

src/main/java/com/innovatrics/mrz/types/MrzFormat.java:120–134  ·  view source on GitHub ↗

Detects given MRZ format. @param mrz the MRZ string. @return the format, never null.

(String mrz)

Source from the content-addressed store, hash-verified

118 * @return the format, never null.
119 */
120 public static final MrzFormat get(String mrz) {
121 final String[] rows = mrz.split("\n");
122 final int cols = rows[0].length();
123 for (int i = 1; i < rows.length; i++) {
124 if (rows[i].length() != cols) {
125 throw new MrzParseException("Different row lengths: 0: " + cols + " and " + i + ": " + rows[i].length(), mrz, new MrzRange(0, 0, 0), null);
126 }
127 }
128 for (final MrzFormat f : values()) {
129 if (f.isFormatOf(rows)) {
130 return f;
131 }
132 }
133 throw new MrzParseException("Unknown format / unsupported number of cols/rows: " + cols + "/" + rows.length, mrz, new MrzRange(0, 0, 0), null);
134 }
135
136 /**
137 * Creates new record instance with this type.

Callers 3

MrzParserMethod · 0.95
parseMethod · 0.95
fromMrzMethod · 0.95

Calls 2

lengthMethod · 0.80
isFormatOfMethod · 0.80

Tested by

no test coverage detected