Tiny update to store string length in var

git-svn-id: https://zxing.googlecode.com/svn/trunk@105 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2007-12-07 22:00:06 +00:00
parent 852669ced6
commit 0a6ab338b8

View file

@ -25,10 +25,11 @@ public final class UPCParsedResult extends ParsedReaderResult {
public UPCParsedResult(String rawText) {
super(ParsedReaderResultType.UPC);
if (rawText.length() != 12 && rawText.length() != 13) {
int length = rawText.length();
if (length != 12 && length != 13) {
throw new IllegalArgumentException("Wrong number of digits for UPC");
}
for (int x = 0; x < rawText.length(); x++) {
for (int x = 0; x < length; x++) {
char c = rawText.charAt(x);
if (c < '0' || c > '9') {
throw new IllegalArgumentException("Invalid character found in UPC");