mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
More small changes from code inspection
git-svn-id: https://zxing.googlecode.com/svn/trunk@800 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
fa59c4e093
commit
d242b00126
|
@ -45,6 +45,8 @@ public final class ReaderException extends Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent stack traces from being taken
|
// Prevent stack traces from being taken
|
||||||
|
// srowen says: huh, my IDE is saying this is not an override. native methods can't be overridden?
|
||||||
|
// This, at least, does not hurt. Because we use a singleton pattern here, it doesn't matter anyhow.
|
||||||
public Throwable fillInStackTrace() {
|
public Throwable fillInStackTrace() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ final class SMSMMSResultParser extends ResultParser {
|
||||||
String subject = null;
|
String subject = null;
|
||||||
String body = null;
|
String body = null;
|
||||||
boolean querySyntax = false;
|
boolean querySyntax = false;
|
||||||
if (nameValuePairs != null && nameValuePairs.size() > 0) {
|
if (nameValuePairs != null && !nameValuePairs.isEmpty()) {
|
||||||
subject = (String) nameValuePairs.get("subject");
|
subject = (String) nameValuePairs.get("subject");
|
||||||
body = (String) nameValuePairs.get("body");
|
body = (String) nameValuePairs.get("body");
|
||||||
querySyntax = true;
|
querySyntax = true;
|
||||||
|
|
|
@ -66,7 +66,7 @@ public final class ByteArray {
|
||||||
|
|
||||||
public void appendByte(int value) {
|
public void appendByte(int value) {
|
||||||
if (size == 0 || size >= bytes.length) {
|
if (size == 0 || size >= bytes.length) {
|
||||||
int newSize = Math.max(INITIAL_SIZE, size * 2);
|
int newSize = Math.max(INITIAL_SIZE, size << 1);
|
||||||
reserve(newSize);
|
reserve(newSize);
|
||||||
}
|
}
|
||||||
bytes[size] = (byte) value;
|
bytes[size] = (byte) value;
|
||||||
|
|
|
@ -87,7 +87,7 @@ public final class ByteMatrix {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.append("\n");
|
result.append('\n');
|
||||||
}
|
}
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class BitMatrixParser {
|
||||||
|
|
||||||
private final BitMatrix mappingBitMatrix;
|
private final BitMatrix mappingBitMatrix;
|
||||||
private final BitMatrix readMappingMatrix;
|
private final BitMatrix readMappingMatrix;
|
||||||
private Version version;
|
private final Version version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bitMatrix {@link BitMatrix} to parse
|
* @param bitMatrix {@link BitMatrix} to parse
|
||||||
|
|
|
@ -86,7 +86,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements
|
||||||
|
|
||||||
private final StringBuffer decodeRowStringBuffer;
|
private final StringBuffer decodeRowStringBuffer;
|
||||||
|
|
||||||
public AbstractUPCEANReader() {
|
protected AbstractUPCEANReader() {
|
||||||
decodeRowStringBuffer = new StringBuffer(20);
|
decodeRowStringBuffer = new StringBuffer(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ public final class ITFReader extends AbstractOneDReader {
|
||||||
/**
|
/**
|
||||||
* Patterns of Wide / Narrow lines to indicate each digit
|
* Patterns of Wide / Narrow lines to indicate each digit
|
||||||
*/
|
*/
|
||||||
static final int[][] PATTERNS = {
|
private static final int[][] PATTERNS = {
|
||||||
{N, N, W, W, N}, // 0
|
{N, N, W, W, N}, // 0
|
||||||
{W, N, N, N, W}, // 1
|
{W, N, N, N, W}, // 1
|
||||||
{N, W, N, N, W}, // 2
|
{N, W, N, N, W}, // 2
|
||||||
|
@ -106,7 +106,7 @@ public final class ITFReader extends AbstractOneDReader {
|
||||||
* @param resultString {@link StringBuffer} to append decoded chars to
|
* @param resultString {@link StringBuffer} to append decoded chars to
|
||||||
* @throws ReaderException if decoding could not complete successfully
|
* @throws ReaderException if decoding could not complete successfully
|
||||||
*/
|
*/
|
||||||
protected void decodeMiddle(BitArray row, int payloadStart, int payloadEnd, StringBuffer resultString) throws ReaderException {
|
static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd, StringBuffer resultString) throws ReaderException {
|
||||||
|
|
||||||
// Digits are interleaved in pairs - 5 black lines for one digit, and the
|
// Digits are interleaved in pairs - 5 black lines for one digit, and the
|
||||||
// 5
|
// 5
|
||||||
|
@ -129,9 +129,9 @@ public final class ITFReader extends AbstractOneDReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
int bestMatch = decodeDigit(counterBlack);
|
int bestMatch = decodeDigit(counterBlack);
|
||||||
resultString.append((char) ('0' + bestMatch % 10));
|
resultString.append((char) ('0' + bestMatch));
|
||||||
bestMatch = decodeDigit(counterWhite);
|
bestMatch = decodeDigit(counterWhite);
|
||||||
resultString.append((char) ('0' + bestMatch % 10));
|
resultString.append((char) ('0' + bestMatch));
|
||||||
|
|
||||||
for (int i = 0; i < counterDigitPair.length; i++) {
|
for (int i = 0; i < counterDigitPair.length; i++) {
|
||||||
payloadStart += counterDigitPair[i];
|
payloadStart += counterDigitPair[i];
|
||||||
|
@ -312,7 +312,7 @@ public final class ITFReader extends AbstractOneDReader {
|
||||||
* @return The decoded digit
|
* @return The decoded digit
|
||||||
* @throws ReaderException if digit cannot be decoded
|
* @throws ReaderException if digit cannot be decoded
|
||||||
*/
|
*/
|
||||||
static int decodeDigit(int[] counters) throws ReaderException {
|
private static int decodeDigit(int[] counters) throws ReaderException {
|
||||||
|
|
||||||
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
|
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
|
||||||
int bestMatch = -1;
|
int bestMatch = -1;
|
||||||
|
|
|
@ -54,7 +54,7 @@ public final class QRCodeWriter implements Writer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (width < 0 || height < 0) {
|
if (width < 0 || height < 0) {
|
||||||
throw new IllegalArgumentException("Requested dimensions are too small: " + width + "x" +
|
throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' +
|
||||||
height);
|
height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,12 +73,12 @@ public final class QRCodeWriter implements Writer {
|
||||||
|
|
||||||
// Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
|
// Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses
|
||||||
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
|
// 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap).
|
||||||
private ByteMatrix renderResult(QRCode code, int width, int height) {
|
private static ByteMatrix renderResult(QRCode code, int width, int height) {
|
||||||
ByteMatrix input = code.getMatrix();
|
ByteMatrix input = code.getMatrix();
|
||||||
int inputWidth = input.width();
|
int inputWidth = input.width();
|
||||||
int inputHeight = input.height();
|
int inputHeight = input.height();
|
||||||
int qrWidth = inputWidth + (QUIET_ZONE_SIZE * 2);
|
int qrWidth = inputWidth + (QUIET_ZONE_SIZE << 1);
|
||||||
int qrHeight = inputHeight + (QUIET_ZONE_SIZE * 2);
|
int qrHeight = inputHeight + (QUIET_ZONE_SIZE << 1);
|
||||||
int outputWidth = Math.max(width, qrWidth);
|
int outputWidth = Math.max(width, qrWidth);
|
||||||
int outputHeight = Math.max(height, qrHeight);
|
int outputHeight = Math.max(height, qrHeight);
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ final class FormatInformation {
|
||||||
private final ErrorCorrectionLevel errorCorrectionLevel;
|
private final ErrorCorrectionLevel errorCorrectionLevel;
|
||||||
private final byte dataMask;
|
private final byte dataMask;
|
||||||
|
|
||||||
private FormatInformation(int formatInfo) throws ReaderException {
|
private FormatInformation(int formatInfo) {
|
||||||
// Bits 3,4
|
// Bits 3,4
|
||||||
errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
|
errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03);
|
||||||
// Bottom 3 bits
|
// Bottom 3 bits
|
||||||
|
|
Loading…
Reference in a new issue