Initial commit
This commit is contained in:
57
sources/com/google/zxing/oned/UPCEWriter.java
Normal file
57
sources/com/google/zxing/oned/UPCEWriter.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.google.zxing.oned;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class UPCEWriter extends UPCEANWriter {
|
||||
@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.UPC_E) {
|
||||
return super.a(str, barcodeFormat, i, i2, map);
|
||||
}
|
||||
throw new IllegalArgumentException("Can only encode UPC_E, but got ".concat(String.valueOf(barcodeFormat)));
|
||||
}
|
||||
|
||||
@Override // com.google.zxing.oned.OneDimensionalCodeWriter
|
||||
public boolean[] a(String str) {
|
||||
int length = str.length();
|
||||
if (length == 7) {
|
||||
try {
|
||||
str = str + UPCEANReader.b(UPCEReader.b(str));
|
||||
} catch (FormatException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
} else if (length == 8) {
|
||||
try {
|
||||
if (!UPCEANReader.a((CharSequence) 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 8 digits long, but got ".concat(String.valueOf(length)));
|
||||
}
|
||||
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.k[digit][Character.digit(str.charAt(7), 10)];
|
||||
boolean[] zArr = new boolean[51];
|
||||
int a = OneDimensionalCodeWriter.a(zArr, 0, UPCEANReader.d, true) + 0;
|
||||
for (int i2 = 1; i2 <= 6; i2++) {
|
||||
int digit2 = Character.digit(str.charAt(i2), 10);
|
||||
if (((i >> (6 - i2)) & 1) == 1) {
|
||||
digit2 += 10;
|
||||
}
|
||||
a += OneDimensionalCodeWriter.a(zArr, a, UPCEANReader.h[digit2], false);
|
||||
}
|
||||
OneDimensionalCodeWriter.a(zArr, a, UPCEANReader.f, false);
|
||||
return zArr;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user