mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-26 09:02:34 -06:00
55 lines
2.3 KiB
Java
55 lines
2.3 KiB
Java
package com.google.zxing.oned;
|
|
|
|
import com.google.zxing.BarcodeFormat;
|
|
import com.google.zxing.FormatException;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
|
|
/* loaded from: classes3.dex */
|
|
public final class UPCEWriter extends UPCEANWriter {
|
|
private static final int CODE_WIDTH = 51;
|
|
|
|
@Override // com.google.zxing.oned.OneDimensionalCodeWriter
|
|
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
|
|
return Collections.singleton(BarcodeFormat.UPC_E);
|
|
}
|
|
|
|
@Override // com.google.zxing.oned.OneDimensionalCodeWriter
|
|
public boolean[] encode(String str) {
|
|
int length = str.length();
|
|
if (length == 7) {
|
|
try {
|
|
str = str + UPCEANReader.getStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(str));
|
|
} catch (FormatException e) {
|
|
throw new IllegalArgumentException(e);
|
|
}
|
|
} else if (length == 8) {
|
|
try {
|
|
if (!UPCEANReader.checkStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(str))) {
|
|
throw new IllegalArgumentException("Contents do not pass checksum");
|
|
}
|
|
} catch (FormatException unused) {
|
|
throw new IllegalArgumentException("Illegal contents");
|
|
}
|
|
} else {
|
|
throw new IllegalArgumentException("Requested contents should be 7 or 8 digits long, but got ".concat(String.valueOf(length)));
|
|
}
|
|
checkNumeric(str);
|
|
int digit = Character.digit(str.charAt(0), 10);
|
|
if (digit != 0 && digit != 1) {
|
|
throw new IllegalArgumentException("Number system must be 0 or 1");
|
|
}
|
|
int i = UPCEReader.NUMSYS_AND_CHECK_DIGIT_PATTERNS[digit][Character.digit(str.charAt(7), 10)];
|
|
boolean[] zArr = new boolean[51];
|
|
int appendPattern = appendPattern(zArr, 0, UPCEANReader.START_END_PATTERN, true);
|
|
for (int i2 = 1; i2 <= 6; i2++) {
|
|
int digit2 = Character.digit(str.charAt(i2), 10);
|
|
if (((i >> (6 - i2)) & 1) == 1) {
|
|
digit2 += 10;
|
|
}
|
|
appendPattern += appendPattern(zArr, appendPattern, UPCEANReader.L_AND_G_PATTERNS[digit2], false);
|
|
}
|
|
appendPattern(zArr, appendPattern, UPCEANReader.END_PATTERN, false);
|
|
return zArr;
|
|
}
|
|
}
|