}
// 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;
}
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;
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;
break;
}
}
- result.append("\n");
+ result.append('\n');
}
return result.toString();
}
\r
private final BitMatrix mappingBitMatrix;\r
private final BitMatrix readMappingMatrix;\r
- private Version version;\r
+ private final Version version;\r
\r
/**\r
* @param bitMatrix {@link BitMatrix} to parse\r
private final StringBuffer decodeRowStringBuffer;
- public AbstractUPCEANReader() {
+ protected AbstractUPCEANReader() {
decodeRowStringBuffer = new StringBuffer(20);
}
/**\r
* Patterns of Wide / Narrow lines to indicate each digit\r
*/\r
- static final int[][] PATTERNS = {\r
+ private static final int[][] PATTERNS = {\r
{N, N, W, W, N}, // 0\r
{W, N, N, N, W}, // 1\r
{N, W, N, N, W}, // 2\r
* @param resultString {@link StringBuffer} to append decoded chars to\r
* @throws ReaderException if decoding could not complete successfully\r
*/\r
- protected void decodeMiddle(BitArray row, int payloadStart, int payloadEnd, StringBuffer resultString) throws ReaderException {\r
+ static void decodeMiddle(BitArray row, int payloadStart, int payloadEnd, StringBuffer resultString) throws ReaderException {\r
\r
// Digits are interleaved in pairs - 5 black lines for one digit, and the\r
// 5\r
}\r
\r
int bestMatch = decodeDigit(counterBlack);\r
- resultString.append((char) ('0' + bestMatch % 10));\r
+ resultString.append((char) ('0' + bestMatch));\r
bestMatch = decodeDigit(counterWhite);\r
- resultString.append((char) ('0' + bestMatch % 10));\r
+ resultString.append((char) ('0' + bestMatch));\r
\r
for (int i = 0; i < counterDigitPair.length; i++) {\r
payloadStart += counterDigitPair[i];\r
* @return The decoded digit\r
* @throws ReaderException if digit cannot be decoded\r
*/\r
- static int decodeDigit(int[] counters) throws ReaderException {\r
+ private static int decodeDigit(int[] counters) throws ReaderException {\r
\r
int bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept\r
int bestMatch = -1;\r
}
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);
}
// 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);
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