50 lines
2.3 KiB
Java
50 lines
2.3 KiB
Java
package com.google.zxing.oned;
|
|
|
|
import com.google.zxing.BarcodeFormat;
|
|
import com.google.zxing.EncodeHintType;
|
|
import com.google.zxing.WriterException;
|
|
import com.google.zxing.common.BitMatrix;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class ITFWriter extends OneDimensionalCodeWriter {
|
|
private static final int[] a = {1, 1, 1, 1};
|
|
private static final int[] b = {3, 1, 1};
|
|
private static final int[][] c = {new int[]{1, 1, 3, 3, 1}, new int[]{3, 1, 1, 1, 3}, new int[]{1, 3, 1, 1, 3}, new int[]{3, 3, 1, 1, 1}, new int[]{1, 1, 3, 1, 3}, new int[]{3, 1, 3, 1, 1}, new int[]{1, 3, 3, 1, 1}, new int[]{1, 1, 1, 3, 3}, new int[]{3, 1, 1, 3, 1}, new int[]{1, 3, 1, 3, 1}};
|
|
|
|
@Override // com.google.zxing.oned.OneDimensionalCodeWriter, com.google.zxing.Writer
|
|
public BitMatrix a(String str, BarcodeFormat barcodeFormat, int i, int i2, Map<EncodeHintType, ?> map) throws WriterException {
|
|
if (barcodeFormat == BarcodeFormat.ITF) {
|
|
return super.a(str, barcodeFormat, i, i2, map);
|
|
}
|
|
throw new IllegalArgumentException("Can only encode ITF, but got ".concat(String.valueOf(barcodeFormat)));
|
|
}
|
|
|
|
@Override // com.google.zxing.oned.OneDimensionalCodeWriter
|
|
public boolean[] a(String str) {
|
|
int length = str.length();
|
|
if (length % 2 != 0) {
|
|
throw new IllegalArgumentException("The length of the input should be even");
|
|
}
|
|
if (length <= 80) {
|
|
boolean[] zArr = new boolean[(length * 9) + 9];
|
|
int a2 = OneDimensionalCodeWriter.a(zArr, 0, a, true);
|
|
for (int i = 0; i < length; i += 2) {
|
|
int digit = Character.digit(str.charAt(i), 10);
|
|
int digit2 = Character.digit(str.charAt(i + 1), 10);
|
|
int[] iArr = new int[10];
|
|
for (int i2 = 0; i2 < 5; i2++) {
|
|
int i3 = i2 * 2;
|
|
int[][] iArr2 = c;
|
|
iArr[i3] = iArr2[digit][i2];
|
|
iArr[i3 + 1] = iArr2[digit2][i2];
|
|
}
|
|
a2 += OneDimensionalCodeWriter.a(zArr, a2, iArr, true);
|
|
}
|
|
OneDimensionalCodeWriter.a(zArr, a2, b, true);
|
|
return zArr;
|
|
}
|
|
throw new IllegalArgumentException("Requested contents should be less than 80 digits long, but got ".concat(String.valueOf(length)));
|
|
}
|
|
}
|