A bunch of code style related changes

git-svn-id: https://zxing.googlecode.com/svn/trunk@1795 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2011-05-21 03:36:39 +00:00
parent 87887ab18c
commit df65c5b83e
56 changed files with 175 additions and 135 deletions

View file

@ -39,7 +39,7 @@ public final class IntentResult {
} }
/** /**
* @return name of format, like "QR_CODE", "UPC_A". See <code>BarcodeFormat</code> for more format names. * @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names.
*/ */
public String getFormatName() { public String getFormatName() {
return formatName; return formatName;

View file

@ -422,8 +422,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
paint.setStrokeWidth(4.0f); paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[0], points[1]);
} else if (points.length == 4 && } else if (points.length == 4 &&
(rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A)) || (rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A) ||
(rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) { rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) {
// Hacky special case -- draw two lines, for the barcode and metadata // Hacky special case -- draw two lines, for the barcode and metadata
drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[0], points[1]);
drawLine(canvas, paint, points[2], points[3]); 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 intent = new Intent(this, HelpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); 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. // 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); intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page);
startActivity(intent); startActivity(intent);
return true; return true;

View file

@ -18,7 +18,6 @@ package com.google.zxing.client.android.book;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -121,7 +120,7 @@ public final class SearchBookContentsActivity extends Activity {
CookieManager.getInstance().removeExpiredCookie(); CookieManager.getInstance().removeExpiredCookie();
Intent intent = getIntent(); Intent intent = getIntent();
if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) { if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
finish(); finish();
return; return;
} }

View file

@ -106,7 +106,7 @@ public final class CalendarResultHandler extends ResultHandler {
long milliseconds = date.getTime(); long milliseconds = date.getTime();
if (when.length() == 16 && when.charAt(15) == 'Z') { if (when.length() == 16 && when.charAt(15) == 'Z') {
Calendar calendar = new GregorianCalendar(); 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; milliseconds += offset;
} }
ParsedResult.maybeAppend(DateFormat.getDateTimeInstance().format(milliseconds), result); ParsedResult.maybeAppend(DateFormat.getDateTimeInstance().format(milliseconds), result);

View file

@ -247,13 +247,13 @@ public abstract class ResultHandler {
intent.setType(Contacts.People.CONTENT_ITEM_TYPE); intent.setType(Contacts.People.CONTENT_ITEM_TYPE);
putExtra(intent, Contacts.Intents.Insert.NAME, names != null ? names[0] : null); 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); Contents.PHONE_KEYS.length);
for (int x = 0; x < phoneCount; x++) { for (int x = 0; x < phoneCount; x++) {
putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[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++) { for (int x = 0; x < emailCount; x++) {
putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]); putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]);
} }

View file

@ -36,8 +36,9 @@ import android.widget.TextView;
* @author dswitkin@google.com (Daniel Switkin) * @author dswitkin@google.com (Daniel Switkin)
*/ */
public final class BookmarkAdapter extends BaseAdapter { 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) { public BookmarkAdapter(Context context, Cursor cursor) {
this.context = context; this.context = context;

View file

@ -199,7 +199,7 @@ public final class WifiActivity extends Activity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Intent intent = getIntent(); Intent intent = getIntent();
if (intent == null || (!intent.getAction().equals(Intents.WifiConnect.ACTION))) { if (intent == null || !intent.getAction().equals(Intents.WifiConnect.ACTION)) {
finish(); finish();
return; return;
} }
@ -211,11 +211,11 @@ public final class WifiActivity extends Activity {
statusView = (TextView) findViewById(R.id.networkStatus); statusView = (TextView) findViewById(R.id.networkStatus);
NetworkType networkT; NetworkType networkT;
if (networkType.equals("WPA")) { if ("WPA".equals(networkType)) {
networkT = NetworkType.NETWORK_WPA; networkT = NetworkType.NETWORK_WPA;
} else if (networkType.equals("WEP")) { } else if ("WEP".equals(networkType)) {
networkT = NetworkType.NETWORK_WEP; networkT = NetworkType.NETWORK_WEP;
} else if (networkType.equals("nopass")) { } else if ("nopass".equals(networkType)) {
networkT = NetworkType.NETWORK_NOPASS; networkT = NetworkType.NETWORK_NOPASS;
} else { } else {
doError(R.string.wifi_type_incorrect); doError(R.string.wifi_type_incorrect);

View file

@ -73,7 +73,7 @@ final class WifiReceiver extends BroadcastReceiver {
delayKill.run(); delayKill.run();
} }
if (state == NetworkInfo.State.DISCONNECTED){ 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(); parent.gotError();
} }
} }

View file

@ -56,8 +56,6 @@ final class CameraManager {
private int autoFocusMessage; private int autoFocusMessage;
private boolean initialized; private boolean initialized;
private boolean previewing; private boolean previewing;
private int previewFormat;
private String previewFormatString;
private final boolean useOneShotPreviewCallback; private final boolean useOneShotPreviewCallback;
/** /**
@ -263,8 +261,8 @@ final class CameraManager {
Camera.Parameters parameters = camera.getParameters(); Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize(); Camera.Size size = parameters.getPreviewSize();
Log.v(TAG, "Default preview size: " + size.width + ", " + size.height); Log.v(TAG, "Default preview size: " + size.width + ", " + size.height);
previewFormat = parameters.getPreviewFormat(); int previewFormat = parameters.getPreviewFormat();
previewFormatString = parameters.get("preview-format"); String previewFormatString = parameters.get("preview-format");
Log.v(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString); Log.v(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
// Ensure that the camera resolution is a multiple of 8, as the screen may not be. // Ensure that the camera resolution is a multiple of 8, as the screen may not be.

View file

@ -66,6 +66,7 @@ public final class RGBLuminanceSource extends LuminanceSource {
} }
} }
@Override
public byte[] getRow(int y, byte[] row) { public byte[] getRow(int y, byte[] row) {
if (y < 0 || y >= getHeight()) { if (y < 0 || y >= getHeight()) {
throw new IllegalArgumentException("Requested row is outside the image: " + y); 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 // 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. // exactly what the caller is asking for, so give it to them without a copy.
@Override
public byte[] getMatrix() { public byte[] getMatrix() {
return luminances; return luminances;
} }

View file

@ -65,23 +65,22 @@ public final class ZXingTestActivity extends Activity {
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { if (item.getItemId() == ABOUT_ID) {
case ABOUT_ID: int versionCode = 0;
int versionCode = 0; String versionName = "unknown";
String versionName = "unknown"; try {
try { PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0);
PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0); versionCode = info.versionCode;
versionCode = info.versionCode; versionName = info.versionName;
versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) {
} catch (PackageManager.NameNotFoundException e) { }
} AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(
builder.setTitle(getString(R.string.app_name) + " " + versionName + " (" + versionCode + getString(R.string.app_name) + ' ' + versionName + " (" + versionCode + ')');
")"); builder.setMessage(getString(R.string.about_message));
builder.setMessage(getString(R.string.about_message)); builder.setPositiveButton(R.string.ok_button, null);
builder.setPositiveButton(R.string.ok_button, null); builder.show();
builder.show();
break;
} }
return super.onOptionsItemSelected(item); 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); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(title); builder.setTitle(title);
builder.setMessage(message); builder.setMessage(message);

View file

@ -73,7 +73,9 @@ public class ResultPoint {
float oneTwoDistance = distance(patterns[1], patterns[2]); float oneTwoDistance = distance(patterns[1], patterns[2]);
float zeroTwoDistance = distance(patterns[0], 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 // Assume one closest to other two is B; A and C will just be guesses at first
if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) { if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
pointB = patterns[0]; pointB = patterns[0];

View file

@ -147,7 +147,7 @@ public final class Decoder {
code = readCode(correctedBits, startIndex, 8); code = readCode(correctedBits, startIndex, 8);
startIndex += 8; startIndex += 8;
result.append((char)(code)); result.append((char) code);
break; break;
default: default:

View file

@ -152,7 +152,7 @@ public final class Detector {
/** /**
* *
* <p> Gets the aztec code corners from the bull's eye corners and the parameters </p> * <p>Gets the Aztec code corners from the bull's eye corners and the parameters </p>
* *
* @param bullEyeCornerPoints the array of bull's eye corners * @param bullEyeCornerPoints the array of bull's eye corners
* @return the array of aztec code corners * @return the array of aztec code corners
@ -160,7 +160,8 @@ public final class Detector {
*/ */
private ResultPoint[] getMatrixCornerPoints(Point[] bullEyeCornerPoints) throws NotFoundException { 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; int dx = bullEyeCornerPoints[0].x-bullEyeCornerPoints[2].x;
dx+=dx>0?1:-1; dx+=dx>0?1:-1;
@ -609,7 +610,7 @@ public final class Detector {
} }
private boolean isValid(int x, int y) { 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;
} }
/** /**

View file

@ -46,7 +46,7 @@ final class ExpandedProductResultParser extends ResultParser {
// product barcodes with complementary data. // product barcodes with complementary data.
public static ExpandedProductParsedResult parse(Result result) { public static ExpandedProductParsedResult parse(Result result) {
BarcodeFormat format = result.getBarcodeFormat(); BarcodeFormat format = result.getBarcodeFormat();
if (!(BarcodeFormat.RSS_EXPANDED.equals(format))) { if (!BarcodeFormat.RSS_EXPANDED.equals(format)) {
// ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode // ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode
return null; return null;
} }

View file

@ -52,7 +52,9 @@ final class GeoResultParser extends ResultParser {
return null; return null;
} }
int longitudeEnd = geoURIWithoutQuery.indexOf(',', latitudeEnd + 1); int longitudeEnd = geoURIWithoutQuery.indexOf(',', latitudeEnd + 1);
double latitude, longitude, altitude; double latitude;
double longitude;
double altitude;
try { try {
latitude = Double.parseDouble(geoURIWithoutQuery.substring(0, latitudeEnd)); latitude = Double.parseDouble(geoURIWithoutQuery.substring(0, latitudeEnd));
if (latitude > 90.0 || latitude < -90.0) { if (latitude > 90.0 || latitude < -90.0) {

View file

@ -146,26 +146,30 @@ public abstract class ResultParser {
for (int i = first; i < max; i++) { for (int i = first; i < max; i++) {
char c = escapedArray[i]; char c = escapedArray[i];
if (c == '+') { switch (c) {
// + is translated directly into a space case '+':
unescaped.append(' '); // + is translated directly into a space
} else if (c == '%') { unescaped.append(' ');
// Are there even two more chars? if not we will just copy the escaped sequence and be done break;
if (i >= max - 2) { case '%':
unescaped.append('%'); // append that % and move on // Are there even two more chars? if not we will just copy the escaped sequence and be done
} else { if (i >= max - 2) {
int firstDigitValue = parseHexDigit(escapedArray[++i]); unescaped.append('%'); // append that % and move on
int secondDigitValue = parseHexDigit(escapedArray[++i]); } else {
if (firstDigitValue < 0 || secondDigitValue < 0) { int firstDigitValue = parseHexDigit(escapedArray[++i]);
// bad digit, just move on int secondDigitValue = parseHexDigit(escapedArray[++i]);
unescaped.append('%'); if (firstDigitValue < 0 || secondDigitValue < 0) {
unescaped.append(escapedArray[i-1]); // bad digit, just move on
unescaped.append(escapedArray[i]); unescaped.append('%');
unescaped.append(escapedArray[i - 1]);
unescaped.append(escapedArray[i]);
}
unescaped.append((char) ((firstDigitValue << 4) + secondDigitValue));
} }
unescaped.append((char) ((firstDigitValue << 4) + secondDigitValue)); break;
} default:
} else { unescaped.append(c);
unescaped.append(c); break;
} }
} }
return unescaped.toString(); return unescaped.toString();

View file

@ -106,11 +106,11 @@ final class VCardResultParser extends ResultParser {
if (equals >= 0) { if (equals >= 0) {
String key = metadata.substring(0, equals); String key = metadata.substring(0, equals);
String value = metadata.substring(equals+1); String value = metadata.substring(equals+1);
if (key.equalsIgnoreCase("ENCODING")) { if ("ENCODING".equalsIgnoreCase(key)) {
if (value.equalsIgnoreCase("QUOTED-PRINTABLE")) { if ("QUOTED-PRINTABLE".equalsIgnoreCase(value)) {
quotedPrintable = true; quotedPrintable = true;
} }
} else if (key.equalsIgnoreCase("CHARSET")) { } else if ("CHARSET".equalsIgnoreCase(key)) {
quotedPrintableCharset = value; quotedPrintableCharset = value;
} }
} }

View file

@ -53,8 +53,12 @@ final class VEventResultParser extends ResultParser {
longitude = Double.NaN; longitude = Double.NaN;
} else { } else {
int semicolon = geoString.indexOf(';'); int semicolon = geoString.indexOf(';');
latitude = Double.parseDouble(geoString.substring(0, semicolon)); try {
longitude = Double.parseDouble(geoString.substring(semicolon + 1)); latitude = Double.parseDouble(geoString.substring(0, semicolon));
longitude = Double.parseDouble(geoString.substring(semicolon + 1));
} catch (NumberFormatException nfe) {
return null;
}
} }
try { try {

View file

@ -81,7 +81,7 @@ public final class CharacterSetECI extends ECI {
/** /**
* @param value character set ECI value * @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 * unsupported
* @throws IllegalArgumentException if ECI value is invalid * @throws IllegalArgumentException if ECI value is invalid
*/ */
@ -97,7 +97,7 @@ public final class CharacterSetECI extends ECI {
/** /**
* @param name character set ECI encoding name * @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 * but unsupported
*/ */
public static CharacterSetECI getCharacterSetECIByName(String name) { public static CharacterSetECI getCharacterSetECIByName(String name) {

View file

@ -36,7 +36,7 @@ public abstract class ECI {
/** /**
* @param value ECI value * @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 * @throws IllegalArgumentException if ECI value is invalid
*/ */
public static ECI getECIByValue(int value) { public static ECI getECIByValue(int value) {

View file

@ -36,7 +36,7 @@ public abstract class GridSampler {
private static GridSampler gridSampler = new DefaultGridSampler(); 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 * 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 * 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 * 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() { public static GridSampler getInstance() {
return gridSampler; return gridSampler;

View file

@ -102,10 +102,10 @@ public final class HybridBinarizer extends GlobalHistogramBinarizer {
if ((xoffset + 8) >= width) { if ((xoffset + 8) >= width) {
xoffset = width - 8; xoffset = width - 8;
} }
int left = (x > 1) ? x : 2; int left = x > 1 ? x : 2;
left = (left < subWidth - 2) ? left : subWidth - 3; left = left < subWidth - 2 ? left : subWidth - 3;
int top = (y > 1) ? y : 2; int top = y > 1 ? y : 2;
top = (top < subHeight - 2) ? top : subHeight - 3; top = top < subHeight - 2 ? top : subHeight - 3;
int sum = 0; int sum = 0;
for (int z = -2; z <= 2; z++) { for (int z = -2; z <= 2; z++) {
int[] blackRow = blackPoints[top + z]; int[] blackRow = blackPoints[top + z];

View file

@ -132,7 +132,7 @@ public final class StringUtils {
((value >= 0xF0 && value <= 0xFF) || value == 0x80 || value == 0xA0)) { ((value >= 0xF0 && value <= 0xFF) || value == 0x80 || value == 0xA0)) {
canBeShiftJIS = false; 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 // These start double-byte characters in Shift_JIS. Let's see if it's followed by a valid
// second byte. // second byte.
if (lastWasPossibleDoubleByteStart) { if (lastWasPossibleDoubleByteStart) {

View file

@ -177,7 +177,7 @@ public final class ReedSolomonDecoder {
// Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. // 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 // Below is a funny-looking workaround from Steven Parkes
int term = field.multiply(errorLocations[j], xiInverse); 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); denominator = field.multiply(denominator, termPlus1);
} }
} }

View file

@ -40,7 +40,7 @@ final class DataBlock {
* *
* @param rawCodewords bytes as read directly from the Data Matrix Code * @param rawCodewords bytes as read directly from the Data Matrix Code
* @param version version of 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 * Data Matrix Code
*/ */
static DataBlock[] getDataBlocks(byte[] rawCodewords, static DataBlock[] getDataBlocks(byte[] rawCodewords,
@ -95,7 +95,7 @@ final class DataBlock {
int max = result[0].codewords.length; int max = result[0].codewords.length;
for (int i = longerBlocksNumDataCodewords; i < max; i++) { for (int i = longerBlocksNumDataCodewords; i < max; i++) {
for (int j = 0; j < numResultBlocks; j++) { 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++]; result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
} }
} }

View file

@ -93,7 +93,7 @@ public final class Version {
* *
* @param numRows Number of rows in modules * @param numRows Number of rows in modules
* @param numColumns Number of columns 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 * @throws FormatException if dimensions do correspond to a valid Data Matrix size
*/ */
public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException { public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException {

View file

@ -302,7 +302,7 @@ public final class Detector {
} }
private boolean isValid(ResultPoint p) { 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;
} }
/** /**

View file

@ -157,7 +157,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
// Compare the expected module sizes; if they are really off, skip // Compare the expected module sizes; if they are really off, skip
float vModSize12 = (p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()) / 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()); float vModSize12A = Math.abs(p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize());
if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) { if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
// break, since elements are ordered by the module size deviation there cannot be // 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 // Compare the expected module sizes; if they are really off, skip
float vModSize23 = (p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()) / 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()); float vModSize23A = Math.abs(p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize());
if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) { if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
// break, since elements are ordered by the module size deviation there cannot be // 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()); float dB = ResultPoint.distance(info.getTopLeft(), info.getTopRight());
// Check the sizes // 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 || if (estimatedModuleCount > MAX_MODULE_COUNT_PER_EDGE ||
estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) { estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) {
continue; continue;
} }
// Calculate the difference of the edge lengths in percent // 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) { if (vABBC >= 0.1f) {
continue; continue;
} }
@ -206,7 +206,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
// Calculate the diagonal length by assuming a 90° angle at topleft // Calculate the diagonal length by assuming a 90° angle at topleft
float dCpy = (float) Math.sqrt(dA * dA + dB * dB); float dCpy = (float) Math.sqrt(dA * dA + dB * dB);
// Compare to the real distance in % // 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) { if (vPyC >= 0.1f) {
continue; continue;

View file

@ -105,7 +105,7 @@ public final class CodaBarReader extends OneDReader {
int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize; int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize;
// If 50% of last pattern size, following last pattern, is not whitespace, fail // 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) // (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(); throw NotFoundException.getNotFoundInstance();
} }

View file

@ -75,7 +75,7 @@ public final class Code39Writer extends UPCEANWriter {
private static void toIntArray(int a, int[] toReturn) { private static void toIntArray(int a, int[] toReturn) {
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
int temp = a & (1 << i); int temp = a & (1 << i);
toReturn[i] = (temp == 0) ? 1 : 2; toReturn[i] = temp == 0 ? 1 : 2;
} }
} }

View file

@ -122,7 +122,7 @@ public final class RSS14Reader extends AbstractRSSReader {
int checkDigit = 0; int checkDigit = 0;
for (int i = 0; i < 13; i++) { for (int i = 0; i < 13; i++) {
int digit = buffer.charAt(i) - '0'; int digit = buffer.charAt(i) - '0';
checkDigit += (((i & 0x01) == 0) ? 3 * digit : digit); checkDigit += (i & 0x01) == 0 ? 3 * digit : digit;
} }
checkDigit = 10 - (checkDigit % 10); checkDigit = 10 - (checkDigit % 10);
if (checkDigit == 10) { if (checkDigit == 10) {

View file

@ -95,11 +95,12 @@ public final class RSSUtils {
} }
n -= elmWidth; n -= elmWidth;
} }
return (val); return val;
} }
static int combins(int n, int r) { static int combins(int n, int r) {
int maxDenom, minDenom; int maxDenom;
int minDenom;
if (n - r > r) { if (n - r > r) {
minDenom = r; minDenom = r;
maxDenom = n - r; maxDenom = n - r;
@ -120,7 +121,7 @@ public final class RSSUtils {
val /= j; val /= j;
j++; j++;
} }
return (val); return val;
} }
static int[] elements(int[] eDist, int N, int K) { static int[] elements(int[] eDist, int N, int K) {

View file

@ -41,7 +41,7 @@ final class BitArrayBuilder {
static BitArray buildBitArray(Vector pairs) { static BitArray buildBitArray(Vector pairs) {
int charNumber = (pairs.size() << 1) - 1; int charNumber = (pairs.size() << 1) - 1;
if ((((ExpandedPair)pairs.lastElement()).getRightChar()) == null) { if (((ExpandedPair) pairs.lastElement()).getRightChar() == null) {
charNumber -= 1; charNumber -= 1;
} }

View file

@ -279,7 +279,7 @@ public final class RSSExpandedReader extends AbstractRSSReader{
} else if (previousPairs.isEmpty()) { } else if (previousPairs.isEmpty()) {
rowOffset = 0; rowOffset = 0;
} else{ } else{
ExpandedPair lastPair = ((ExpandedPair)previousPairs.lastElement()); ExpandedPair lastPair = (ExpandedPair) previousPairs.lastElement();
rowOffset = lastPair.getFinderPattern().getStartEnd()[1]; rowOffset = lastPair.getFinderPattern().getStartEnd()[1];
} }
boolean searchingEvenPair = previousPairs.size() % 2 != 0; boolean searchingEvenPair = previousPairs.size() % 2 != 0;

View file

@ -67,7 +67,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
int checkDigit = 0; int checkDigit = 0;
for (int i = 0; i < 13; i++) { for (int i = 0; i < 13; i++) {
int digit = buf.charAt(i + currentPos) - '0'; 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); checkDigit = 10 - (checkDigit % 10);

View file

@ -127,7 +127,7 @@ public final class Decoder {
*/ */
private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws FormatException { private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws FormatException {
if ((erasures != null && erasures.length > numECCodewords / 2 + MAX_ERRORS) || 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 // Too many errors or EC Codewords is corrupted
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }

View file

@ -41,7 +41,7 @@ final class DataBlock {
* @param rawCodewords bytes as read directly from the QR Code * @param rawCodewords bytes as read directly from the QR Code
* @param version version of the QR Code * @param version version of the QR Code
* @param ecLevel error-correction level 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 * QR Code
*/ */
static DataBlock[] getDataBlocks(byte[] rawCodewords, static DataBlock[] getDataBlocks(byte[] rawCodewords,

View file

@ -70,7 +70,7 @@ abstract class DataMask {
/** /**
* @param reference a value between 0 and 7 indicating one of the eight possible * @param reference a value between 0 and 7 indicating one of the eight possible
* data mask patterns a QR Code may use * 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) { static DataMask forReference(int reference) {
if (reference < 0 || reference > 7) { if (reference < 0 || reference > 7) {

View file

@ -139,7 +139,7 @@ final class DecodedBitStreamParser {
assembledTwoBytes += 0x0A6A1; assembledTwoBytes += 0x0A6A1;
} }
buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF); buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF);
buffer[offset + 1] = (byte) ((assembledTwoBytes) & 0xFF); buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF);
offset += 2; offset += 2;
count--; count--;
} }

View file

@ -73,7 +73,7 @@ public final class ErrorCorrectionLevel {
/** /**
* @param bits int containing the two bits encoding a QR Code's error correction level * @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) { public static ErrorCorrectionLevel forBits(int bits) {
if (bits < 0 || bits >= FOR_BITS.length) { if (bits < 0 || bits >= FOR_BITS.length) {

View file

@ -50,7 +50,7 @@ public final class Mode {
/** /**
* @param bits four bits encoding a QR Code data 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 * @throws IllegalArgumentException if bits do not correspond to a known mode
*/ */
public static Mode forBits(int bits) { public static Mode forBits(int bits) {
@ -84,7 +84,7 @@ public final class Mode {
/** /**
* @param version version in question * @param version version in question
* @return number of bits used, in this QR Code symbol {@link Version}, to encode the * @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) { public int getCharacterCountBits(Version version) {
if (characterCountBitsForVersions == null) { if (characterCountBitsForVersions == null) {

View file

@ -90,7 +90,7 @@ public final class Version {
* <p>Deduces version information purely from QR Code dimensions.</p> * <p>Deduces version information purely from QR Code dimensions.</p>
* *
* @param dimension dimension in modules * @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 * @throws FormatException if dimension is not 1 mod 4
*/ */
public static Version getProvisionalVersionForDimension(int dimension) throws FormatException { public static Version getProvisionalVersionForDimension(int dimension) throws FormatException {

View file

@ -94,7 +94,7 @@ final class AlignmentPatternFinder {
int[] stateCount = new int[3]; int[] stateCount = new int[3];
for (int iGen = 0; iGen < height; iGen++) { for (int iGen = 0; iGen < height; iGen++) {
// Search from middle outwards // 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[0] = 0;
stateCount[1] = 0; stateCount[1] = 0;
stateCount[2] = 0; stateCount[2] = 0;

View file

@ -139,11 +139,11 @@ public class Detector {
return new DetectorResult(bits, points); return new DetectorResult(bits, points);
} }
public PerspectiveTransform createTransform(ResultPoint topLeft, public static PerspectiveTransform createTransform(ResultPoint topLeft,
ResultPoint topRight, ResultPoint topRight,
ResultPoint bottomLeft, ResultPoint bottomLeft,
ResultPoint alignmentPattern, ResultPoint alignmentPattern,
int dimension) { int dimension) {
float dimMinusThree = (float) dimension - 3.5f; float dimMinusThree = (float) dimension - 3.5f;
float bottomRightX; float bottomRightX;
float bottomRightY; float bottomRightY;

View file

@ -559,7 +559,7 @@ public class FinderPatternFinder {
public int compare(Object center1, Object center2) { public int compare(Object center1, Object center2) {
float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average); float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average);
float dB = Math.abs(((FinderPattern) center1).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()) { if (((FinderPattern) center2).getCount() == ((FinderPattern) center1).getCount()) {
float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average); float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average);
float dB = Math.abs(((FinderPattern) center1).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 { } else {
return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount(); return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount();
} }

View file

@ -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). // 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(); int numPaddingBytes = numDataBytes - bits.getSizeInBytes();
for (int i = 0; i < numPaddingBytes; ++i) { 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) { if (bits.getSize() != capacity) {
throw new WriterException("Bits size does not equal capacity"); throw new WriterException("Bits size does not equal capacity");

View file

@ -138,7 +138,8 @@ public final class MaskUtil {
if (!QRCode.isValidMaskPattern(maskPattern)) { if (!QRCode.isValidMaskPattern(maskPattern)) {
throw new IllegalArgumentException("Invalid mask pattern"); throw new IllegalArgumentException("Invalid mask pattern");
} }
int intermediate, temp; int intermediate;
int temp;
switch (maskPattern) { switch (maskPattern) {
case 0: case 0:
intermediate = (y + x) & 0x1; intermediate = (y + x) & 0x1;
@ -161,11 +162,11 @@ public final class MaskUtil {
break; break;
case 6: case 6:
temp = y * x; temp = y * x;
intermediate = (((temp & 0x1) + (temp % 3)) & 0x1); intermediate = ((temp & 0x1) + (temp % 3)) & 0x1;
break; break;
case 7: case 7:
temp = y * x; temp = y * x;
intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1); intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1;
break; break;
default: default:
throw new IllegalArgumentException("Invalid mask pattern: " + maskPattern); throw new IllegalArgumentException("Invalid mask pattern: " + maskPattern);

View file

@ -365,9 +365,9 @@ public final class MatrixUtil {
// Check if "value" is valid. // Check if "value" is valid.
private static boolean isValidValue(int value) { private static boolean isValidValue(int value) {
return (value == -1 || // Empty. return value == -1 || // Empty.
value == 0 || // Light (white). value == 0 || // Light (white).
value == 1); // Dark (black). value == 1; // Dark (black).
} }
private static void embedTimingPatterns(ByteMatrix matrix) throws WriterException { private static void embedTimingPatterns(ByteMatrix matrix) throws WriterException {

View file

@ -27,6 +27,8 @@ import org.junit.Test;
* @author Vikram Aggarwal * @author Vikram Aggarwal
*/ */
public final class WifiParsedResultTestCase extends Assert { public final class WifiParsedResultTestCase extends Assert {
@Test
public void testNoPassword() { public void testNoPassword() {
doTest("WIFI:S:NoPassword;P:;T:;;", "NoPassword", "", ""); doTest("WIFI:S:NoPassword;P:;T:;;", "NoPassword", "", "");
doTest("WIFI:S:No Password;P:;T:;;", "No Password", "", ""); doTest("WIFI:S:No Password;P:;T:;;", "No Password", "", "");

View file

@ -328,8 +328,8 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
// to keep it centered // to keep it centered
at = new AffineTransform(); at = new AffineTransform();
at.rotate(radians, width / 2.0, height / 2.0); at.rotate(radians, width / 2.0, height / 2.0);
at.translate(((width - original.getWidth()) / 2.0), at.translate((width - original.getWidth()) / 2.0,
((height - original.getHeight()) / 2.0)); (height - original.getHeight()) / 2.0);
op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC); op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
return op.filter(original, null); return op.filter(original, null);

View file

@ -120,7 +120,7 @@ public final class BitMatrixTestCase extends Assert {
assertEquals(200, array3.getSize()); assertEquals(200, array3.getSize());
for (int x = 0; x < 102; x++) { for (int x = 0; x < 102; x++) {
boolean on = ((x & 0x03) == 0); boolean on = (x & 0x03) == 0;
assertEquals(on, array.get(x)); assertEquals(on, array.get(x));
assertEquals(on, array2.get(x)); assertEquals(on, array2.get(x));
assertEquals(on, array3.get(x)); assertEquals(on, array3.get(x));

View file

@ -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_March_12th_2010 = "....XXXX.X..XX..";
protected static final String compressedDate_End = "X..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); BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(binaryString);
AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary); AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary);
String result = decoder.parseInformation(); String result = decoder.parseInformation();

View file

@ -27,7 +27,9 @@ import org.junit.Test;
* @author mysen@google.com (Chris Mysen) - ported from C++ * @author mysen@google.com (Chris Mysen) - ported from C++
*/ */
public final class MatrixUtilTestCase extends Assert { public final class MatrixUtilTestCase extends Assert {
public void testtoString() {
@Test
public void testToString() {
ByteMatrix array = new ByteMatrix(3, 3); ByteMatrix array = new ByteMatrix(3, 3);
array.set(0, 0, 0); array.set(0, 0, 0);
array.set(1, 0, 1); array.set(1, 0, 1);
@ -254,6 +256,7 @@ public final class MatrixUtilTestCase extends Assert {
1, // Version 1 1, // Version 1
3, // Mask pattern 3 3, // Mask pattern 3
matrix); matrix);
assertEquals(expected, matrix.toString());
} }
@Test @Test

View file

@ -45,7 +45,7 @@ import java.util.regex.Pattern;
* *
* <p>Pass the Android client res/ directory as first argument, and optionally message keys * <p>Pass the Android client res/ directory as first argument, and optionally message keys
* who should be forced to retranslate. * who should be forced to retranslate.
* Usage: <code>StringsResourceTranslator android/res/ [key_1 ...]</p> * Usage: {@code StringsResourceTranslator android/res/ [key_1 ...]}</p>
* *
* @author Sean Owen * @author Sean Owen
*/ */

View file

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