diff --git a/core/src/com/google/zxing/client/result/ExpandedProductParsedResult.java b/core/src/com/google/zxing/client/result/ExpandedProductParsedResult.java index f1865d2da..6053100d4 100644 --- a/core/src/com/google/zxing/client/result/ExpandedProductParsedResult.java +++ b/core/src/com/google/zxing/client/result/ExpandedProductParsedResult.java @@ -37,6 +37,7 @@ public final class ExpandedProductParsedResult extends ParsedResult { public static final String KILOGRAM = "KG"; public static final String POUND = "LB"; + private final String rawText; private final String productID; private final String sscc; private final String lotNumber; @@ -53,7 +54,8 @@ public final class ExpandedProductParsedResult extends ParsedResult { // For AIS that not exist in this object private final Map uncommonAIs; - public ExpandedProductParsedResult(String productID, + public ExpandedProductParsedResult(String rawText, + String productID, String sscc, String lotNumber, String productionDate, @@ -68,6 +70,7 @@ public final class ExpandedProductParsedResult extends ParsedResult { String priceCurrency, Map uncommonAIs) { super(ParsedResultType.PRODUCT); + this.rawText = rawText; this.productID = productID; this.sscc = sscc; this.lotNumber = lotNumber; @@ -134,6 +137,10 @@ public final class ExpandedProductParsedResult extends ParsedResult { return o == null ? 0 : o.hashCode(); } + public String getRawText() { + return rawText; + } + public String getProductID() { return productID; } @@ -192,6 +199,6 @@ public final class ExpandedProductParsedResult extends ParsedResult { @Override public String getDisplayResult() { - return String.valueOf(productID); + return String.valueOf(rawText); } } diff --git a/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java b/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java index de74b7cf7..d83f3ed1a 100644 --- a/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java +++ b/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java @@ -133,7 +133,8 @@ public final class ExpandedProductResultParser extends ResultParser { } } - return new ExpandedProductParsedResult(productID, + return new ExpandedProductParsedResult(rawText, + productID, sscc, lotNumber, productionDate, diff --git a/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java b/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java index 6937871b0..a03201727 100644 --- a/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java +++ b/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java @@ -39,6 +39,7 @@ import com.google.zxing.oned.rss.RSSUtils; import com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Collections; @@ -88,6 +89,7 @@ public final class RSSExpandedReader extends AbstractRSSReader { { 45, 135, 194, 160, 58, 174, 100, 89} }; + /* private static final int FINDER_PAT_A = 0; private static final int FINDER_PAT_B = 1; private static final int FINDER_PAT_C = 2; @@ -109,13 +111,14 @@ public final class RSSExpandedReader extends AbstractRSSReader { }; private static final int LONGEST_SEQUENCE_SIZE = FINDER_PATTERN_SEQUENCES[FINDER_PATTERN_SEQUENCES.length - 1].length; + */ private static final int MAX_PAIRS = 11; private final List pairs = new ArrayList(MAX_PAIRS); private final List rows = new ArrayList(); private final int [] startEnd = new int[2]; - private final int [] currentSequence = new int[LONGEST_SEQUENCE_SIZE]; + //private final int [] currentSequence = new int[LONGEST_SEQUENCE_SIZE]; private boolean startFromEven = false; @Override @@ -217,7 +220,7 @@ public final class RSSExpandedReader extends AbstractRSSReader { break; } prevIsSame = erow.isEquivalent(this.pairs); - insertPos += 1; + insertPos++; } if (nextIsSame || prevIsSame) { return; @@ -239,11 +242,12 @@ public final class RSSExpandedReader extends AbstractRSSReader { // Remove all the rows that contains only specified pairs private static void removePartialRows(List pairs, List rows) { - check: - for (ExpandedRow r : rows) { + for (Iterator iterator = rows.iterator(); iterator.hasNext(); ) { + ExpandedRow r = iterator.next(); if (r.getPairs().size() == pairs.size()) { continue; } + boolean allFound = true; for (ExpandedPair p : r.getPairs()) { boolean found = false; for (ExpandedPair pp : pairs) { @@ -253,21 +257,23 @@ public final class RSSExpandedReader extends AbstractRSSReader { } } if (!found) { - continue check; + allFound = false; + break; } } - // 'pairs' contains all the pairs from the row 'r' - rows.remove(r); - // start from the begining - removePartialRows(pairs, rows); - return; + if (allFound) { + // 'pairs' contains all the pairs from the row 'r' + iterator.remove(); + // start from the begining + removePartialRows(pairs, rows); + } } } // Returns true when one of the rows already contains all the pairs private static boolean isPartialRow(Iterable pairs, Iterable rows) { - check: for (ExpandedRow r : rows) { + boolean allFound = true; for (ExpandedPair p : pairs) { boolean found = false; for (ExpandedPair pp : r.getPairs()) { @@ -277,11 +283,14 @@ public final class RSSExpandedReader extends AbstractRSSReader { } } if (!found) { - continue check; + allFound = false; + break; } } - // the row 'r' contain all the pairs from 'pairs' - return true; + if (allFound) { + // the row 'r' contain all the pairs from 'pairs' + return true; + } } return false; } diff --git a/core/test/src/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java b/core/test/src/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java index eab5187e5..06ad313e5 100644 --- a/core/test/src/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java +++ b/core/test/src/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java @@ -64,7 +64,8 @@ public final class RSSExpandedImage2resultTestCase extends Assert { // (01)90012345678908(3103)001750 String path = "test/data/blackbox/rssexpanded-1/2.jpg"; ExpandedProductParsedResult expected = - new ExpandedProductParsedResult("90012345678908", + new ExpandedProductParsedResult("(01)90012345678908(3103)001750", + "90012345678908", null, null, null, null, null, null, "001750", ExpandedProductParsedResult.KILOGRAM,