From: srowen Date: Sun, 21 Dec 2008 18:54:58 +0000 (+0000) Subject: More small changes from code inspection X-Git-Url: http://git.rot13.org/?p=zxing.git;a=commitdiff_plain;h=a96a22b731c6402277a70ca54ccec32088adbfbb More small changes from code inspection git-svn-id: http://zxing.googlecode.com/svn/trunk@800 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- diff --git a/core/src/com/google/zxing/ReaderException.java b/core/src/com/google/zxing/ReaderException.java index 750dde8c..0d8a3d53 100644 --- a/core/src/com/google/zxing/ReaderException.java +++ b/core/src/com/google/zxing/ReaderException.java @@ -45,6 +45,8 @@ public final class ReaderException extends Exception { } // 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() { return null; } diff --git a/core/src/com/google/zxing/client/result/SMSMMSResultParser.java b/core/src/com/google/zxing/client/result/SMSMMSResultParser.java index dfa5da08..88bcfa38 100644 --- a/core/src/com/google/zxing/client/result/SMSMMSResultParser.java +++ b/core/src/com/google/zxing/client/result/SMSMMSResultParser.java @@ -57,7 +57,7 @@ final class SMSMMSResultParser extends ResultParser { String subject = null; String body = null; boolean querySyntax = false; - if (nameValuePairs != null && nameValuePairs.size() > 0) { + if (nameValuePairs != null && !nameValuePairs.isEmpty()) { subject = (String) nameValuePairs.get("subject"); body = (String) nameValuePairs.get("body"); querySyntax = true; diff --git a/core/src/com/google/zxing/common/ByteArray.java b/core/src/com/google/zxing/common/ByteArray.java index 7382b785..8fccba4d 100644 --- a/core/src/com/google/zxing/common/ByteArray.java +++ b/core/src/com/google/zxing/common/ByteArray.java @@ -66,7 +66,7 @@ public final class ByteArray { public void appendByte(int value) { if (size == 0 || size >= bytes.length) { - int newSize = Math.max(INITIAL_SIZE, size * 2); + int newSize = Math.max(INITIAL_SIZE, size << 1); reserve(newSize); } bytes[size] = (byte) value; diff --git a/core/src/com/google/zxing/common/ByteMatrix.java b/core/src/com/google/zxing/common/ByteMatrix.java index 056e2612..b924296e 100644 --- a/core/src/com/google/zxing/common/ByteMatrix.java +++ b/core/src/com/google/zxing/common/ByteMatrix.java @@ -87,7 +87,7 @@ public final class ByteMatrix { break; } } - result.append("\n"); + result.append('\n'); } return result.toString(); } diff --git a/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java b/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java index 443b099e..fe483022 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java +++ b/core/src/com/google/zxing/datamatrix/decoder/BitMatrixParser.java @@ -26,7 +26,7 @@ final class BitMatrixParser { private final BitMatrix mappingBitMatrix; private final BitMatrix readMappingMatrix; - private Version version; + private final Version version; /** * @param bitMatrix {@link BitMatrix} to parse diff --git a/core/src/com/google/zxing/oned/AbstractUPCEANReader.java b/core/src/com/google/zxing/oned/AbstractUPCEANReader.java index 53ba2ccc..5336e0dc 100644 --- a/core/src/com/google/zxing/oned/AbstractUPCEANReader.java +++ b/core/src/com/google/zxing/oned/AbstractUPCEANReader.java @@ -86,7 +86,7 @@ public abstract class AbstractUPCEANReader extends AbstractOneDReader implements private final StringBuffer decodeRowStringBuffer; - public AbstractUPCEANReader() { + protected AbstractUPCEANReader() { decodeRowStringBuffer = new StringBuffer(20); } diff --git a/core/src/com/google/zxing/oned/ITFReader.java b/core/src/com/google/zxing/oned/ITFReader.java index a2965831..d7db263f 100644 --- a/core/src/com/google/zxing/oned/ITFReader.java +++ b/core/src/com/google/zxing/oned/ITFReader.java @@ -60,7 +60,7 @@ public final class ITFReader extends AbstractOneDReader { /** * Patterns of Wide / Narrow lines to indicate each digit */ - static final int[][] PATTERNS = { + private static final int[][] PATTERNS = { {N, N, W, W, N}, // 0 {W, N, N, N, W}, // 1 {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 * @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 // 5 @@ -129,9 +129,9 @@ public final class ITFReader extends AbstractOneDReader { } int bestMatch = decodeDigit(counterBlack); - resultString.append((char) ('0' + bestMatch % 10)); + resultString.append((char) ('0' + bestMatch)); bestMatch = decodeDigit(counterWhite); - resultString.append((char) ('0' + bestMatch % 10)); + resultString.append((char) ('0' + bestMatch)); for (int i = 0; i < counterDigitPair.length; i++) { payloadStart += counterDigitPair[i]; @@ -312,7 +312,7 @@ public final class ITFReader extends AbstractOneDReader { * @return The decoded digit * @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 bestMatch = -1; diff --git a/core/src/com/google/zxing/qrcode/QRCodeWriter.java b/core/src/com/google/zxing/qrcode/QRCodeWriter.java index 874cc0ed..c3f24ea9 100644 --- a/core/src/com/google/zxing/qrcode/QRCodeWriter.java +++ b/core/src/com/google/zxing/qrcode/QRCodeWriter.java @@ -54,7 +54,7 @@ public final class QRCodeWriter implements Writer { } 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); } @@ -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 // 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(); int inputWidth = input.width(); int inputHeight = input.height(); - int qrWidth = inputWidth + (QUIET_ZONE_SIZE * 2); - int qrHeight = inputHeight + (QUIET_ZONE_SIZE * 2); + int qrWidth = inputWidth + (QUIET_ZONE_SIZE << 1); + int qrHeight = inputHeight + (QUIET_ZONE_SIZE << 1); int outputWidth = Math.max(width, qrWidth); int outputHeight = Math.max(height, qrHeight); diff --git a/core/src/com/google/zxing/qrcode/decoder/FormatInformation.java b/core/src/com/google/zxing/qrcode/decoder/FormatInformation.java index e7649d78..f9cbefec 100644 --- a/core/src/com/google/zxing/qrcode/decoder/FormatInformation.java +++ b/core/src/com/google/zxing/qrcode/decoder/FormatInformation.java @@ -77,7 +77,7 @@ final class FormatInformation { private final ErrorCorrectionLevel errorCorrectionLevel; private final byte dataMask; - private FormatInformation(int formatInfo) throws ReaderException { + private FormatInformation(int formatInfo) { // Bits 3,4 errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); // Bottom 3 bits