mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
move all Result to RXingResult
This commit is contained in:
@@ -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