diff --git a/android-integration/src/com/google/zxing/integration/android/IntentResult.java b/android-integration/src/com/google/zxing/integration/android/IntentResult.java index d4c69c025..5f41c9b8f 100644 --- a/android-integration/src/com/google/zxing/integration/android/IntentResult.java +++ b/android-integration/src/com/google/zxing/integration/android/IntentResult.java @@ -39,7 +39,7 @@ public final class IntentResult { } /** - * @return name of format, like "QR_CODE", "UPC_A". See BarcodeFormat for more format names. + * @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names. */ public String getFormatName() { return formatName; diff --git a/android/src/com/google/zxing/client/android/CaptureActivity.java b/android/src/com/google/zxing/client/android/CaptureActivity.java index fbc7891c0..f187ce535 100755 --- a/android/src/com/google/zxing/client/android/CaptureActivity.java +++ b/android/src/com/google/zxing/client/android/CaptureActivity.java @@ -422,8 +422,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal paint.setStrokeWidth(4.0f); drawLine(canvas, paint, points[0], points[1]); } else if (points.length == 4 && - (rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A)) || - (rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) { + (rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A) || + rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) { // Hacky special case -- draw two lines, for the barcode and metadata drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[2], points[3]); @@ -590,7 +590,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal Intent intent = new Intent(this, HelpActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Show the default page on a clean install, and the what's new page on an upgrade. - String page = (lastVersion == 0) ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE; + String page = lastVersion == 0 ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE; intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page); startActivity(intent); return true; diff --git a/android/src/com/google/zxing/client/android/book/SearchBookContentsActivity.java b/android/src/com/google/zxing/client/android/book/SearchBookContentsActivity.java index 4817a7012..8033ea250 100644 --- a/android/src/com/google/zxing/client/android/book/SearchBookContentsActivity.java +++ b/android/src/com/google/zxing/client/android/book/SearchBookContentsActivity.java @@ -18,7 +18,6 @@ package com.google.zxing.client.android.book; import android.app.Activity; import android.content.Intent; -import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -121,7 +120,7 @@ public final class SearchBookContentsActivity extends Activity { CookieManager.getInstance().removeExpiredCookie(); Intent intent = getIntent(); - if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) { + if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) { finish(); return; } diff --git a/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java b/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java index 7d522d331..4ad5fd05f 100644 --- a/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/CalendarResultHandler.java @@ -106,7 +106,7 @@ public final class CalendarResultHandler extends ResultHandler { long milliseconds = date.getTime(); if (when.length() == 16 && when.charAt(15) == 'Z') { Calendar calendar = new GregorianCalendar(); - int offset = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)); + int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); milliseconds += offset; } ParsedResult.maybeAppend(DateFormat.getDateTimeInstance().format(milliseconds), result); diff --git a/android/src/com/google/zxing/client/android/result/ResultHandler.java b/android/src/com/google/zxing/client/android/result/ResultHandler.java index 7f6a2c282..022e1ac78 100644 --- a/android/src/com/google/zxing/client/android/result/ResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/ResultHandler.java @@ -247,13 +247,13 @@ public abstract class ResultHandler { intent.setType(Contacts.People.CONTENT_ITEM_TYPE); putExtra(intent, Contacts.Intents.Insert.NAME, names != null ? names[0] : null); - int phoneCount = Math.min((phoneNumbers != null) ? phoneNumbers.length : 0, + int phoneCount = Math.min(phoneNumbers != null ? phoneNumbers.length : 0, Contents.PHONE_KEYS.length); for (int x = 0; x < phoneCount; x++) { putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[x]); } - int emailCount = Math.min((emails != null) ? emails.length : 0, Contents.EMAIL_KEYS.length); + int emailCount = Math.min(emails != null ? emails.length : 0, Contents.EMAIL_KEYS.length); for (int x = 0; x < emailCount; x++) { putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]); } diff --git a/android/src/com/google/zxing/client/android/share/BookmarkAdapter.java b/android/src/com/google/zxing/client/android/share/BookmarkAdapter.java index 27d8b4814..ee9364e1f 100644 --- a/android/src/com/google/zxing/client/android/share/BookmarkAdapter.java +++ b/android/src/com/google/zxing/client/android/share/BookmarkAdapter.java @@ -36,8 +36,9 @@ import android.widget.TextView; * @author dswitkin@google.com (Daniel Switkin) */ public final class BookmarkAdapter extends BaseAdapter { - private Context context; - private Cursor cursor; + + private final Context context; + private final Cursor cursor; public BookmarkAdapter(Context context, Cursor cursor) { this.context = context; diff --git a/android/src/com/google/zxing/client/android/wifi/WifiActivity.java b/android/src/com/google/zxing/client/android/wifi/WifiActivity.java index d5794974c..56488098b 100644 --- a/android/src/com/google/zxing/client/android/wifi/WifiActivity.java +++ b/android/src/com/google/zxing/client/android/wifi/WifiActivity.java @@ -199,7 +199,7 @@ public final class WifiActivity extends Activity { super.onCreate(savedInstanceState); Intent intent = getIntent(); - if (intent == null || (!intent.getAction().equals(Intents.WifiConnect.ACTION))) { + if (intent == null || !intent.getAction().equals(Intents.WifiConnect.ACTION)) { finish(); return; } @@ -211,11 +211,11 @@ public final class WifiActivity extends Activity { statusView = (TextView) findViewById(R.id.networkStatus); NetworkType networkT; - if (networkType.equals("WPA")) { + if ("WPA".equals(networkType)) { networkT = NetworkType.NETWORK_WPA; - } else if (networkType.equals("WEP")) { + } else if ("WEP".equals(networkType)) { networkT = NetworkType.NETWORK_WEP; - } else if (networkType.equals("nopass")) { + } else if ("nopass".equals(networkType)) { networkT = NetworkType.NETWORK_NOPASS; } else { doError(R.string.wifi_type_incorrect); diff --git a/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java b/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java index e9c5ada3a..0c230997f 100644 --- a/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java +++ b/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java @@ -73,7 +73,7 @@ final class WifiReceiver extends BroadcastReceiver { delayKill.run(); } if (state == NetworkInfo.State.DISCONNECTED){ - Log.d(TAG, "Got state: " + state + " for ssid: " + ssid); + Log.d(TAG, "Got state Disconnected for ssid: " + ssid); parent.gotError(); } } diff --git a/androidtest/src/com/google/zxing/client/androidtest/CameraManager.java b/androidtest/src/com/google/zxing/client/androidtest/CameraManager.java index 37b84dcc9..4996783d6 100755 --- a/androidtest/src/com/google/zxing/client/androidtest/CameraManager.java +++ b/androidtest/src/com/google/zxing/client/androidtest/CameraManager.java @@ -56,8 +56,6 @@ final class CameraManager { private int autoFocusMessage; private boolean initialized; private boolean previewing; - private int previewFormat; - private String previewFormatString; private final boolean useOneShotPreviewCallback; /** @@ -263,8 +261,8 @@ final class CameraManager { Camera.Parameters parameters = camera.getParameters(); Camera.Size size = parameters.getPreviewSize(); Log.v(TAG, "Default preview size: " + size.width + ", " + size.height); - previewFormat = parameters.getPreviewFormat(); - previewFormatString = parameters.get("preview-format"); + int previewFormat = parameters.getPreviewFormat(); + String previewFormatString = parameters.get("preview-format"); Log.v(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString); // Ensure that the camera resolution is a multiple of 8, as the screen may not be. diff --git a/androidtest/src/com/google/zxing/client/androidtest/RGBLuminanceSource.java b/androidtest/src/com/google/zxing/client/androidtest/RGBLuminanceSource.java index 0be705283..5adaff87a 100644 --- a/androidtest/src/com/google/zxing/client/androidtest/RGBLuminanceSource.java +++ b/androidtest/src/com/google/zxing/client/androidtest/RGBLuminanceSource.java @@ -66,6 +66,7 @@ public final class RGBLuminanceSource extends LuminanceSource { } } + @Override public byte[] getRow(int y, byte[] row) { if (y < 0 || y >= getHeight()) { throw new IllegalArgumentException("Requested row is outside the image: " + y); @@ -81,6 +82,7 @@ public final class RGBLuminanceSource extends LuminanceSource { // Since this class does not support cropping, the underlying byte array already contains // exactly what the caller is asking for, so give it to them without a copy. + @Override public byte[] getMatrix() { return luminances; } diff --git a/androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java b/androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java index 99d5069e7..c6bc1b437 100755 --- a/androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java +++ b/androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java @@ -65,23 +65,22 @@ public final class ZXingTestActivity extends Activity { @Override public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case ABOUT_ID: - int versionCode = 0; - String versionName = "unknown"; - try { - PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0); - versionCode = info.versionCode; - versionName = info.versionName; - } catch (PackageManager.NameNotFoundException e) { - } - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getString(R.string.app_name) + " " + versionName + " (" + versionCode + - ")"); - builder.setMessage(getString(R.string.about_message)); - builder.setPositiveButton(R.string.ok_button, null); - builder.show(); - break; + if (item.getItemId() == ABOUT_ID) { + int versionCode = 0; + String versionName = "unknown"; + try { + PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0); + versionCode = info.versionCode; + versionName = info.versionName; + } catch (PackageManager.NameNotFoundException e) { + } + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle( + getString(R.string.app_name) + ' ' + versionName + " (" + versionCode + ')'); + builder.setMessage(getString(R.string.about_message)); + builder.setPositiveButton(R.string.ok_button, null); + builder.show(); + } return super.onOptionsItemSelected(item); } @@ -215,7 +214,7 @@ public final class ZXingTestActivity extends Activity { } }; - private void showDialog(int title, String message) { + private void showDialog(int title, CharSequence message) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(title); builder.setMessage(message); diff --git a/core/src/com/google/zxing/ResultPoint.java b/core/src/com/google/zxing/ResultPoint.java index 0c8e883d7..366ae3855 100644 --- a/core/src/com/google/zxing/ResultPoint.java +++ b/core/src/com/google/zxing/ResultPoint.java @@ -73,7 +73,9 @@ public class ResultPoint { float oneTwoDistance = distance(patterns[1], patterns[2]); float zeroTwoDistance = distance(patterns[0], patterns[2]); - ResultPoint pointA, pointB, pointC; + ResultPoint pointA; + ResultPoint pointB; + ResultPoint pointC; // Assume one closest to other two is B; A and C will just be guesses at first if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) { pointB = patterns[0]; diff --git a/core/src/com/google/zxing/aztec/decoder/Decoder.java b/core/src/com/google/zxing/aztec/decoder/Decoder.java index 45e8205a7..b14f09992 100644 --- a/core/src/com/google/zxing/aztec/decoder/Decoder.java +++ b/core/src/com/google/zxing/aztec/decoder/Decoder.java @@ -147,7 +147,7 @@ public final class Decoder { code = readCode(correctedBits, startIndex, 8); startIndex += 8; - result.append((char)(code)); + result.append((char) code); break; default: diff --git a/core/src/com/google/zxing/aztec/detector/Detector.java b/core/src/com/google/zxing/aztec/detector/Detector.java index c58f30507..95b2ce974 100644 --- a/core/src/com/google/zxing/aztec/detector/Detector.java +++ b/core/src/com/google/zxing/aztec/detector/Detector.java @@ -152,7 +152,7 @@ public final class Detector { /** * - *

Gets the aztec code corners from the bull's eye corners and the parameters

+ *

Gets the Aztec code corners from the bull's eye corners and the parameters

* * @param bullEyeCornerPoints the array of bull's eye corners * @return the array of aztec code corners @@ -160,7 +160,8 @@ public final class Detector { */ private ResultPoint[] getMatrixCornerPoints(Point[] bullEyeCornerPoints) throws NotFoundException { - float ratio = (2*nbLayers+(nbLayers>4?1:0)+(nbLayers-4)/8)/(2.0f*nbCenterLayers); + float ratio = (2 * nbLayers + (nbLayers > 4 ? 1 : 0) + (nbLayers - 4) / 8) + / (2.0f * nbCenterLayers); int dx = bullEyeCornerPoints[0].x-bullEyeCornerPoints[2].x; dx+=dx>0?1:-1; @@ -609,7 +610,7 @@ public final class Detector { } private boolean isValid(int x, int y) { - return (x >= 0 && x < image.width && y > 0 && y < image.height); + return x >= 0 && x < image.width && y > 0 && y < image.height; } /** diff --git a/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java b/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java index cddbda81b..22f28d0a5 100644 --- a/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java +++ b/core/src/com/google/zxing/client/result/ExpandedProductResultParser.java @@ -46,7 +46,7 @@ final class ExpandedProductResultParser extends ResultParser { // product barcodes with complementary data. public static ExpandedProductParsedResult parse(Result result) { BarcodeFormat format = result.getBarcodeFormat(); - if (!(BarcodeFormat.RSS_EXPANDED.equals(format))) { + if (!BarcodeFormat.RSS_EXPANDED.equals(format)) { // ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode return null; } diff --git a/core/src/com/google/zxing/client/result/GeoResultParser.java b/core/src/com/google/zxing/client/result/GeoResultParser.java index 8459ddcbc..7a0db6e5b 100644 --- a/core/src/com/google/zxing/client/result/GeoResultParser.java +++ b/core/src/com/google/zxing/client/result/GeoResultParser.java @@ -52,7 +52,9 @@ final class GeoResultParser extends ResultParser { return null; } int longitudeEnd = geoURIWithoutQuery.indexOf(',', latitudeEnd + 1); - double latitude, longitude, altitude; + double latitude; + double longitude; + double altitude; try { latitude = Double.parseDouble(geoURIWithoutQuery.substring(0, latitudeEnd)); if (latitude > 90.0 || latitude < -90.0) { diff --git a/core/src/com/google/zxing/client/result/ResultParser.java b/core/src/com/google/zxing/client/result/ResultParser.java index bdcc4d09b..86f1b1081 100644 --- a/core/src/com/google/zxing/client/result/ResultParser.java +++ b/core/src/com/google/zxing/client/result/ResultParser.java @@ -146,26 +146,30 @@ public abstract class ResultParser { for (int i = first; i < max; i++) { char c = escapedArray[i]; - if (c == '+') { - // + is translated directly into a space - unescaped.append(' '); - } else if (c == '%') { - // Are there even two more chars? if not we will just copy the escaped sequence and be done - if (i >= max - 2) { - unescaped.append('%'); // append that % and move on - } else { - int firstDigitValue = parseHexDigit(escapedArray[++i]); - int secondDigitValue = parseHexDigit(escapedArray[++i]); - if (firstDigitValue < 0 || secondDigitValue < 0) { - // bad digit, just move on - unescaped.append('%'); - unescaped.append(escapedArray[i-1]); - unescaped.append(escapedArray[i]); + switch (c) { + case '+': + // + is translated directly into a space + unescaped.append(' '); + break; + case '%': + // Are there even two more chars? if not we will just copy the escaped sequence and be done + if (i >= max - 2) { + unescaped.append('%'); // append that % and move on + } else { + int firstDigitValue = parseHexDigit(escapedArray[++i]); + int secondDigitValue = parseHexDigit(escapedArray[++i]); + if (firstDigitValue < 0 || secondDigitValue < 0) { + // bad digit, just move on + unescaped.append('%'); + unescaped.append(escapedArray[i - 1]); + unescaped.append(escapedArray[i]); + } + unescaped.append((char) ((firstDigitValue << 4) + secondDigitValue)); } - unescaped.append((char) ((firstDigitValue << 4) + secondDigitValue)); - } - } else { - unescaped.append(c); + break; + default: + unescaped.append(c); + break; } } return unescaped.toString(); diff --git a/core/src/com/google/zxing/client/result/VCardResultParser.java b/core/src/com/google/zxing/client/result/VCardResultParser.java index 4d5397139..4b714f4ab 100644 --- a/core/src/com/google/zxing/client/result/VCardResultParser.java +++ b/core/src/com/google/zxing/client/result/VCardResultParser.java @@ -106,11 +106,11 @@ final class VCardResultParser extends ResultParser { if (equals >= 0) { String key = metadata.substring(0, equals); String value = metadata.substring(equals+1); - if (key.equalsIgnoreCase("ENCODING")) { - if (value.equalsIgnoreCase("QUOTED-PRINTABLE")) { + if ("ENCODING".equalsIgnoreCase(key)) { + if ("QUOTED-PRINTABLE".equalsIgnoreCase(value)) { quotedPrintable = true; } - } else if (key.equalsIgnoreCase("CHARSET")) { + } else if ("CHARSET".equalsIgnoreCase(key)) { quotedPrintableCharset = value; } } diff --git a/core/src/com/google/zxing/client/result/VEventResultParser.java b/core/src/com/google/zxing/client/result/VEventResultParser.java index b6278f2d9..cff92a35c 100644 --- a/core/src/com/google/zxing/client/result/VEventResultParser.java +++ b/core/src/com/google/zxing/client/result/VEventResultParser.java @@ -53,8 +53,12 @@ final class VEventResultParser extends ResultParser { longitude = Double.NaN; } else { int semicolon = geoString.indexOf(';'); - latitude = Double.parseDouble(geoString.substring(0, semicolon)); - longitude = Double.parseDouble(geoString.substring(semicolon + 1)); + try { + latitude = Double.parseDouble(geoString.substring(0, semicolon)); + longitude = Double.parseDouble(geoString.substring(semicolon + 1)); + } catch (NumberFormatException nfe) { + return null; + } } try { diff --git a/core/src/com/google/zxing/common/CharacterSetECI.java b/core/src/com/google/zxing/common/CharacterSetECI.java index 26a151888..42b7fa9f6 100644 --- a/core/src/com/google/zxing/common/CharacterSetECI.java +++ b/core/src/com/google/zxing/common/CharacterSetECI.java @@ -81,7 +81,7 @@ public final class CharacterSetECI extends ECI { /** * @param value character set ECI value - * @return {@link CharacterSetECI} representing ECI of given value, or null if it is legal but + * @return CharacterSetECI representing ECI of given value, or null if it is legal but * unsupported * @throws IllegalArgumentException if ECI value is invalid */ @@ -97,7 +97,7 @@ public final class CharacterSetECI extends ECI { /** * @param name character set ECI encoding name - * @return {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal + * @return CharacterSetECI representing ECI for character encoding, or null if it is legal * but unsupported */ public static CharacterSetECI getCharacterSetECIByName(String name) { diff --git a/core/src/com/google/zxing/common/ECI.java b/core/src/com/google/zxing/common/ECI.java index 9d725dbc3..444c779c2 100644 --- a/core/src/com/google/zxing/common/ECI.java +++ b/core/src/com/google/zxing/common/ECI.java @@ -36,7 +36,7 @@ public abstract class ECI { /** * @param value ECI value - * @return {@link ECI} representing ECI of given value, or null if it is legal but unsupported + * @return ECI representing ECI of given value, or null if it is legal but unsupported * @throws IllegalArgumentException if ECI value is invalid */ public static ECI getECIByValue(int value) { diff --git a/core/src/com/google/zxing/common/GridSampler.java b/core/src/com/google/zxing/common/GridSampler.java index bd892d889..7f26c264e 100644 --- a/core/src/com/google/zxing/common/GridSampler.java +++ b/core/src/com/google/zxing/common/GridSampler.java @@ -36,7 +36,7 @@ public abstract class GridSampler { private static GridSampler gridSampler = new DefaultGridSampler(); /** - * Sets the implementation of {@link GridSampler} used by the library. One global + * Sets the implementation of GridSampler used by the library. One global * instance is stored, which may sound problematic. But, the implementation provided * ought to be appropriate for the entire platform, and all uses of this library * in the whole lifetime of the JVM. For instance, an Android activity can swap in @@ -52,7 +52,7 @@ public abstract class GridSampler { } /** - * @return the current implementation of {@link GridSampler} + * @return the current implementation of GridSampler */ public static GridSampler getInstance() { return gridSampler; diff --git a/core/src/com/google/zxing/common/HybridBinarizer.java b/core/src/com/google/zxing/common/HybridBinarizer.java index e89b06f5d..b482c1a22 100644 --- a/core/src/com/google/zxing/common/HybridBinarizer.java +++ b/core/src/com/google/zxing/common/HybridBinarizer.java @@ -102,10 +102,10 @@ public final class HybridBinarizer extends GlobalHistogramBinarizer { if ((xoffset + 8) >= width) { xoffset = width - 8; } - int left = (x > 1) ? x : 2; - left = (left < subWidth - 2) ? left : subWidth - 3; - int top = (y > 1) ? y : 2; - top = (top < subHeight - 2) ? top : subHeight - 3; + int left = x > 1 ? x : 2; + left = left < subWidth - 2 ? left : subWidth - 3; + int top = y > 1 ? y : 2; + top = top < subHeight - 2 ? top : subHeight - 3; int sum = 0; for (int z = -2; z <= 2; z++) { int[] blackRow = blackPoints[top + z]; diff --git a/core/src/com/google/zxing/common/StringUtils.java b/core/src/com/google/zxing/common/StringUtils.java index 7ebff6f3d..97999f997 100644 --- a/core/src/com/google/zxing/common/StringUtils.java +++ b/core/src/com/google/zxing/common/StringUtils.java @@ -132,7 +132,7 @@ public final class StringUtils { ((value >= 0xF0 && value <= 0xFF) || value == 0x80 || value == 0xA0)) { canBeShiftJIS = false; } - if (((value >= 0x81 && value <= 0x9F) || (value >= 0xE0 && value <= 0xEF))) { + if ((value >= 0x81 && value <= 0x9F) || (value >= 0xE0 && value <= 0xEF)) { // These start double-byte characters in Shift_JIS. Let's see if it's followed by a valid // second byte. if (lastWasPossibleDoubleByteStart) { diff --git a/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java b/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java index 3e75d4198..b523fd34b 100644 --- a/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java +++ b/core/src/com/google/zxing/common/reedsolomon/ReedSolomonDecoder.java @@ -177,7 +177,7 @@ public final class ReedSolomonDecoder { // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. // Below is a funny-looking workaround from Steven Parkes int term = field.multiply(errorLocations[j], xiInverse); - int termPlus1 = ((term & 0x1) == 0) ? (term | 1) : (term & ~1); + int termPlus1 = (term & 0x1) == 0 ? term | 1 : term & ~1; denominator = field.multiply(denominator, termPlus1); } } diff --git a/core/src/com/google/zxing/datamatrix/decoder/DataBlock.java b/core/src/com/google/zxing/datamatrix/decoder/DataBlock.java index 9a1b4e29b..17577adb9 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/DataBlock.java +++ b/core/src/com/google/zxing/datamatrix/decoder/DataBlock.java @@ -40,7 +40,7 @@ final class DataBlock { * * @param rawCodewords bytes as read directly from the Data Matrix Code * @param version version of the Data Matrix Code - * @return {@link DataBlock}s containing original bytes, "de-interleaved" from representation in the + * @return DataBlocks containing original bytes, "de-interleaved" from representation in the * Data Matrix Code */ static DataBlock[] getDataBlocks(byte[] rawCodewords, @@ -95,7 +95,7 @@ final class DataBlock { int max = result[0].codewords.length; for (int i = longerBlocksNumDataCodewords; i < max; i++) { for (int j = 0; j < numResultBlocks; j++) { - int iOffset = (specialVersion && j > 7) ? i - 1 : i; + int iOffset = specialVersion && j > 7 ? i - 1 : i; result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; } } diff --git a/core/src/com/google/zxing/datamatrix/decoder/Version.java b/core/src/com/google/zxing/datamatrix/decoder/Version.java index 5f9785449..8cadac989 100644 --- a/core/src/com/google/zxing/datamatrix/decoder/Version.java +++ b/core/src/com/google/zxing/datamatrix/decoder/Version.java @@ -93,7 +93,7 @@ public final class Version { * * @param numRows Number of rows in modules * @param numColumns Number of columns in modules - * @return {@link Version} for a Data Matrix Code of those dimensions + * @return Version for a Data Matrix Code of those dimensions * @throws FormatException if dimensions do correspond to a valid Data Matrix size */ public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException { diff --git a/core/src/com/google/zxing/datamatrix/detector/Detector.java b/core/src/com/google/zxing/datamatrix/detector/Detector.java index d9fbec563..9b22bf492 100644 --- a/core/src/com/google/zxing/datamatrix/detector/Detector.java +++ b/core/src/com/google/zxing/datamatrix/detector/Detector.java @@ -302,7 +302,7 @@ public final class Detector { } private boolean isValid(ResultPoint p) { - return (p.getX() >= 0 && p.getX() < image.width && p.getY() > 0 && p.getY() < image.height); + return p.getX() >= 0 && p.getX() < image.width && p.getY() > 0 && p.getY() < image.height; } /** diff --git a/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java b/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java index 0eb8ea10b..1162324e2 100644 --- a/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java +++ b/core/src/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java @@ -157,7 +157,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder { // Compare the expected module sizes; if they are really off, skip float vModSize12 = (p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()) / - (Math.min(p1.getEstimatedModuleSize(), p2.getEstimatedModuleSize())); + Math.min(p1.getEstimatedModuleSize(), p2.getEstimatedModuleSize()); float vModSize12A = Math.abs(p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()); if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) { // break, since elements are ordered by the module size deviation there cannot be @@ -173,7 +173,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder { // Compare the expected module sizes; if they are really off, skip float vModSize23 = (p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()) / - (Math.min(p2.getEstimatedModuleSize(), p3.getEstimatedModuleSize())); + Math.min(p2.getEstimatedModuleSize(), p3.getEstimatedModuleSize()); float vModSize23A = Math.abs(p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()); if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) { // break, since elements are ordered by the module size deviation there cannot be @@ -191,14 +191,14 @@ final class MultiFinderPatternFinder extends FinderPatternFinder { float dB = ResultPoint.distance(info.getTopLeft(), info.getTopRight()); // Check the sizes - float estimatedModuleCount = ((dA + dB) / p1.getEstimatedModuleSize()) / 2; + float estimatedModuleCount = (dA + dB) / (p1.getEstimatedModuleSize() * 2.0f); if (estimatedModuleCount > MAX_MODULE_COUNT_PER_EDGE || estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) { continue; } // Calculate the difference of the edge lengths in percent - float vABBC = Math.abs(((dA - dB) / Math.min(dA, dB))); + float vABBC = Math.abs((dA - dB) / Math.min(dA, dB)); if (vABBC >= 0.1f) { continue; } @@ -206,7 +206,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder { // Calculate the diagonal length by assuming a 90° angle at topleft float dCpy = (float) Math.sqrt(dA * dA + dB * dB); // Compare to the real distance in % - float vPyC = Math.abs(((dC - dCpy) / Math.min(dC, dCpy))); + float vPyC = Math.abs((dC - dCpy) / Math.min(dC, dCpy)); if (vPyC >= 0.1f) { continue; diff --git a/core/src/com/google/zxing/oned/CodaBarReader.java b/core/src/com/google/zxing/oned/CodaBarReader.java index 652d104ab..3a311ef0b 100644 --- a/core/src/com/google/zxing/oned/CodaBarReader.java +++ b/core/src/com/google/zxing/oned/CodaBarReader.java @@ -105,7 +105,7 @@ public final class CodaBarReader extends OneDReader { int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize; // If 50% of last pattern size, following last pattern, is not whitespace, fail // (but if it's whitespace to the very end of the image, that's OK) - if ((nextStart) != end && (whiteSpaceAfterEnd / 2 < lastPatternSize)) { + if (nextStart != end && (whiteSpaceAfterEnd / 2 < lastPatternSize)) { throw NotFoundException.getNotFoundInstance(); } diff --git a/core/src/com/google/zxing/oned/Code39Writer.java b/core/src/com/google/zxing/oned/Code39Writer.java index dc9cc243b..fa82b3e1e 100644 --- a/core/src/com/google/zxing/oned/Code39Writer.java +++ b/core/src/com/google/zxing/oned/Code39Writer.java @@ -75,7 +75,7 @@ public final class Code39Writer extends UPCEANWriter { private static void toIntArray(int a, int[] toReturn) { for (int i = 0; i < 9; i++) { int temp = a & (1 << i); - toReturn[i] = (temp == 0) ? 1 : 2; + toReturn[i] = temp == 0 ? 1 : 2; } } diff --git a/core/src/com/google/zxing/oned/rss/RSS14Reader.java b/core/src/com/google/zxing/oned/rss/RSS14Reader.java index 17de4b7da..9570cbb92 100644 --- a/core/src/com/google/zxing/oned/rss/RSS14Reader.java +++ b/core/src/com/google/zxing/oned/rss/RSS14Reader.java @@ -122,7 +122,7 @@ public final class RSS14Reader extends AbstractRSSReader { int checkDigit = 0; for (int i = 0; i < 13; i++) { int digit = buffer.charAt(i) - '0'; - checkDigit += (((i & 0x01) == 0) ? 3 * digit : digit); + checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; } checkDigit = 10 - (checkDigit % 10); if (checkDigit == 10) { diff --git a/core/src/com/google/zxing/oned/rss/RSSUtils.java b/core/src/com/google/zxing/oned/rss/RSSUtils.java index 6977fc2f5..b5651090b 100644 --- a/core/src/com/google/zxing/oned/rss/RSSUtils.java +++ b/core/src/com/google/zxing/oned/rss/RSSUtils.java @@ -95,11 +95,12 @@ public final class RSSUtils { } n -= elmWidth; } - return (val); + return val; } static int combins(int n, int r) { - int maxDenom, minDenom; + int maxDenom; + int minDenom; if (n - r > r) { minDenom = r; maxDenom = n - r; @@ -120,7 +121,7 @@ public final class RSSUtils { val /= j; j++; } - return (val); + return val; } static int[] elements(int[] eDist, int N, int K) { diff --git a/core/src/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java b/core/src/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java index 336046cf3..a88c404b1 100644 --- a/core/src/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java +++ b/core/src/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java @@ -41,7 +41,7 @@ final class BitArrayBuilder { static BitArray buildBitArray(Vector pairs) { int charNumber = (pairs.size() << 1) - 1; - if ((((ExpandedPair)pairs.lastElement()).getRightChar()) == null) { + if (((ExpandedPair) pairs.lastElement()).getRightChar() == null) { charNumber -= 1; } diff --git a/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java b/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java index 7287f5c67..1e4069a4f 100644 --- a/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java +++ b/core/src/com/google/zxing/oned/rss/expanded/RSSExpandedReader.java @@ -279,7 +279,7 @@ public final class RSSExpandedReader extends AbstractRSSReader{ } else if (previousPairs.isEmpty()) { rowOffset = 0; } else{ - ExpandedPair lastPair = ((ExpandedPair)previousPairs.lastElement()); + ExpandedPair lastPair = (ExpandedPair) previousPairs.lastElement(); rowOffset = lastPair.getFinderPattern().getStartEnd()[1]; } boolean searchingEvenPair = previousPairs.size() % 2 != 0; diff --git a/core/src/com/google/zxing/oned/rss/expanded/decoders/AI01decoder.java b/core/src/com/google/zxing/oned/rss/expanded/decoders/AI01decoder.java index 62f878bba..145747aa8 100644 --- a/core/src/com/google/zxing/oned/rss/expanded/decoders/AI01decoder.java +++ b/core/src/com/google/zxing/oned/rss/expanded/decoders/AI01decoder.java @@ -67,7 +67,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder { int checkDigit = 0; for (int i = 0; i < 13; i++) { int digit = buf.charAt(i + currentPos) - '0'; - checkDigit += (((i & 0x01) == 0) ? 3 * digit : digit); + checkDigit += (i & 0x01) == 0 ? 3 * digit : digit; } checkDigit = 10 - (checkDigit % 10); diff --git a/core/src/com/google/zxing/pdf417/decoder/Decoder.java b/core/src/com/google/zxing/pdf417/decoder/Decoder.java index ece3acd04..10121af59 100644 --- a/core/src/com/google/zxing/pdf417/decoder/Decoder.java +++ b/core/src/com/google/zxing/pdf417/decoder/Decoder.java @@ -127,7 +127,7 @@ public final class Decoder { */ private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws FormatException { if ((erasures != null && erasures.length > numECCodewords / 2 + MAX_ERRORS) || - (numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS)) { + numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS) { // Too many errors or EC Codewords is corrupted throw FormatException.getFormatInstance(); } diff --git a/core/src/com/google/zxing/qrcode/decoder/DataBlock.java b/core/src/com/google/zxing/qrcode/decoder/DataBlock.java index a08b5683e..12959d9c1 100755 --- a/core/src/com/google/zxing/qrcode/decoder/DataBlock.java +++ b/core/src/com/google/zxing/qrcode/decoder/DataBlock.java @@ -41,7 +41,7 @@ final class DataBlock { * @param rawCodewords bytes as read directly from the QR Code * @param version version of the QR Code * @param ecLevel error-correction level of the QR Code - * @return {@link DataBlock}s containing original bytes, "de-interleaved" from representation in the + * @return DataBlocks containing original bytes, "de-interleaved" from representation in the * QR Code */ static DataBlock[] getDataBlocks(byte[] rawCodewords, diff --git a/core/src/com/google/zxing/qrcode/decoder/DataMask.java b/core/src/com/google/zxing/qrcode/decoder/DataMask.java index 31da35edc..d29dbd47f 100755 --- a/core/src/com/google/zxing/qrcode/decoder/DataMask.java +++ b/core/src/com/google/zxing/qrcode/decoder/DataMask.java @@ -70,7 +70,7 @@ abstract class DataMask { /** * @param reference a value between 0 and 7 indicating one of the eight possible * data mask patterns a QR Code may use - * @return {@link DataMask} encapsulating the data mask pattern + * @return DataMask encapsulating the data mask pattern */ static DataMask forReference(int reference) { if (reference < 0 || reference > 7) { diff --git a/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java b/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java index a358034dc..76087ec04 100644 --- a/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java +++ b/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java @@ -139,7 +139,7 @@ final class DecodedBitStreamParser { assembledTwoBytes += 0x0A6A1; } buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF); - buffer[offset + 1] = (byte) ((assembledTwoBytes) & 0xFF); + buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF); offset += 2; count--; } diff --git a/core/src/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java b/core/src/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java index 400611afe..e8d6c2589 100644 --- a/core/src/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java +++ b/core/src/com/google/zxing/qrcode/decoder/ErrorCorrectionLevel.java @@ -73,7 +73,7 @@ public final class ErrorCorrectionLevel { /** * @param bits int containing the two bits encoding a QR Code's error correction level - * @return {@link ErrorCorrectionLevel} representing the encoded error correction level + * @return ErrorCorrectionLevel representing the encoded error correction level */ public static ErrorCorrectionLevel forBits(int bits) { if (bits < 0 || bits >= FOR_BITS.length) { diff --git a/core/src/com/google/zxing/qrcode/decoder/Mode.java b/core/src/com/google/zxing/qrcode/decoder/Mode.java index cdd5b49b9..3c66217d3 100644 --- a/core/src/com/google/zxing/qrcode/decoder/Mode.java +++ b/core/src/com/google/zxing/qrcode/decoder/Mode.java @@ -50,7 +50,7 @@ public final class Mode { /** * @param bits four bits encoding a QR Code data mode - * @return {@link Mode} encoded by these bits + * @return Mode encoded by these bits * @throws IllegalArgumentException if bits do not correspond to a known mode */ public static Mode forBits(int bits) { @@ -84,7 +84,7 @@ public final class Mode { /** * @param version version in question * @return number of bits used, in this QR Code symbol {@link Version}, to encode the - * count of characters that will follow encoded in this {@link Mode} + * count of characters that will follow encoded in this Mode */ public int getCharacterCountBits(Version version) { if (characterCountBitsForVersions == null) { diff --git a/core/src/com/google/zxing/qrcode/decoder/Version.java b/core/src/com/google/zxing/qrcode/decoder/Version.java index 26cc864d6..ba795de42 100755 --- a/core/src/com/google/zxing/qrcode/decoder/Version.java +++ b/core/src/com/google/zxing/qrcode/decoder/Version.java @@ -90,7 +90,7 @@ public final class Version { *

Deduces version information purely from QR Code dimensions.

* * @param dimension dimension in modules - * @return {@link Version} for a QR Code of that dimension + * @return Version for a QR Code of that dimension * @throws FormatException if dimension is not 1 mod 4 */ public static Version getProvisionalVersionForDimension(int dimension) throws FormatException { diff --git a/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java b/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java index c85cd72ec..3aadf284f 100644 --- a/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java +++ b/core/src/com/google/zxing/qrcode/detector/AlignmentPatternFinder.java @@ -94,7 +94,7 @@ final class AlignmentPatternFinder { int[] stateCount = new int[3]; for (int iGen = 0; iGen < height; iGen++) { // Search from middle outwards - int i = middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1)); + int i = middleI + ((iGen & 0x01) == 0 ? (iGen + 1) >> 1 : -((iGen + 1) >> 1)); stateCount[0] = 0; stateCount[1] = 0; stateCount[2] = 0; diff --git a/core/src/com/google/zxing/qrcode/detector/Detector.java b/core/src/com/google/zxing/qrcode/detector/Detector.java index b0eba53d3..f5bd96351 100644 --- a/core/src/com/google/zxing/qrcode/detector/Detector.java +++ b/core/src/com/google/zxing/qrcode/detector/Detector.java @@ -139,11 +139,11 @@ public class Detector { return new DetectorResult(bits, points); } - public PerspectiveTransform createTransform(ResultPoint topLeft, - ResultPoint topRight, - ResultPoint bottomLeft, - ResultPoint alignmentPattern, - int dimension) { + public static PerspectiveTransform createTransform(ResultPoint topLeft, + ResultPoint topRight, + ResultPoint bottomLeft, + ResultPoint alignmentPattern, + int dimension) { float dimMinusThree = (float) dimension - 3.5f; float bottomRightX; float bottomRightY; diff --git a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java index 9968f0098..01b3bde2a 100755 --- a/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java +++ b/core/src/com/google/zxing/qrcode/detector/FinderPatternFinder.java @@ -559,7 +559,7 @@ public class FinderPatternFinder { public int compare(Object center1, Object center2) { float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average); float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average); - return dA < dB ? -1 : (dA == dB ? 0 : 1); + return dA < dB ? -1 : dA == dB ? 0 : 1; } } @@ -575,7 +575,7 @@ public class FinderPatternFinder { if (((FinderPattern) center2).getCount() == ((FinderPattern) center1).getCount()) { float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average); float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average); - return dA < dB ? 1 : (dA == dB ? 0 : -1); + return dA < dB ? 1 : dA == dB ? 0 : -1; } else { return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount(); } diff --git a/core/src/com/google/zxing/qrcode/encoder/Encoder.java b/core/src/com/google/zxing/qrcode/encoder/Encoder.java index 30f67f08c..8796511ab 100644 --- a/core/src/com/google/zxing/qrcode/encoder/Encoder.java +++ b/core/src/com/google/zxing/qrcode/encoder/Encoder.java @@ -281,7 +281,7 @@ public final class Encoder { // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24). int numPaddingBytes = numDataBytes - bits.getSizeInBytes(); for (int i = 0; i < numPaddingBytes; ++i) { - bits.appendBits(((i & 0x01) == 0) ? 0xEC : 0x11, 8); + bits.appendBits((i & 0x01) == 0 ? 0xEC : 0x11, 8); } if (bits.getSize() != capacity) { throw new WriterException("Bits size does not equal capacity"); diff --git a/core/src/com/google/zxing/qrcode/encoder/MaskUtil.java b/core/src/com/google/zxing/qrcode/encoder/MaskUtil.java index c7f3c48ad..61ccf48c1 100644 --- a/core/src/com/google/zxing/qrcode/encoder/MaskUtil.java +++ b/core/src/com/google/zxing/qrcode/encoder/MaskUtil.java @@ -138,7 +138,8 @@ public final class MaskUtil { if (!QRCode.isValidMaskPattern(maskPattern)) { throw new IllegalArgumentException("Invalid mask pattern"); } - int intermediate, temp; + int intermediate; + int temp; switch (maskPattern) { case 0: intermediate = (y + x) & 0x1; @@ -161,11 +162,11 @@ public final class MaskUtil { break; case 6: temp = y * x; - intermediate = (((temp & 0x1) + (temp % 3)) & 0x1); + intermediate = ((temp & 0x1) + (temp % 3)) & 0x1; break; case 7: temp = y * x; - intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1); + intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1; break; default: throw new IllegalArgumentException("Invalid mask pattern: " + maskPattern); diff --git a/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java b/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java index 76bdb1899..3d434e675 100644 --- a/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java +++ b/core/src/com/google/zxing/qrcode/encoder/MatrixUtil.java @@ -365,9 +365,9 @@ public final class MatrixUtil { // Check if "value" is valid. private static boolean isValidValue(int value) { - return (value == -1 || // Empty. + return value == -1 || // Empty. value == 0 || // Light (white). - value == 1); // Dark (black). + value == 1; // Dark (black). } private static void embedTimingPatterns(ByteMatrix matrix) throws WriterException { diff --git a/core/test/src/com/google/zxing/client/result/WifiParsedResultTestCase.java b/core/test/src/com/google/zxing/client/result/WifiParsedResultTestCase.java index 1e426f8da..a81b1a670 100644 --- a/core/test/src/com/google/zxing/client/result/WifiParsedResultTestCase.java +++ b/core/test/src/com/google/zxing/client/result/WifiParsedResultTestCase.java @@ -27,6 +27,8 @@ import org.junit.Test; * @author Vikram Aggarwal */ public final class WifiParsedResultTestCase extends Assert { + + @Test public void testNoPassword() { doTest("WIFI:S:NoPassword;P:;T:;;", "NoPassword", "", ""); doTest("WIFI:S:No Password;P:;T:;;", "No Password", "", ""); diff --git a/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java b/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java index a149f99ad..7555923a7 100644 --- a/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java +++ b/core/test/src/com/google/zxing/common/AbstractBlackBoxTestCase.java @@ -328,8 +328,8 @@ public abstract class AbstractBlackBoxTestCase extends Assert { // to keep it centered at = new AffineTransform(); at.rotate(radians, width / 2.0, height / 2.0); - at.translate(((width - original.getWidth()) / 2.0), - ((height - original.getHeight()) / 2.0)); + at.translate((width - original.getWidth()) / 2.0, + (height - original.getHeight()) / 2.0); op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC); return op.filter(original, null); diff --git a/core/test/src/com/google/zxing/common/BitMatrixTestCase.java b/core/test/src/com/google/zxing/common/BitMatrixTestCase.java index a006ef4b1..0bc0abe3b 100644 --- a/core/test/src/com/google/zxing/common/BitMatrixTestCase.java +++ b/core/test/src/com/google/zxing/common/BitMatrixTestCase.java @@ -120,7 +120,7 @@ public final class BitMatrixTestCase extends Assert { assertEquals(200, array3.getSize()); for (int x = 0; x < 102; x++) { - boolean on = ((x & 0x03) == 0); + boolean on = (x & 0x03) == 0; assertEquals(on, array.get(x)); assertEquals(on, array2.get(x)); assertEquals(on, array3.get(x)); diff --git a/core/test/src/com/google/zxing/oned/rss/expanded/decoders/AbstractDecoderTest.java b/core/test/src/com/google/zxing/oned/rss/expanded/decoders/AbstractDecoderTest.java index 1d8618909..5521d3b4b 100644 --- a/core/test/src/com/google/zxing/oned/rss/expanded/decoders/AbstractDecoderTest.java +++ b/core/test/src/com/google/zxing/oned/rss/expanded/decoders/AbstractDecoderTest.java @@ -66,7 +66,8 @@ public abstract class AbstractDecoderTest extends Assert { protected static final String compressedDate_March_12th_2010 = "....XXXX.X..XX.."; protected static final String compressedDate_End = "X..X.XX........."; - protected void assertCorrectBinaryString(String binaryString, String expectedNumber) throws NotFoundException { + protected static void assertCorrectBinaryString(String binaryString, String expectedNumber) + throws NotFoundException { BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(binaryString); AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary); String result = decoder.parseInformation(); diff --git a/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java b/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java index eab7c17a0..4f8cf1e76 100644 --- a/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java +++ b/core/test/src/com/google/zxing/qrcode/encoder/MatrixUtilTestCase.java @@ -27,7 +27,9 @@ import org.junit.Test; * @author mysen@google.com (Chris Mysen) - ported from C++ */ public final class MatrixUtilTestCase extends Assert { - public void testtoString() { + + @Test + public void testToString() { ByteMatrix array = new ByteMatrix(3, 3); array.set(0, 0, 0); array.set(1, 0, 1); @@ -254,6 +256,7 @@ public final class MatrixUtilTestCase extends Assert { 1, // Version 1 3, // Mask pattern 3 matrix); + assertEquals(expected, matrix.toString()); } @Test diff --git a/javase/src/com/google/zxing/StringsResourceTranslator.java b/javase/src/com/google/zxing/StringsResourceTranslator.java index 3800642e3..0bdfedee1 100644 --- a/javase/src/com/google/zxing/StringsResourceTranslator.java +++ b/javase/src/com/google/zxing/StringsResourceTranslator.java @@ -45,7 +45,7 @@ import java.util.regex.Pattern; * *

Pass the Android client res/ directory as first argument, and optionally message keys * who should be forced to retranslate. - * Usage: StringsResourceTranslator android/res/ [key_1 ...]

+ * Usage: {@code StringsResourceTranslator android/res/ [key_1 ...]}

* * @author Sean Owen */ diff --git a/zxingorg/src/com/google/zxing/web/DecodeServlet.java b/zxingorg/src/com/google/zxing/web/DecodeServlet.java index c8fb05da4..42a603261 100644 --- a/zxingorg/src/com/google/zxing/web/DecodeServlet.java +++ b/zxingorg/src/com/google/zxing/web/DecodeServlet.java @@ -70,6 +70,7 @@ import java.util.Collection; import java.util.Hashtable; import java.util.List; import java.util.Vector; +import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; @@ -112,6 +113,7 @@ public final class DecodeServlet extends HttpServlet { possibleFormats.add(BarcodeFormat.CODABAR); possibleFormats.add(BarcodeFormat.ITF); possibleFormats.add(BarcodeFormat.RSS_14); + possibleFormats.add(BarcodeFormat.RSS_EXPANDED); possibleFormats.add(BarcodeFormat.QR_CODE); possibleFormats.add(BarcodeFormat.DATA_MATRIX); possibleFormats.add(BarcodeFormat.AZTEC); @@ -163,7 +165,9 @@ public final class DecodeServlet extends HttpServlet { try { imageURI = new URI(imageURIString); } catch (URISyntaxException urise) { - log.fine("URI was not valid: " + imageURIString); + if (log.isLoggable(Level.FINE)) { + log.fine("URI was not valid: " + imageURIString); + } response.sendRedirect("badurl.jspx"); return; } @@ -181,7 +185,9 @@ public final class DecodeServlet extends HttpServlet { getResponse = client.execute(getRequest); } catch (IllegalArgumentException iae) { // Thrown if hostname is bad or null - log.fine(iae.toString()); + if (log.isLoggable(Level.FINE)) { + log.fine(iae.toString()); + } getRequest.abort(); response.sendRedirect("badurl.jspx"); return; @@ -191,14 +197,18 @@ public final class DecodeServlet extends HttpServlet { // javax.net.ssl.SSLPeerUnverifiedException, // org.apache.http.NoHttpResponseException, // org.apache.http.client.ClientProtocolException, - log.fine(ioe.toString()); + if (log.isLoggable(Level.FINE)) { + log.fine(ioe.toString()); + } getRequest.abort(); response.sendRedirect("badurl.jspx"); return; } if (getResponse.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK) { - log.fine("Unsuccessful return code: " + getResponse.getStatusLine().getStatusCode()); + if (log.isLoggable(Level.FINE)) { + log.fine("Unsuccessful return code: " + getResponse.getStatusLine().getStatusCode()); + } response.sendRedirect("badurl.jspx"); return; } @@ -257,7 +267,9 @@ public final class DecodeServlet extends HttpServlet { } } } catch (FileUploadException fue) { - log.fine(fue.toString()); + if (log.isLoggable(Level.FINE)) { + log.fine(fue.toString()); + } response.sendRedirect("badimage.jspx"); } @@ -270,17 +282,23 @@ public final class DecodeServlet extends HttpServlet { try { image = ImageIO.read(is); } catch (IOException ioe) { - log.fine(ioe.toString()); + if (log.isLoggable(Level.FINE)) { + log.fine(ioe.toString()); + } // Includes javax.imageio.IIOException response.sendRedirect("badimage.jspx"); return; } catch (CMMException cmme) { - log.fine(cmme.toString()); + if (log.isLoggable(Level.FINE)) { + log.fine(cmme.toString()); + } // Have seen this in logs response.sendRedirect("badimage.jspx"); return; } catch (IllegalArgumentException iae) { - log.fine(iae.toString()); + if (log.isLoggable(Level.FINE)) { + log.fine(iae.toString()); + } // Have seen this in logs for some JPEGs response.sendRedirect("badimage.jspx"); return; @@ -291,7 +309,9 @@ public final class DecodeServlet extends HttpServlet { } if (image.getHeight() <= 1 || image.getWidth() <= 1 || image.getHeight() * image.getWidth() > MAX_PIXELS) { - log.fine("Dimensions too large: " + image.getWidth() + 'x' + image.getHeight()); + if (log.isLoggable(Level.FINE)) { + log.fine("Dimensions too large: " + image.getWidth() + 'x' + image.getHeight()); + } response.sendRedirect("badimage.jspx"); return; }