mirror of
https://github.com/zxing/zxing.git
synced 2025-01-13 04:07:27 -08:00
Minor inspection stuff
git-svn-id: https://zxing.googlecode.com/svn/trunk@2247 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
7541fcda65
commit
346de1b561
|
@ -78,8 +78,7 @@ abstract class ContactEncoder {
|
|||
Collection<String> uniques = new HashSet<String>(2);
|
||||
for (String value : values) {
|
||||
String trimmed = trim(value);
|
||||
if (trimmed != null) {
|
||||
if (!uniques.contains(trimmed)) {
|
||||
if (trimmed != null && !uniques.contains(trimmed)) {
|
||||
newContents.append(prefix).append(':').append(fieldFormatter.format(trimmed)).append(terminator);
|
||||
String display = formatter == null ? trimmed : formatter.format(trimmed);
|
||||
newDisplayContents.append(display).append('\n');
|
||||
|
@ -90,6 +89,5 @@ abstract class ContactEncoder {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package com.google.zxing.aztec;
|
|||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.DecodeHintType;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
|
@ -47,7 +46,7 @@ public final class AztecReader implements Reader {
|
|||
* @return a String representing the content encoded by the Data Matrix code
|
||||
* @throws NotFoundException if a Data Matrix code cannot be found
|
||||
* @throws FormatException if a Data Matrix code cannot be decoded
|
||||
* @throws ChecksumException if error correction fails
|
||||
* @throws com.google.zxing.ChecksumException if error correction fails
|
||||
*/
|
||||
@Override
|
||||
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
|
||||
|
|
|
@ -598,7 +598,7 @@ public final class Detector {
|
|||
return new Point(x,y);
|
||||
}
|
||||
|
||||
private static class Point {
|
||||
private static final class Point {
|
||||
public final int x;
|
||||
public final int y;
|
||||
|
||||
|
|
|
@ -207,9 +207,7 @@ public final class VCardResultParser extends ResultParser {
|
|||
case '=':
|
||||
if (i < length - 2) {
|
||||
char nextChar = value.charAt(i+1);
|
||||
if (nextChar == '\r' || nextChar == '\n') {
|
||||
// Ignore, it's just a continuation symbol
|
||||
} else {
|
||||
if (nextChar != '\r' && nextChar != '\n') {
|
||||
char nextNextChar = value.charAt(i+2);
|
||||
int firstDigit = parseHexDigit(nextChar);
|
||||
int secondDigit = parseHexDigit(nextNextChar);
|
||||
|
|
|
@ -174,9 +174,7 @@ final class DecodedBitStreamParser {
|
|||
// Ignore this symbol for now
|
||||
} else if (oneByte >= 242) { // Not to be used in ASCII encodation
|
||||
// ... but work around encoders that end with 254, latch back to ASCII
|
||||
if (oneByte == 254 && bits.available() == 0) {
|
||||
// Ignore
|
||||
} else {
|
||||
if (oneByte != 254 || bits.available() != 0) {
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -406,7 +406,7 @@ public final class Detector {
|
|||
/**
|
||||
* Simply encapsulates two points and a number of transitions between them.
|
||||
*/
|
||||
private static class ResultPointsAndTransitions {
|
||||
private static final class ResultPointsAndTransitions {
|
||||
|
||||
private final ResultPoint from;
|
||||
private final ResultPoint to;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.google.zxing.maxicode.decoder;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
|
||||
/**
|
||||
|
@ -65,7 +64,6 @@ final class BitMatrixParser {
|
|||
|
||||
/**
|
||||
* @param bitMatrix {@link BitMatrix} to parse
|
||||
* @throws FormatException if height is not 33 or width is not 30
|
||||
*/
|
||||
BitMatrixParser(BitMatrix bitMatrix) {
|
||||
this.bitMatrix = bitMatrix;
|
||||
|
|
|
@ -191,13 +191,11 @@ public final class Code128Reader extends OneDReader {
|
|||
bestMatch = startCode;
|
||||
}
|
||||
}
|
||||
if (bestMatch >= 0) {
|
||||
// Look for whitespace before start pattern, >= 50% of width of start pattern
|
||||
if (row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart,
|
||||
false)) {
|
||||
if (bestMatch >= 0 &&
|
||||
row.isRange(Math.max(0, patternStart - (i - patternStart) / 2), patternStart, false)) {
|
||||
return new int[]{patternStart, i, bestMatch};
|
||||
}
|
||||
}
|
||||
patternStart += counters[0] + counters[1];
|
||||
System.arraycopy(counters, 2, counters, 0, patternLength - 2);
|
||||
counters[patternLength - 2] = 0;
|
||||
|
|
|
@ -184,12 +184,11 @@ public final class Code39Reader extends OneDReader {
|
|||
counters[counterPosition]++;
|
||||
} else {
|
||||
if (counterPosition == patternLength - 1) {
|
||||
if (toNarrowWidePattern(counters) == ASTERISK_ENCODING) {
|
||||
// Look for whitespace before start pattern, >= 50% of width of start pattern
|
||||
if (row.isRange(Math.max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) {
|
||||
if (toNarrowWidePattern(counters) == ASTERISK_ENCODING &&
|
||||
row.isRange(Math.max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) {
|
||||
return new int[]{patternStart, i};
|
||||
}
|
||||
}
|
||||
patternStart += counters[0] + counters[1];
|
||||
System.arraycopy(counters, 2, counters, 0, patternLength - 2);
|
||||
counters[patternLength - 2] = 0;
|
||||
|
|
|
@ -67,7 +67,7 @@ public final class ITFWriter extends UPCEANWriter {
|
|||
pos += appendPattern(result, pos, encoding, 1);
|
||||
}
|
||||
int[] end = {3, 1, 1};
|
||||
pos += appendPattern(result, pos, end, 1);
|
||||
appendPattern(result, pos, end, 1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -316,8 +316,6 @@ final class DecodedBitStreamParser {
|
|||
ch = ' ';
|
||||
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
|
||||
subMode = Mode.ALPHA;
|
||||
} else {
|
||||
// is this even possible?
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -152,12 +152,14 @@ public class Detector {
|
|||
if (alignmentPattern != null) {
|
||||
bottomRightX = alignmentPattern.getX();
|
||||
bottomRightY = alignmentPattern.getY();
|
||||
sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f;
|
||||
sourceBottomRightX = dimMinusThree - 3.0f;
|
||||
sourceBottomRightY = sourceBottomRightX;
|
||||
} else {
|
||||
// Don't have an alignment pattern, just make up the bottom-right point
|
||||
bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
|
||||
bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
|
||||
sourceBottomRightX = sourceBottomRightY = dimMinusThree;
|
||||
sourceBottomRightX = dimMinusThree;
|
||||
sourceBottomRightY = dimMinusThree;
|
||||
}
|
||||
|
||||
return PerspectiveTransform.quadrilateralToQuadrilateral(
|
||||
|
|
|
@ -549,7 +549,7 @@ public class FinderPatternFinder {
|
|||
/**
|
||||
* <p>Orders by furthest from average</p>
|
||||
*/
|
||||
private static class FurthestFromAverageComparator implements Comparator<FinderPattern>, Serializable {
|
||||
private static final class FurthestFromAverageComparator implements Comparator<FinderPattern>, Serializable {
|
||||
private final float average;
|
||||
private FurthestFromAverageComparator(float f) {
|
||||
average = f;
|
||||
|
@ -565,7 +565,7 @@ public class FinderPatternFinder {
|
|||
/**
|
||||
* <p>Orders by {@link FinderPattern#getCount()}, descending.</p>
|
||||
*/
|
||||
private static class CenterComparator implements Comparator<FinderPattern>, Serializable {
|
||||
private static final class CenterComparator implements Comparator<FinderPattern>, Serializable {
|
||||
private final float average;
|
||||
private CenterComparator(float f) {
|
||||
average = f;
|
||||
|
|
|
@ -542,7 +542,7 @@ public final class Encoder {
|
|||
try {
|
||||
bytes = content.getBytes(encoding);
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
throw new WriterException(uee.toString());
|
||||
throw new WriterException(uee);
|
||||
}
|
||||
for (byte b : bytes) {
|
||||
bits.appendBits(b, 8);
|
||||
|
@ -554,7 +554,7 @@ public final class Encoder {
|
|||
try {
|
||||
bytes = content.getBytes("Shift_JIS");
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
throw new WriterException(uee.toString());
|
||||
throw new WriterException(uee);
|
||||
}
|
||||
int length = bytes.length;
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
|
|
|
@ -255,11 +255,9 @@ final class MatrixUtil {
|
|||
}
|
||||
|
||||
// Skip masking if mask_pattern is -1.
|
||||
if (maskPattern != -1) {
|
||||
if (MaskUtil.getDataMaskBit(maskPattern, xx, y)) {
|
||||
if (maskPattern != -1 && MaskUtil.getDataMaskBit(maskPattern, xx, y)) {
|
||||
bit = !bit;
|
||||
}
|
||||
}
|
||||
matrix.set(xx, y, bit);
|
||||
}
|
||||
y += direction;
|
||||
|
|
Loading…
Reference in a new issue