mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 20:32:34 +00:00
move all Result to RXingResult
This commit is contained in:
@@ -19,9 +19,9 @@ package com.google.zxing.oned;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -67,25 +67,25 @@ public final class CodaBarReader extends OneDReader {
|
||||
// for more information see : http://www.mecsw.com/specs/codabar.html
|
||||
|
||||
// Keep some instance variables to avoid reallocations
|
||||
private final StringBuilder decodeRowResult;
|
||||
private final StringBuilder decodeRowRXingResult;
|
||||
private int[] counters;
|
||||
private int counterLength;
|
||||
|
||||
public CodaBarReader() {
|
||||
decodeRowResult = new StringBuilder(20);
|
||||
decodeRowRXingResult = new StringBuilder(20);
|
||||
counters = new int[80];
|
||||
counterLength = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
|
||||
Arrays.fill(counters, 0);
|
||||
setCounters(row);
|
||||
int startOffset = findStartPattern();
|
||||
int nextStart = startOffset;
|
||||
|
||||
decodeRowResult.setLength(0);
|
||||
decodeRowRXingResult.setLength(0);
|
||||
do {
|
||||
int charOffset = toNarrowWidePattern(nextStart);
|
||||
if (charOffset == -1) {
|
||||
@@ -94,10 +94,10 @@ public final class CodaBarReader extends OneDReader {
|
||||
// Hack: We store the position in the alphabet table into a
|
||||
// StringBuilder, so that we can access the decoded patterns in
|
||||
// validatePattern. We'll translate to the actual characters later.
|
||||
decodeRowResult.append((char) charOffset);
|
||||
decodeRowRXingResult.append((char) charOffset);
|
||||
nextStart += 8;
|
||||
// Stop as soon as we see the end character.
|
||||
if (decodeRowResult.length() > 1 &&
|
||||
if (decodeRowRXingResult.length() > 1 &&
|
||||
arrayContains(STARTEND_ENCODING, ALPHABET[charOffset])) {
|
||||
break;
|
||||
}
|
||||
@@ -120,28 +120,28 @@ public final class CodaBarReader extends OneDReader {
|
||||
validatePattern(startOffset);
|
||||
|
||||
// Translate character table offsets to actual characters.
|
||||
for (int i = 0; i < decodeRowResult.length(); i++) {
|
||||
decodeRowResult.setCharAt(i, ALPHABET[decodeRowResult.charAt(i)]);
|
||||
for (int i = 0; i < decodeRowRXingResult.length(); i++) {
|
||||
decodeRowRXingResult.setCharAt(i, ALPHABET[decodeRowRXingResult.charAt(i)]);
|
||||
}
|
||||
// Ensure a valid start and end character
|
||||
char startchar = decodeRowResult.charAt(0);
|
||||
char startchar = decodeRowRXingResult.charAt(0);
|
||||
if (!arrayContains(STARTEND_ENCODING, startchar)) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
char endchar = decodeRowResult.charAt(decodeRowResult.length() - 1);
|
||||
char endchar = decodeRowRXingResult.charAt(decodeRowRXingResult.length() - 1);
|
||||
if (!arrayContains(STARTEND_ENCODING, endchar)) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
// remove stop/start characters character and check if a long enough string is contained
|
||||
if (decodeRowResult.length() <= MIN_CHARACTER_LENGTH) {
|
||||
if (decodeRowRXingResult.length() <= MIN_CHARACTER_LENGTH) {
|
||||
// Almost surely a false positive ( start + stop + at least 1 character)
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
if (hints == null || !hints.containsKey(DecodeHintType.RETURN_CODABAR_START_END)) {
|
||||
decodeRowResult.deleteCharAt(decodeRowResult.length() - 1);
|
||||
decodeRowResult.deleteCharAt(0);
|
||||
decodeRowRXingResult.deleteCharAt(decodeRowRXingResult.length() - 1);
|
||||
decodeRowRXingResult.deleteCharAt(0);
|
||||
}
|
||||
|
||||
int runningCount = 0;
|
||||
@@ -154,14 +154,14 @@ public final class CodaBarReader extends OneDReader {
|
||||
}
|
||||
float right = runningCount;
|
||||
|
||||
Result result = new Result(
|
||||
decodeRowResult.toString(),
|
||||
RXingResult result = new RXingResult(
|
||||
decodeRowRXingResult.toString(),
|
||||
null,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODABAR);
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]F0");
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]F0");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -169,13 +169,13 @@ public final class CodaBarReader extends OneDReader {
|
||||
// First, sum up the total size of our four categories of stripe sizes;
|
||||
int[] sizes = {0, 0, 0, 0};
|
||||
int[] counts = {0, 0, 0, 0};
|
||||
int end = decodeRowResult.length() - 1;
|
||||
int end = decodeRowRXingResult.length() - 1;
|
||||
|
||||
// We break out of this loop in the middle, in order to handle
|
||||
// inter-character spaces properly.
|
||||
int pos = start;
|
||||
for (int i = 0; i <= end; i++) {
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)];
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowRXingResult.charAt(i)];
|
||||
for (int j = 6; j >= 0; j--) {
|
||||
// Even j = bars, while odd j = spaces. Categories 2 and 3 are for
|
||||
// long stripes, while 0 and 1 are for short stripes.
|
||||
@@ -204,7 +204,7 @@ public final class CodaBarReader extends OneDReader {
|
||||
// Now verify that all of the stripes are within the thresholds.
|
||||
pos = start;
|
||||
for (int i = 0; i <= end; i++) {
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowResult.charAt(i)];
|
||||
int pattern = CHARACTER_ENCODINGS[decodeRowRXingResult.charAt(i)];
|
||||
for (int j = 6; j >= 0; j--) {
|
||||
// Even j = bars, while odd j = spaces. Categories 2 and 3 are for
|
||||
// long stripes, while 0 and 1 are for short stripes.
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -234,7 +234,7 @@ public final class Code128Reader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
|
||||
boolean convertFNC1 = hints != null && hints.containsKey(DecodeHintType.ASSUME_GS1);
|
||||
@@ -547,14 +547,14 @@ public final class Code128Reader extends OneDReader {
|
||||
for (int i = 0; i < rawCodesSize; i++) {
|
||||
rawBytes[i] = rawCodes.get(i);
|
||||
}
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
result.toString(),
|
||||
rawBytes,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODE_128);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]C" + symbologyModifier);
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]C" + symbologyModifier);
|
||||
return resultObject;
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
||||
private static final int CODE_FNC_4_A = 101; // Code A
|
||||
private static final int CODE_FNC_4_B = 100; // Code B
|
||||
|
||||
// Results of minimal lookahead for code C
|
||||
// RXingResults of minimal lookahead for code C
|
||||
private enum CType {
|
||||
UNCODABLE,
|
||||
ONE_DIGIT,
|
||||
@@ -249,10 +249,10 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
||||
checkWeight++;
|
||||
}
|
||||
}
|
||||
return produceResult(patterns, checkSum);
|
||||
return produceRXingResult(patterns, checkSum);
|
||||
}
|
||||
|
||||
static boolean[] produceResult(Collection<int[]> patterns, int checkSum) {
|
||||
static boolean[] produceRXingResult(Collection<int[]> patterns, int checkSum) {
|
||||
// Compute and append checksum
|
||||
checkSum %= 103;
|
||||
patterns.add(Code128Reader.CODE_PATTERNS[checkSum]);
|
||||
@@ -456,7 +456,7 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
||||
}
|
||||
memoizedCost = null;
|
||||
minPath = null;
|
||||
return produceResult(patterns, checkSum[0]);
|
||||
return produceRXingResult(patterns, checkSum[0]);
|
||||
}
|
||||
|
||||
private static void addPattern(Collection<int[]> patterns,
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -56,7 +56,7 @@ public final class Code39Reader extends OneDReader {
|
||||
|
||||
private final boolean usingCheckDigit;
|
||||
private final boolean extendedMode;
|
||||
private final StringBuilder decodeRowResult;
|
||||
private final StringBuilder decodeRowRXingResult;
|
||||
private final int[] counters;
|
||||
|
||||
/**
|
||||
@@ -91,17 +91,17 @@ public final class Code39Reader extends OneDReader {
|
||||
public Code39Reader(boolean usingCheckDigit, boolean extendedMode) {
|
||||
this.usingCheckDigit = usingCheckDigit;
|
||||
this.extendedMode = extendedMode;
|
||||
decodeRowResult = new StringBuilder(20);
|
||||
decodeRowRXingResult = new StringBuilder(20);
|
||||
counters = new int[9];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
int[] theCounters = counters;
|
||||
Arrays.fill(theCounters, 0);
|
||||
StringBuilder result = decodeRowResult;
|
||||
StringBuilder result = decodeRowRXingResult;
|
||||
result.setLength(0);
|
||||
|
||||
int[] start = findAsteriskPattern(row, theCounters);
|
||||
@@ -144,7 +144,7 @@ public final class Code39Reader extends OneDReader {
|
||||
int max = result.length() - 1;
|
||||
int total = 0;
|
||||
for (int i = 0; i < max; i++) {
|
||||
total += ALPHABET_STRING.indexOf(decodeRowResult.charAt(i));
|
||||
total += ALPHABET_STRING.indexOf(decodeRowRXingResult.charAt(i));
|
||||
}
|
||||
if (result.charAt(max) != ALPHABET_STRING.charAt(total % 43)) {
|
||||
throw ChecksumException.getChecksumInstance();
|
||||
@@ -167,14 +167,14 @@ public final class Code39Reader extends OneDReader {
|
||||
float left = (start[1] + start[0]) / 2.0f;
|
||||
float right = lastStart + lastPatternSize / 2.0f;
|
||||
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
resultString,
|
||||
null,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODE_39);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]A0");
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]A0");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -55,16 +55,16 @@ public final class Code93Reader extends OneDReader {
|
||||
};
|
||||
static final int ASTERISK_ENCODING = CHARACTER_ENCODINGS[47];
|
||||
|
||||
private final StringBuilder decodeRowResult;
|
||||
private final StringBuilder decodeRowRXingResult;
|
||||
private final int[] counters;
|
||||
|
||||
public Code93Reader() {
|
||||
decodeRowResult = new StringBuilder(20);
|
||||
decodeRowRXingResult = new StringBuilder(20);
|
||||
counters = new int[6];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
int[] start = findAsteriskPattern(row);
|
||||
@@ -74,7 +74,7 @@ public final class Code93Reader extends OneDReader {
|
||||
|
||||
int[] theCounters = counters;
|
||||
Arrays.fill(theCounters, 0);
|
||||
StringBuilder result = decodeRowResult;
|
||||
StringBuilder result = decodeRowRXingResult;
|
||||
result.setLength(0);
|
||||
|
||||
char decodedChar;
|
||||
@@ -120,14 +120,14 @@ public final class Code93Reader extends OneDReader {
|
||||
float left = (start[1] + start[0]) / 2.0f;
|
||||
float right = lastStart + lastPatternSize / 2.0f;
|
||||
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
resultString,
|
||||
null,
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
BarcodeFormat.CODE_93);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]G0");
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]G0");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -99,7 +99,7 @@ public final class ITFReader extends OneDReader {
|
||||
};
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws FormatException, NotFoundException {
|
||||
|
||||
// Find out where the Middle section (payload) starts & ends
|
||||
@@ -140,13 +140,13 @@ public final class ITFReader extends OneDReader {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
|
||||
Result resultObject = new Result(
|
||||
RXingResult resultObject = new RXingResult(
|
||||
resultString,
|
||||
null, // no natural byte representation for these barcodes
|
||||
new ResultPoint[] {new ResultPoint(startRange[1], rowNumber),
|
||||
new ResultPoint(endRange[0], rowNumber)},
|
||||
new RXingResultPoint[] {new RXingResultPoint(startRange[1], rowNumber),
|
||||
new RXingResultPoint(endRange[0], rowNumber)},
|
||||
BarcodeFormat.ITF);
|
||||
resultObject.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]I0");
|
||||
resultObject.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]I0");
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
import com.google.zxing.oned.rss.RSS14Reader;
|
||||
import com.google.zxing.oned.rss.expanded.RSSExpandedReader;
|
||||
@@ -90,7 +90,7 @@ public final class MultiFormatOneDReader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
for (OneDReader reader : readers) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -69,14 +69,14 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
// Compute this location once and reuse it on multiple implementations
|
||||
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
|
||||
for (UPCEANReader reader : readers) {
|
||||
try {
|
||||
Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
|
||||
RXingResult result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
|
||||
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
|
||||
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
|
||||
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
|
||||
@@ -99,11 +99,11 @@ public final class MultiFormatUPCEANReader extends OneDReader {
|
||||
|
||||
if (ean13MayBeUPCA && canReturnUPCA) {
|
||||
// Transfer the metadata across
|
||||
Result resultUPCA = new Result(result.getText().substring(1),
|
||||
RXingResult resultUPCA = new RXingResult(result.getText().substring(1),
|
||||
result.getRawBytes(),
|
||||
result.getResultPoints(),
|
||||
result.getRXingResultPoints(),
|
||||
BarcodeFormat.UPC_A);
|
||||
resultUPCA.putAllMetadata(result.getResultMetadata());
|
||||
resultUPCA.putAllMetadata(result.getRXingResultMetadata());
|
||||
return resultUPCA;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -23,9 +23,9 @@ import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Reader;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -42,13 +42,13 @@ import java.util.Map;
|
||||
public abstract class OneDReader implements Reader {
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
return decode(image, null);
|
||||
}
|
||||
|
||||
// Note that we don't try rotation without the try harder flag, even if rotation was supported.
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image,
|
||||
public RXingResult decode(BinaryBitmap image,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
|
||||
try {
|
||||
return doDecode(image, hints);
|
||||
@@ -56,22 +56,22 @@ public abstract class OneDReader implements Reader {
|
||||
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
|
||||
if (tryHarder && image.isRotateSupported()) {
|
||||
BinaryBitmap rotatedImage = image.rotateCounterClockwise();
|
||||
Result result = doDecode(rotatedImage, hints);
|
||||
RXingResult result = doDecode(rotatedImage, hints);
|
||||
// Record that we found it rotated 90 degrees CCW / 270 degrees CW
|
||||
Map<ResultMetadataType,?> metadata = result.getResultMetadata();
|
||||
Map<RXingResultMetadataType,?> metadata = result.getRXingResultMetadata();
|
||||
int orientation = 270;
|
||||
if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) {
|
||||
if (metadata != null && metadata.containsKey(RXingResultMetadataType.ORIENTATION)) {
|
||||
// But if we found it reversed in doDecode(), add in that result here:
|
||||
orientation = (orientation +
|
||||
(Integer) metadata.get(ResultMetadataType.ORIENTATION)) % 360;
|
||||
(Integer) metadata.get(RXingResultMetadataType.ORIENTATION)) % 360;
|
||||
}
|
||||
result.putMetadata(ResultMetadataType.ORIENTATION, orientation);
|
||||
result.putMetadata(RXingResultMetadataType.ORIENTATION, orientation);
|
||||
// Update result points
|
||||
ResultPoint[] points = result.getResultPoints();
|
||||
RXingResultPoint[] points = result.getRXingResultPoints();
|
||||
if (points != null) {
|
||||
int height = rotatedImage.getHeight();
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
points[i] = new ResultPoint(height - points[i].getY() - 1, points[i].getX());
|
||||
points[i] = new RXingResultPoint(height - points[i].getY() - 1, points[i].getX());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -100,7 +100,7 @@ public abstract class OneDReader implements Reader {
|
||||
* @return The contents of the decoded barcode
|
||||
* @throws NotFoundException Any spontaneous errors which occur
|
||||
*/
|
||||
private Result doDecode(BinaryBitmap image,
|
||||
private RXingResult doDecode(BinaryBitmap image,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
int width = image.getWidth();
|
||||
int height = image.getHeight();
|
||||
@@ -152,16 +152,16 @@ public abstract class OneDReader implements Reader {
|
||||
}
|
||||
try {
|
||||
// Look for a barcode
|
||||
Result result = decodeRow(rowNumber, row, hints);
|
||||
RXingResult result = decodeRow(rowNumber, row, hints);
|
||||
// We found our barcode
|
||||
if (attempt == 1) {
|
||||
// But it was upside down, so note that
|
||||
result.putMetadata(ResultMetadataType.ORIENTATION, 180);
|
||||
result.putMetadata(RXingResultMetadataType.ORIENTATION, 180);
|
||||
// And remember to flip the result points horizontally.
|
||||
ResultPoint[] points = result.getResultPoints();
|
||||
RXingResultPoint[] points = result.getRXingResultPoints();
|
||||
if (points != null) {
|
||||
points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY());
|
||||
points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY());
|
||||
points[0] = new RXingResultPoint(width - points[0].getX() - 1, points[0].getY());
|
||||
points[1] = new RXingResultPoint(width - points[1].getX() - 1, points[1].getY());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -285,12 +285,12 @@ public abstract class OneDReader implements Reader {
|
||||
* @param rowNumber row number from top of the row
|
||||
* @param row the black/white pixel data of the row
|
||||
* @param hints decode hints
|
||||
* @return {@link Result} containing encoded string and start/end of barcode
|
||||
* @return {@link RXingResult} containing encoded string and start/end of barcode
|
||||
* @throws NotFoundException if no potential barcode is found
|
||||
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
||||
* @throws FormatException if a potential barcode is found but format is invalid
|
||||
*/
|
||||
public abstract Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public abstract RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException;
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class OneDimensionalCodeWriter implements Writer {
|
||||
}
|
||||
|
||||
boolean[] code = encode(contents, hints);
|
||||
return renderResult(code, width, height, sidesMargin);
|
||||
return renderRXingResult(code, width, height, sidesMargin);
|
||||
}
|
||||
|
||||
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
|
||||
@@ -100,7 +100,7 @@ public abstract class OneDimensionalCodeWriter implements Writer {
|
||||
/**
|
||||
* @return a byte array of horizontal pixels (0 = white, 1 = black)
|
||||
*/
|
||||
private static BitMatrix renderResult(boolean[] code, int width, int height, int sidesMargin) {
|
||||
private static BitMatrix renderRXingResult(boolean[] code, int width, int height, int sidesMargin) {
|
||||
int inputWidth = code.length;
|
||||
// Add quiet zone on both sides.
|
||||
int fullWidth = inputWidth + sidesMargin;
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -38,29 +38,29 @@ public final class UPCAReader extends UPCEANReader {
|
||||
private final UPCEANReader ean13Reader = new EAN13Reader();
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
int[] startGuardRange,
|
||||
Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange, hints));
|
||||
return maybeReturnRXingResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException, ChecksumException {
|
||||
return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, hints));
|
||||
return maybeReturnRXingResult(ean13Reader.decodeRow(rowNumber, row, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
return maybeReturnResult(ean13Reader.decode(image));
|
||||
public RXingResult decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
return maybeReturnRXingResult(ean13Reader.decode(image));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, FormatException {
|
||||
return maybeReturnResult(ean13Reader.decode(image, hints));
|
||||
return maybeReturnRXingResult(ean13Reader.decode(image, hints));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,14 +74,14 @@ public final class UPCAReader extends UPCEANReader {
|
||||
return ean13Reader.decodeMiddle(row, startRange, resultString);
|
||||
}
|
||||
|
||||
private static Result maybeReturnResult(Result result) throws FormatException {
|
||||
private static RXingResult maybeReturnRXingResult(RXingResult result) throws FormatException {
|
||||
String text = result.getText();
|
||||
if (text.charAt(0) == '0') {
|
||||
Result upcaResult = new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
|
||||
if (result.getResultMetadata() != null) {
|
||||
upcaResult.putAllMetadata(result.getResultMetadata());
|
||||
RXingResult upcaRXingResult = new RXingResult(text.substring(1), null, result.getRXingResultPoints(), BarcodeFormat.UPC_A);
|
||||
if (result.getRXingResultMetadata() != null) {
|
||||
upcaRXingResult.putAllMetadata(result.getRXingResultMetadata());
|
||||
}
|
||||
return upcaResult;
|
||||
return upcaRXingResult;
|
||||
} else {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.google.zxing.oned;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.EnumMap;
|
||||
@@ -34,27 +34,27 @@ final class UPCEANExtension2Support {
|
||||
private final int[] decodeMiddleCounters = new int[4];
|
||||
private final StringBuilder decodeRowStringBuffer = new StringBuilder();
|
||||
|
||||
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
RXingResult decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
|
||||
StringBuilder result = decodeRowStringBuffer;
|
||||
result.setLength(0);
|
||||
int end = decodeMiddle(row, extensionStartRange, result);
|
||||
|
||||
String resultString = result.toString();
|
||||
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
Map<RXingResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
|
||||
Result extensionResult =
|
||||
new Result(resultString,
|
||||
RXingResult extensionRXingResult =
|
||||
new RXingResult(resultString,
|
||||
null,
|
||||
new ResultPoint[] {
|
||||
new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new ResultPoint(end, rowNumber),
|
||||
new RXingResultPoint[] {
|
||||
new RXingResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new RXingResultPoint(end, rowNumber),
|
||||
},
|
||||
BarcodeFormat.UPC_EAN_EXTENSION);
|
||||
if (extensionData != null) {
|
||||
extensionResult.putAllMetadata(extensionData);
|
||||
extensionRXingResult.putAllMetadata(extensionData);
|
||||
}
|
||||
return extensionResult;
|
||||
return extensionRXingResult;
|
||||
}
|
||||
|
||||
private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException {
|
||||
@@ -98,14 +98,14 @@ final class UPCEANExtension2Support {
|
||||
/**
|
||||
* @param raw raw content of extension
|
||||
* @return formatted interpretation of raw content as a {@link Map} mapping
|
||||
* one {@link ResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
* one {@link RXingResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
*/
|
||||
private static Map<ResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
private static Map<RXingResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
if (raw.length() != 2) {
|
||||
return null;
|
||||
}
|
||||
Map<ResultMetadataType,Object> result = new EnumMap<>(ResultMetadataType.class);
|
||||
result.put(ResultMetadataType.ISSUE_NUMBER, Integer.valueOf(raw));
|
||||
Map<RXingResultMetadataType,Object> result = new EnumMap<>(RXingResultMetadataType.class);
|
||||
result.put(RXingResultMetadataType.ISSUE_NUMBER, Integer.valueOf(raw));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ package com.google.zxing.oned;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.EnumMap;
|
||||
@@ -38,27 +38,27 @@ final class UPCEANExtension5Support {
|
||||
private final int[] decodeMiddleCounters = new int[4];
|
||||
private final StringBuilder decodeRowStringBuffer = new StringBuilder();
|
||||
|
||||
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
RXingResult decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
|
||||
|
||||
StringBuilder result = decodeRowStringBuffer;
|
||||
result.setLength(0);
|
||||
int end = decodeMiddle(row, extensionStartRange, result);
|
||||
|
||||
String resultString = result.toString();
|
||||
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
Map<RXingResultMetadataType,Object> extensionData = parseExtensionString(resultString);
|
||||
|
||||
Result extensionResult =
|
||||
new Result(resultString,
|
||||
RXingResult extensionRXingResult =
|
||||
new RXingResult(resultString,
|
||||
null,
|
||||
new ResultPoint[] {
|
||||
new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new ResultPoint(end, rowNumber),
|
||||
new RXingResultPoint[] {
|
||||
new RXingResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
|
||||
new RXingResultPoint(end, rowNumber),
|
||||
},
|
||||
BarcodeFormat.UPC_EAN_EXTENSION);
|
||||
if (extensionData != null) {
|
||||
extensionResult.putAllMetadata(extensionData);
|
||||
extensionRXingResult.putAllMetadata(extensionData);
|
||||
}
|
||||
return extensionResult;
|
||||
return extensionRXingResult;
|
||||
}
|
||||
|
||||
private int decodeMiddle(BitArray row, int[] startRange, StringBuilder resultString) throws NotFoundException {
|
||||
@@ -127,9 +127,9 @@ final class UPCEANExtension5Support {
|
||||
/**
|
||||
* @param raw raw content of extension
|
||||
* @return formatted interpretation of raw content as a {@link Map} mapping
|
||||
* one {@link ResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
* one {@link RXingResultMetadataType} to appropriate value, or {@code null} if not known
|
||||
*/
|
||||
private static Map<ResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
private static Map<RXingResultMetadataType,Object> parseExtensionString(String raw) {
|
||||
if (raw.length() != 5) {
|
||||
return null;
|
||||
}
|
||||
@@ -137,8 +137,8 @@ final class UPCEANExtension5Support {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
Map<ResultMetadataType,Object> result = new EnumMap<>(ResultMetadataType.class);
|
||||
result.put(ResultMetadataType.SUGGESTED_PRICE, value);
|
||||
Map<RXingResultMetadataType,Object> result = new EnumMap<>(RXingResultMetadataType.class);
|
||||
result.put(RXingResultMetadataType.SUGGESTED_PRICE, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.google.zxing.oned;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
final class UPCEANExtensionSupport {
|
||||
@@ -28,7 +28,7 @@ final class UPCEANExtensionSupport {
|
||||
private final UPCEANExtension2Support twoSupport = new UPCEANExtension2Support();
|
||||
private final UPCEANExtension5Support fiveSupport = new UPCEANExtension5Support();
|
||||
|
||||
Result decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException {
|
||||
RXingResult decodeRow(int rowNumber, BitArray row, int rowOffset) throws NotFoundException {
|
||||
int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN);
|
||||
try {
|
||||
return fiveSupport.decodeRow(rowNumber, row, extensionStartRange);
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.ReaderException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.ResultPointCallback;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.RXingResultPointCallback;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -126,7 +126,7 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
public RXingResult decodeRow(int rowNumber, BitArray row, Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
return decodeRow(rowNumber, row, findStartGuardPattern(row), hints);
|
||||
}
|
||||
@@ -140,23 +140,23 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
* @param row encoding of the row of the barcode image
|
||||
* @param startGuardRange start/end column where the opening start pattern was found
|
||||
* @param hints optional hints that influence decoding
|
||||
* @return {@link Result} encapsulating the result of decoding a barcode in the row
|
||||
* @return {@link RXingResult} encapsulating the result of decoding a barcode in the row
|
||||
* @throws NotFoundException if no potential barcode is found
|
||||
* @throws ChecksumException if a potential barcode is found but does not pass its checksum
|
||||
* @throws FormatException if a potential barcode is found but format is invalid
|
||||
*/
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
int[] startGuardRange,
|
||||
Map<DecodeHintType,?> hints)
|
||||
throws NotFoundException, ChecksumException, FormatException {
|
||||
|
||||
ResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
RXingResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
int symbologyIdentifier = 0;
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(
|
||||
(startGuardRange[0] + startGuardRange[1]) / 2.0f, rowNumber
|
||||
));
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
int endStart = decodeMiddle(row, startGuardRange, result);
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(
|
||||
endStart, rowNumber
|
||||
));
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
int[] endRange = decodeEnd(row, endStart);
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(
|
||||
(endRange[0] + endRange[1]) / 2.0f, rowNumber
|
||||
));
|
||||
}
|
||||
@@ -200,21 +200,21 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
float left = (startGuardRange[1] + startGuardRange[0]) / 2.0f;
|
||||
float right = (endRange[1] + endRange[0]) / 2.0f;
|
||||
BarcodeFormat format = getBarcodeFormat();
|
||||
Result decodeResult = new Result(resultString,
|
||||
RXingResult decodeRXingResult = new RXingResult(resultString,
|
||||
null, // no natural byte representation for these barcodes
|
||||
new ResultPoint[]{
|
||||
new ResultPoint(left, rowNumber),
|
||||
new ResultPoint(right, rowNumber)},
|
||||
new RXingResultPoint[]{
|
||||
new RXingResultPoint(left, rowNumber),
|
||||
new RXingResultPoint(right, rowNumber)},
|
||||
format);
|
||||
|
||||
int extensionLength = 0;
|
||||
|
||||
try {
|
||||
Result extensionResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);
|
||||
decodeResult.putMetadata(ResultMetadataType.UPC_EAN_EXTENSION, extensionResult.getText());
|
||||
decodeResult.putAllMetadata(extensionResult.getResultMetadata());
|
||||
decodeResult.addResultPoints(extensionResult.getResultPoints());
|
||||
extensionLength = extensionResult.getText().length();
|
||||
RXingResult extensionRXingResult = extensionReader.decodeRow(rowNumber, row, endRange[1]);
|
||||
decodeRXingResult.putMetadata(RXingResultMetadataType.UPC_EAN_EXTENSION, extensionRXingResult.getText());
|
||||
decodeRXingResult.putAllMetadata(extensionRXingResult.getRXingResultMetadata());
|
||||
decodeRXingResult.addRXingResultPoints(extensionRXingResult.getRXingResultPoints());
|
||||
extensionLength = extensionRXingResult.getText().length();
|
||||
} catch (ReaderException re) {
|
||||
// continue
|
||||
}
|
||||
@@ -237,16 +237,16 @@ public abstract class UPCEANReader extends OneDReader {
|
||||
if (format == BarcodeFormat.EAN_13 || format == BarcodeFormat.UPC_A) {
|
||||
String countryID = eanManSupport.lookupCountryIdentifier(resultString);
|
||||
if (countryID != null) {
|
||||
decodeResult.putMetadata(ResultMetadataType.POSSIBLE_COUNTRY, countryID);
|
||||
decodeRXingResult.putMetadata(RXingResultMetadataType.POSSIBLE_COUNTRY, countryID);
|
||||
}
|
||||
}
|
||||
if (format == BarcodeFormat.EAN_8) {
|
||||
symbologyIdentifier = 4;
|
||||
}
|
||||
|
||||
decodeResult.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]E" + symbologyIdentifier);
|
||||
decodeRXingResult.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]E" + symbologyIdentifier);
|
||||
|
||||
return decodeResult;
|
||||
return decodeRXingResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.google.zxing.oned.rss;
|
||||
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
|
||||
/**
|
||||
* Encapsulates an RSS barcode finder pattern, including its start/end position and row.
|
||||
@@ -25,14 +25,14 @@ public final class FinderPattern {
|
||||
|
||||
private final int value;
|
||||
private final int[] startEnd;
|
||||
private final ResultPoint[] resultPoints;
|
||||
private final RXingResultPoint[] resultPoints;
|
||||
|
||||
public FinderPattern(int value, int[] startEnd, int start, int end, int rowNumber) {
|
||||
this.value = value;
|
||||
this.startEnd = startEnd;
|
||||
this.resultPoints = new ResultPoint[] {
|
||||
new ResultPoint(start, rowNumber),
|
||||
new ResultPoint(end, rowNumber),
|
||||
this.resultPoints = new RXingResultPoint[] {
|
||||
new RXingResultPoint(start, rowNumber),
|
||||
new RXingResultPoint(end, rowNumber),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class FinderPattern {
|
||||
return startEnd;
|
||||
}
|
||||
|
||||
public ResultPoint[] getResultPoints() {
|
||||
public RXingResultPoint[] getRXingResultPoints() {
|
||||
return resultPoints;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ package com.google.zxing.oned.rss;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.ResultPointCallback;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.RXingResultPointCallback;
|
||||
import com.google.zxing.common.BitArray;
|
||||
import com.google.zxing.common.detector.MathUtils;
|
||||
|
||||
@@ -65,7 +65,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException {
|
||||
Pair leftPair = decodePair(row, false, rowNumber, hints);
|
||||
@@ -78,7 +78,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
if (left.getCount() > 1) {
|
||||
for (Pair right : possibleRightPairs) {
|
||||
if (right.getCount() > 1 && checkChecksum(left, right)) {
|
||||
return constructResult(left, right);
|
||||
return constructRXingResult(left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
possibleRightPairs.clear();
|
||||
}
|
||||
|
||||
private static Result constructResult(Pair leftPair, Pair rightPair) {
|
||||
private static RXingResult constructRXingResult(Pair leftPair, Pair rightPair) {
|
||||
long symbolValue = 4537077L * leftPair.getValue() + rightPair.getValue();
|
||||
String text = String.valueOf(symbolValue);
|
||||
|
||||
@@ -130,14 +130,14 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
}
|
||||
buffer.append(checkDigit);
|
||||
|
||||
ResultPoint[] leftPoints = leftPair.getFinderPattern().getResultPoints();
|
||||
ResultPoint[] rightPoints = rightPair.getFinderPattern().getResultPoints();
|
||||
Result result = new Result(
|
||||
RXingResultPoint[] leftPoints = leftPair.getFinderPattern().getRXingResultPoints();
|
||||
RXingResultPoint[] rightPoints = rightPair.getFinderPattern().getRXingResultPoints();
|
||||
RXingResult result = new RXingResult(
|
||||
buffer.toString(),
|
||||
null,
|
||||
new ResultPoint[] { leftPoints[0], leftPoints[1], rightPoints[0], rightPoints[1], },
|
||||
new RXingResultPoint[] { leftPoints[0], leftPoints[1], rightPoints[0], rightPoints[1], },
|
||||
BarcodeFormat.RSS_14);
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
int[] startEnd = findFinderPattern(row, right);
|
||||
FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd);
|
||||
|
||||
ResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
RXingResultPointCallback resultPointCallback = hints == null ? null :
|
||||
(RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
|
||||
|
||||
if (resultPointCallback != null) {
|
||||
startEnd = pattern.getStartEnd();
|
||||
@@ -169,7 +169,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
||||
// row is actually reversed
|
||||
center = row.getSize() - 1 - center;
|
||||
}
|
||||
resultPointCallback.foundPossibleResultPoint(new ResultPoint(center, rowNumber));
|
||||
resultPointCallback.foundPossibleRXingResultPoint(new RXingResultPoint(center, rowNumber));
|
||||
}
|
||||
|
||||
DataCharacter outside = decodeDataCharacter(row, pattern, true);
|
||||
|
||||
@@ -30,9 +30,9 @@ import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.ResultMetadataType;
|
||||
import com.google.zxing.ResultPoint;
|
||||
import com.google.zxing.RXingResult;
|
||||
import com.google.zxing.RXingResultMetadataType;
|
||||
import com.google.zxing.RXingResultPoint;
|
||||
import com.google.zxing.common.BitArray;
|
||||
import com.google.zxing.common.detector.MathUtils;
|
||||
import com.google.zxing.oned.rss.AbstractRSSReader;
|
||||
@@ -123,7 +123,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||
private boolean startFromEven;
|
||||
|
||||
@Override
|
||||
public Result decodeRow(int rowNumber,
|
||||
public RXingResult decodeRow(int rowNumber,
|
||||
BitArray row,
|
||||
Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
|
||||
// Rows can start with even pattern in case in prev rows there where odd number of patters.
|
||||
@@ -131,14 +131,14 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||
this.pairs.clear();
|
||||
this.startFromEven = false;
|
||||
try {
|
||||
return constructResult(decodeRow2pairs(rowNumber, row));
|
||||
return constructRXingResult(decodeRow2pairs(rowNumber, row));
|
||||
} catch (NotFoundException e) {
|
||||
// OK
|
||||
}
|
||||
|
||||
this.pairs.clear();
|
||||
this.startFromEven = true;
|
||||
return constructResult(decodeRow2pairs(rowNumber, row));
|
||||
return constructRXingResult(decodeRow2pairs(rowNumber, row));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -348,22 +348,22 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
||||
}
|
||||
|
||||
// Not private for unit testing
|
||||
static Result constructResult(List<ExpandedPair> pairs) throws NotFoundException, FormatException {
|
||||
static RXingResult constructRXingResult(List<ExpandedPair> pairs) throws NotFoundException, FormatException {
|
||||
BitArray binary = BitArrayBuilder.buildBitArray(pairs);
|
||||
|
||||
AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary);
|
||||
String resultingString = decoder.parseInformation();
|
||||
|
||||
ResultPoint[] firstPoints = pairs.get(0).getFinderPattern().getResultPoints();
|
||||
ResultPoint[] lastPoints = pairs.get(pairs.size() - 1).getFinderPattern().getResultPoints();
|
||||
RXingResultPoint[] firstPoints = pairs.get(0).getFinderPattern().getRXingResultPoints();
|
||||
RXingResultPoint[] lastPoints = pairs.get(pairs.size() - 1).getFinderPattern().getRXingResultPoints();
|
||||
|
||||
Result result = new Result(
|
||||
RXingResult result = new RXingResult(
|
||||
resultingString,
|
||||
null,
|
||||
new ResultPoint[]{firstPoints[0], firstPoints[1], lastPoints[0], lastPoints[1]},
|
||||
new RXingResultPoint[]{firstPoints[0], firstPoints[1], lastPoints[0], lastPoints[1]},
|
||||
BarcodeFormat.RSS_EXPANDED
|
||||
);
|
||||
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]e0");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,16 +30,16 @@ package com.google.zxing.oned.rss.expanded.decoders;
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
||||
*/
|
||||
final class BlockParsedResult {
|
||||
final class BlockParsedRXingResult {
|
||||
|
||||
private final DecodedInformation decodedInformation;
|
||||
private final boolean finished;
|
||||
|
||||
BlockParsedResult() {
|
||||
BlockParsedRXingResult() {
|
||||
this(null, false);
|
||||
}
|
||||
|
||||
BlockParsedResult(DecodedInformation information, boolean finished) {
|
||||
BlockParsedRXingResult(DecodedInformation information, boolean finished) {
|
||||
this.finished = finished;
|
||||
this.decodedInformation = information;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ final class GeneralAppIdDecoder {
|
||||
|
||||
private DecodedInformation parseBlocks() throws FormatException {
|
||||
boolean isFinished;
|
||||
BlockParsedResult result;
|
||||
BlockParsedRXingResult result;
|
||||
do {
|
||||
int initialPosition = current.getPosition();
|
||||
|
||||
@@ -158,7 +158,7 @@ final class GeneralAppIdDecoder {
|
||||
return result.getDecodedInformation();
|
||||
}
|
||||
|
||||
private BlockParsedResult parseNumericBlock() throws FormatException {
|
||||
private BlockParsedRXingResult parseNumericBlock() throws FormatException {
|
||||
while (isStillNumeric(current.getPosition())) {
|
||||
DecodedNumeric numeric = decodeNumeric(current.getPosition());
|
||||
current.setPosition(numeric.getNewPosition());
|
||||
@@ -170,13 +170,13 @@ final class GeneralAppIdDecoder {
|
||||
} else {
|
||||
information = new DecodedInformation(current.getPosition(), buffer.toString(), numeric.getSecondDigit());
|
||||
}
|
||||
return new BlockParsedResult(information, true);
|
||||
return new BlockParsedRXingResult(information, true);
|
||||
}
|
||||
buffer.append(numeric.getFirstDigit());
|
||||
|
||||
if (numeric.isSecondDigitFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true);
|
||||
return new BlockParsedRXingResult(information, true);
|
||||
}
|
||||
buffer.append(numeric.getSecondDigit());
|
||||
}
|
||||
@@ -185,17 +185,17 @@ final class GeneralAppIdDecoder {
|
||||
current.setAlpha();
|
||||
current.incrementPosition(4);
|
||||
}
|
||||
return new BlockParsedResult();
|
||||
return new BlockParsedRXingResult();
|
||||
}
|
||||
|
||||
private BlockParsedResult parseIsoIec646Block() throws FormatException {
|
||||
private BlockParsedRXingResult parseIsoIec646Block() throws FormatException {
|
||||
while (isStillIsoIec646(current.getPosition())) {
|
||||
DecodedChar iso = decodeIsoIec646(current.getPosition());
|
||||
current.setPosition(iso.getNewPosition());
|
||||
|
||||
if (iso.isFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true);
|
||||
return new BlockParsedRXingResult(information, true);
|
||||
}
|
||||
buffer.append(iso.getValue());
|
||||
}
|
||||
@@ -212,17 +212,17 @@ final class GeneralAppIdDecoder {
|
||||
|
||||
current.setAlpha();
|
||||
}
|
||||
return new BlockParsedResult();
|
||||
return new BlockParsedRXingResult();
|
||||
}
|
||||
|
||||
private BlockParsedResult parseAlphaBlock() {
|
||||
private BlockParsedRXingResult parseAlphaBlock() {
|
||||
while (isStillAlpha(current.getPosition())) {
|
||||
DecodedChar alpha = decodeAlphanumeric(current.getPosition());
|
||||
current.setPosition(alpha.getNewPosition());
|
||||
|
||||
if (alpha.isFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true); //end of the char block
|
||||
return new BlockParsedRXingResult(information, true); //end of the char block
|
||||
}
|
||||
|
||||
buffer.append(alpha.getValue());
|
||||
@@ -240,7 +240,7 @@ final class GeneralAppIdDecoder {
|
||||
|
||||
current.setIsoIec646();
|
||||
}
|
||||
return new BlockParsedResult();
|
||||
return new BlockParsedRXingResult();
|
||||
}
|
||||
|
||||
private boolean isStillIsoIec646(int pos) {
|
||||
|
||||
Reference in New Issue
Block a user