X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=core%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Foned%2FUPCEReader.java;h=f8b885aa633a3f2a8ccab12a3bff95dad8aa8b17;hb=1170ad08b19f495ae38daf72a816ac60e5606aae;hp=13fcfd5b33ce157e06ce3056cd0224cef5ef68e1;hpb=4b7e347031d7d2053257c15ce5a9b301de777824;p=zxing.git diff --git a/core/src/com/google/zxing/oned/UPCEReader.java b/core/src/com/google/zxing/oned/UPCEReader.java index 13fcfd5b..f8b885aa 100644 --- a/core/src/com/google/zxing/oned/UPCEReader.java +++ b/core/src/com/google/zxing/oned/UPCEReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2008 Google Inc. + * Copyright 2008 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package com.google.zxing.oned; import com.google.zxing.ReaderException; +import com.google.zxing.BarcodeFormat; import com.google.zxing.common.BitArray; /** @@ -25,7 +26,7 @@ import com.google.zxing.common.BitArray; *

This is a great reference for * UPC-E information.

* - * @author srowen@google.com (Sean Owen) + * @author Sean Owen */ public final class UPCEReader extends AbstractUPCEANReader { @@ -45,9 +46,18 @@ public final class UPCEReader extends AbstractUPCEANReader { {0x07, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A} }; - protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer result) throws ReaderException { + private final int[] decodeMiddleCounters; + + public UPCEReader() { + decodeMiddleCounters = new int[4]; + } - int[] counters = new int[4]; + protected int decodeMiddle(BitArray row, int[] startRange, StringBuffer result) throws ReaderException { + int[] counters = decodeMiddleCounters; + counters[0] = 0; + counters[1] = 0; + counters[2] = 0; + counters[3] = 0; int end = row.getSize(); int rowOffset = startRange[1]; @@ -89,7 +99,11 @@ public final class UPCEReader extends AbstractUPCEANReader { } } } - throw new ReaderException("Unable to determine number system and check digit"); + throw ReaderException.getInstance(); + } + + BarcodeFormat getBarcodeFormat() { + return BarcodeFormat.UPC_E; } /** @@ -98,7 +112,7 @@ public final class UPCEReader extends AbstractUPCEANReader { * @param upce UPC-E code as string of digits * @return equivalent UPC-A code as string of digits */ - private static String convertUPCEtoUPCA(String upce) { + public static String convertUPCEtoUPCA(String upce) { char[] upceChars = new char[6]; upce.getChars(1, 7, upceChars, 0); StringBuffer result = new StringBuffer(12);