80 lines
2.8 KiB
Java
80 lines
2.8 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 class Code93Writer extends OneDimensionalCodeWriter {
|
|
@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.CODE_93) {
|
|
return super.a(str, barcodeFormat, i, i2, map);
|
|
}
|
|
throw new IllegalArgumentException("Can only encode CODE_93, but got ".concat(String.valueOf(barcodeFormat)));
|
|
}
|
|
|
|
@Override // com.google.zxing.oned.OneDimensionalCodeWriter
|
|
public boolean[] a(String str) {
|
|
int length = str.length();
|
|
if (length <= 80) {
|
|
int[] iArr = new int[9];
|
|
int length2 = ((str.length() + 2 + 2) * 9) + 1;
|
|
a(Code93Reader.d[47], iArr);
|
|
boolean[] zArr = new boolean[length2];
|
|
int a = a(zArr, 0, iArr);
|
|
for (int i = 0; i < length; i++) {
|
|
a(Code93Reader.d["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*".indexOf(str.charAt(i))], iArr);
|
|
a += a(zArr, a, iArr);
|
|
}
|
|
int a2 = a(str, 20);
|
|
a(Code93Reader.d[a2], iArr);
|
|
int a3 = a + a(zArr, a, iArr);
|
|
a(Code93Reader.d[a(str + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*".charAt(a2), 15)], iArr);
|
|
int a4 = a3 + a(zArr, a3, iArr);
|
|
a(Code93Reader.d[47], iArr);
|
|
zArr[a4 + a(zArr, a4, iArr)] = true;
|
|
return zArr;
|
|
}
|
|
throw new IllegalArgumentException("Requested contents should be less than 80 digits long, but got ".concat(String.valueOf(length)));
|
|
}
|
|
|
|
private static void a(int i, int[] iArr) {
|
|
for (int i2 = 0; i2 < 9; i2++) {
|
|
int i3 = 1;
|
|
if (((1 << (8 - i2)) & i) == 0) {
|
|
i3 = 0;
|
|
}
|
|
iArr[i2] = i3;
|
|
}
|
|
}
|
|
|
|
private static int a(boolean[] zArr, int i, int[] iArr) {
|
|
int length = iArr.length;
|
|
int i2 = i;
|
|
int i3 = 0;
|
|
while (i3 < length) {
|
|
int i4 = i2 + 1;
|
|
zArr[i2] = iArr[i3] != 0;
|
|
i3++;
|
|
i2 = i4;
|
|
}
|
|
return 9;
|
|
}
|
|
|
|
private static int a(String str, int i) {
|
|
int i2 = 0;
|
|
int i3 = 1;
|
|
for (int length = str.length() - 1; length >= 0; length--) {
|
|
i2 += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd*".indexOf(str.charAt(length)) * i3;
|
|
i3++;
|
|
if (i3 > i) {
|
|
i3 = 1;
|
|
}
|
|
}
|
|
return i2 % 47;
|
|
}
|
|
}
|