* <p>Decodes Code 39 barcodes. This does not support "Full ASCII Code 39" yet.</p>
*
* @author Sean Owen
+ * @see Code93Reader
*/
public final class Code39Reader extends OneDReader {
for (int i = 0; i < max; i++) {
total += ALPHABET_STRING.indexOf(result.charAt(i));
}
- if (total % 43 != ALPHABET_STRING.indexOf(result.charAt(max))) {
+ if (result.charAt(max) != ALPHABET[total % 43]) {
throw ChecksumException.getChecksumInstance();
}
result.deleteCharAt(max);
}
- String resultString = result.toString();
- if (extendedMode) {
- resultString = decodeExtended(resultString);
- }
-
- if (resultString.length() == 0) {
+ if (result.length() == 0) {
// Almost surely a false positive
throw NotFoundException.getNotFoundInstance();
}
+ String resultString;
+ if (extendedMode) {
+ resultString = decodeExtended(result);
+ } else {
+ resultString = result.toString();
+ }
+
float left = (float) (start[1] + start[0]) / 2.0f;
float right = (float) (nextStart + lastStart) / 2.0f;
return new Result(
throw NotFoundException.getNotFoundInstance();
}
- private static String decodeExtended(String encoded) throws FormatException {
+ private static String decodeExtended(StringBuffer encoded) throws FormatException {
int length = encoded.length();
StringBuffer decoded = new StringBuffer(length);
for (int i = 0; i < length; i++) {