Various changes from IJ12.1 inspections

git-svn-id: https://zxing.googlecode.com/svn/trunk@2581 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-03-01 20:01:40 +00:00
parent 4b124b109d
commit b01cff36fa
60 changed files with 103 additions and 106 deletions

View file

@ -221,7 +221,7 @@ public class IntentIntegrator {
setTargetApplications(list); setTargetApplications(list);
} }
public void setTargetApplications(List<String> targetApplications) { public final void setTargetApplications(List<String> targetApplications) {
if (targetApplications.isEmpty()) { if (targetApplications.isEmpty()) {
throw new IllegalArgumentException("No target applications"); throw new IllegalArgumentException("No target applications");
} }
@ -236,14 +236,14 @@ public class IntentIntegrator {
return moreExtras; return moreExtras;
} }
public void addExtra(String key, Object value) { public final void addExtra(String key, Object value) {
moreExtras.put(key, value); moreExtras.put(key, value);
} }
/** /**
* Initiates a scan for all known barcode types. * Initiates a scan for all known barcode types.
*/ */
public AlertDialog initiateScan() { public final AlertDialog initiateScan() {
return initiateScan(ALL_CODE_TYPES); return initiateScan(ALL_CODE_TYPES);
} }
@ -255,7 +255,7 @@ public class IntentIntegrator {
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app * @return the {@link AlertDialog} that was shown to the user prompting them to download the app
* if a prompt was needed, or null otherwise * if a prompt was needed, or null otherwise
*/ */
public AlertDialog initiateScan(Collection<String> desiredBarcodeFormats) { public final AlertDialog initiateScan(Collection<String> desiredBarcodeFormats) {
Intent intentScan = new Intent(BS_PACKAGE + ".SCAN"); Intent intentScan = new Intent(BS_PACKAGE + ".SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT); intentScan.addCategory(Intent.CATEGORY_DEFAULT);
@ -371,7 +371,7 @@ public class IntentIntegrator {
* Defaults to type "TEXT_TYPE". * Defaults to type "TEXT_TYPE".
* @see #shareText(CharSequence, CharSequence) * @see #shareText(CharSequence, CharSequence)
*/ */
public AlertDialog shareText(CharSequence text) { public final AlertDialog shareText(CharSequence text) {
return shareText(text, "TEXT_TYPE"); return shareText(text, "TEXT_TYPE");
} }
@ -384,7 +384,7 @@ public class IntentIntegrator {
* @return the {@link AlertDialog} that was shown to the user prompting them to download the app * @return the {@link AlertDialog} that was shown to the user prompting them to download the app
* if a prompt was needed, or null otherwise * if a prompt was needed, or null otherwise
*/ */
public AlertDialog shareText(CharSequence text, CharSequence type) { public final AlertDialog shareText(CharSequence text, CharSequence type) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.addCategory(Intent.CATEGORY_DEFAULT); intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setAction(BS_PACKAGE + ".ENCODE"); intent.setAction(BS_PACKAGE + ".ENCODE");

View file

@ -131,7 +131,7 @@ public final class CaptureActivityHandler extends Handler {
try { try {
activity.startActivity(intent); activity.startActivity(intent);
} catch (ActivityNotFoundException anfe) { } catch (ActivityNotFoundException ignored) {
Log.w(TAG, "Can't find anything to handle VIEW of URI " + url); Log.w(TAG, "Can't find anything to handle VIEW of URI " + url);
} }
break; break;

View file

@ -23,7 +23,7 @@ package com.google.zxing.client.android.book;
*/ */
final class SearchBookContentsResult { final class SearchBookContentsResult {
private static String query; private static String query = null;
private final String pageId; private final String pageId;
private final String pageNumber; private final String pageNumber;

View file

@ -47,8 +47,8 @@ final class MECARDContactEncoder extends ContactEncoder {
String url, String url,
String note) { String note) {
StringBuilder newContents = new StringBuilder(100); StringBuilder newContents = new StringBuilder(100);
StringBuilder newDisplayContents = new StringBuilder(100);
newContents.append("MECARD:"); newContents.append("MECARD:");
StringBuilder newDisplayContents = new StringBuilder(100);
appendUpToUnique(newContents, newDisplayContents, "N", names, 1, new Formatter() { appendUpToUnique(newContents, newDisplayContents, "N", names, 1, new Formatter() {
@Override @Override
public String format(String source) { public String format(String source) {

View file

@ -181,7 +181,7 @@ final class QRCodeEncoder {
if (bundle == null) { if (bundle == null) {
throw new WriterException("No extras"); throw new WriterException("No extras");
} }
Uri uri = (Uri) bundle.getParcelable(Intent.EXTRA_STREAM); Uri uri = bundle.getParcelable(Intent.EXTRA_STREAM);
if (uri == null) { if (uri == null) {
throw new WriterException("No EXTRA_STREAM"); throw new WriterException("No EXTRA_STREAM");
} }

View file

@ -46,9 +46,9 @@ final class VCardContactEncoder extends ContactEncoder {
String url, String url,
String note) { String note) {
StringBuilder newContents = new StringBuilder(100); StringBuilder newContents = new StringBuilder(100);
StringBuilder newDisplayContents = new StringBuilder(100);
newContents.append("BEGIN:VCARD").append(TERMINATOR); newContents.append("BEGIN:VCARD").append(TERMINATOR);
newContents.append("VERSION:3.0").append(TERMINATOR); newContents.append("VERSION:3.0").append(TERMINATOR);
StringBuilder newDisplayContents = new StringBuilder(100);
appendUpToUnique(newContents, newDisplayContents, "N", names, 1, null); appendUpToUnique(newContents, newDisplayContents, "N", names, 1, null);
append(newContents, newDisplayContents, "ORG", organization); append(newContents, newDisplayContents, "ORG", organization);
appendUpToUnique(newContents, newDisplayContents, "ADR", addresses, 1, null); appendUpToUnique(newContents, newDisplayContents, "ADR", addresses, 1, null);

View file

@ -267,7 +267,6 @@ public final class HistoryManager {
* </ul> * </ul>
*/ */
CharSequence buildHistory() { CharSequence buildHistory() {
StringBuilder historyText = new StringBuilder(1000);
SQLiteOpenHelper helper = new DBHelper(activity); SQLiteOpenHelper helper = new DBHelper(activity);
SQLiteDatabase db = null; SQLiteDatabase db = null;
Cursor cursor = null; Cursor cursor = null;
@ -278,6 +277,7 @@ public final class HistoryManager {
null, null, null, null, null, null, null, null,
DBHelper.TIMESTAMP_COL + " DESC"); DBHelper.TIMESTAMP_COL + " DESC");
StringBuilder historyText = new StringBuilder(1000);
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
historyText.append('"').append(massageHistoryField(cursor.getString(0))).append("\","); historyText.append('"').append(massageHistoryField(cursor.getString(0))).append("\",");

View file

@ -434,7 +434,7 @@ public abstract class ResultHandler {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
try { try {
launchIntent(intent); launchIntent(intent);
} catch (ActivityNotFoundException anfe) { } catch (ActivityNotFoundException ignored) {
Log.w(TAG, "Nothing available to handle " + intent); Log.w(TAG, "Nothing available to handle " + intent);
} }
} }
@ -491,7 +491,7 @@ public abstract class ResultHandler {
final void launchIntent(Intent intent) { final void launchIntent(Intent intent) {
try { try {
rawLaunchIntent(intent); rawLaunchIntent(intent);
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException ignored) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.app_name); builder.setTitle(R.string.app_name);
builder.setMessage(R.string.msg_intent_failed); builder.setMessage(R.string.msg_intent_failed);

View file

@ -65,12 +65,12 @@ public final class SMSResultHandler extends ResultHandler {
@Override @Override
public CharSequence getDisplayContents() { public CharSequence getDisplayContents() {
SMSParsedResult smsResult = (SMSParsedResult) getResult(); SMSParsedResult smsResult = (SMSParsedResult) getResult();
StringBuilder contents = new StringBuilder(50);
String[] rawNumbers = smsResult.getNumbers(); String[] rawNumbers = smsResult.getNumbers();
String[] formattedNumbers = new String[rawNumbers.length]; String[] formattedNumbers = new String[rawNumbers.length];
for (int i = 0; i < rawNumbers.length; i++) { for (int i = 0; i < rawNumbers.length; i++) {
formattedNumbers[i] = PhoneNumberUtils.formatNumber(rawNumbers[i]); formattedNumbers[i] = PhoneNumberUtils.formatNumber(rawNumbers[i]);
} }
StringBuilder contents = new StringBuilder(50);
ParsedResult.maybeAppend(formattedNumbers, contents); ParsedResult.maybeAppend(formattedNumbers, contents);
ParsedResult.maybeAppend(smsResult.getSubject(), contents); ParsedResult.maybeAppend(smsResult.getSubject(), contents);
ParsedResult.maybeAppend(smsResult.getBody(), contents); ParsedResult.maybeAppend(smsResult.getBody(), contents);

View file

@ -45,7 +45,7 @@ final class URIResultInfoRetriever extends SupplementalInfoRetriever {
URI oldURI; URI oldURI;
try { try {
oldURI = new URI(result.getURI()); oldURI = new URI(result.getURI());
} catch (URISyntaxException e) { } catch (URISyntaxException ignored) {
return; return;
} }
URI newURI = HttpHelper.unredirect(oldURI); URI newURI = HttpHelper.unredirect(oldURI);

View file

@ -177,13 +177,12 @@ public final class ShareActivity extends Activity {
return; // Show error? return; // Show error?
} }
ContentResolver resolver = getContentResolver(); ContentResolver resolver = getContentResolver();
Bundle bundle = new Bundle();
Cursor cursor; Cursor cursor;
try { try {
// We're seeing about six reports a week of this exception although I don't understand why. // We're seeing about six reports a week of this exception although I don't understand why.
cursor = resolver.query(contactUri, null, null, null, null); cursor = resolver.query(contactUri, null, null, null, null);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException ignored) {
return; return;
} }
if (cursor == null) { if (cursor == null) {
@ -208,6 +207,7 @@ public final class ShareActivity extends Activity {
} }
// Don't require a name to be present, this contact might be just a phone number. // Don't require a name to be present, this contact might be just a phone number.
Bundle bundle = new Bundle();
if (name != null && name.length() > 0) { if (name != null && name.length() > 0) {
bundle.putString(ContactsContract.Intents.Insert.NAME, massageContactData(name)); bundle.putString(ContactsContract.Intents.Insert.NAME, massageContactData(name));
} }

View file

@ -74,7 +74,7 @@ public final class WifiConfigManager extends AsyncTask<WifiParsedResult,Object,O
NetworkType networkType; NetworkType networkType;
try { try {
networkType = NetworkType.forIntentValue(networkTypeString); networkType = NetworkType.forIntentValue(networkTypeString);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException ignored) {
Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString); Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
return null; return null;
} }

View file

@ -105,7 +105,7 @@ final class BenchmarkThread implements Runnable {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
result = multiFormatReader.decodeWithState(bitmap); result = multiFormatReader.decodeWithState(bitmap);
success = true; success = true;
} catch (ReaderException e) { } catch (ReaderException ignored) {
success = false; success = false;
} }
now = Debug.threadCpuTimeNanos() - now; now = Debug.threadCpuTimeNanos() - now;

View file

@ -84,7 +84,7 @@ public final class ZXingTestActivity extends Activity {
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 ignored) {
versionCode = 0; versionCode = 0;
versionName = "unknown"; versionName = "unknown";
} }

View file

@ -84,6 +84,7 @@ public final class MultiFormatWriter implements Writer {
break; break;
case DATA_MATRIX: case DATA_MATRIX:
writer = new DataMatrixWriter(); writer = new DataMatrixWriter();
break;
case AZTEC: case AZTEC:
writer = new AztecWriter(); writer = new AztecWriter();
break; break;

View file

@ -316,7 +316,7 @@ public final class Decoder {
try { try {
ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(gf); ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(gf);
rsDecoder.decode(dataWords, numECCodewords); rsDecoder.decode(dataWords, numECCodewords);
} catch (ReedSolomonException rse) { } catch (ReedSolomonException ignored) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }

View file

@ -237,7 +237,7 @@ public final class Detector {
try { try {
ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM); ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
rsDecoder.decode(parameterWords, numECCodewords); rsDecoder.decode(parameterWords, numECCodewords);
} catch (ReedSolomonException rse) { } catch (ReedSolomonException ignored) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }

View file

@ -22,7 +22,6 @@ import java.util.Map;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.Writer; import com.google.zxing.Writer;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
public final class AztecWriter implements Writer { public final class AztecWriter implements Writer {
@ -30,14 +29,13 @@ public final class AztecWriter implements Writer {
private static final Charset LATIN_1 = Charset.forName("ISO-8859-1"); private static final Charset LATIN_1 = Charset.forName("ISO-8859-1");
@Override @Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) throws WriterException { public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) {
AztecCode aztec = Encoder.encode(contents.getBytes(LATIN_1), 30); AztecCode aztec = Encoder.encode(contents.getBytes(LATIN_1), 30);
return aztec.getMatrix(); return aztec.getMatrix();
} }
@Override @Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map<EncodeHintType, ?> hints) {
throws WriterException {
return encode(contents, format, width, height); return encode(contents, format, width, height);
} }

View file

@ -138,7 +138,6 @@ public final class Encoder {
* @return Aztec symbol matrix with metadata * @return Aztec symbol matrix with metadata
*/ */
public static AztecCode encode(byte[] data, int minECCPercent) { public static AztecCode encode(byte[] data, int minECCPercent) {
AztecCode aztec = new AztecCode();
// High-level encode // High-level encode
BitArray bits = highLevelEncode(data); BitArray bits = highLevelEncode(data);
@ -266,6 +265,7 @@ public final class Encoder {
} }
} }
AztecCode aztec = new AztecCode();
aztec.setCompact(compact); aztec.setCompact(compact);
aztec.setSize(matrixSize); aztec.setSize(matrixSize);
aztec.setLayers(layers); aztec.setLayers(layers);

View file

@ -151,7 +151,6 @@ public final class ExpandedProductResultParser extends ResultParser {
} }
private static String findAIvalue(int i, String rawText) { private static String findAIvalue(int i, String rawText) {
StringBuilder buf = new StringBuilder();
char c = rawText.charAt(i); char c = rawText.charAt(i);
// First character must be a open parenthesis.If not, ERROR // First character must be a open parenthesis.If not, ERROR
if (c != '(') { if (c != '(') {
@ -160,6 +159,7 @@ public final class ExpandedProductResultParser extends ResultParser {
String rawTextAux = rawText.substring(i + 1); String rawTextAux = rawText.substring(i + 1);
StringBuilder buf = new StringBuilder();
for (int index = 0; index < rawTextAux.length(); index++) { for (int index = 0; index < rawTextAux.length(); index++) {
char currentChar = rawTextAux.charAt(index); char currentChar = rawTextAux.charAt(index);
if (currentChar == ')') { if (currentChar == ')') {

View file

@ -64,7 +64,7 @@ public final class GeoResultParser extends ResultParser {
return null; return null;
} }
} }
} catch (NumberFormatException nfe) { } catch (NumberFormatException ignored) {
return null; return null;
} }
return new GeoParsedResult(latitude, longitude, altitude, query); return new GeoParsedResult(latitude, longitude, altitude, query);

View file

@ -65,7 +65,7 @@ public final class VEventResultParser extends ResultParser {
try { try {
latitude = Double.parseDouble(geoString.substring(0, semicolon)); latitude = Double.parseDouble(geoString.substring(0, semicolon));
longitude = Double.parseDouble(geoString.substring(semicolon + 1)); longitude = Double.parseDouble(geoString.substring(semicolon + 1));
} catch (NumberFormatException nfe) { } catch (NumberFormatException ignored) {
return null; return null;
} }
} }
@ -81,7 +81,7 @@ public final class VEventResultParser extends ResultParser {
description, description,
latitude, latitude,
longitude); longitude);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException ignored) {
return null; return null;
} }
} }

View file

@ -123,7 +123,7 @@ public final class Decoder {
int numECCodewords = codewordBytes.length - numDataCodewords; int numECCodewords = codewordBytes.length - numDataCodewords;
try { try {
rsDecoder.decode(codewordsInts, numECCodewords); rsDecoder.decode(codewordsInts, numECCodewords);
} catch (ReedSolomonException rse) { } catch (ReedSolomonException ignored) {
throw ChecksumException.getChecksumInstance(); throw ChecksumException.getChecksumInstance();
} }
// Copy back into array of bytes -- only need to worry about the bytes that were data // Copy back into array of bytes -- only need to worry about the bytes that were data

View file

@ -111,9 +111,8 @@ class C40Encoder implements Encoder {
} }
if (context.hasMoreCharacters()) { if (context.hasMoreCharacters()) {
context.writeCodeword(HighLevelEncoder.C40_UNLATCH); context.writeCodeword(HighLevelEncoder.C40_UNLATCH);
} else {
//No unlatch
} }
// else no unlatch
context.pos--; context.pos--;
} else if (rest == 0) { } else if (rest == 0) {
while (buffer.length() >= 3) { while (buffer.length() >= 3) {

View file

@ -99,7 +99,7 @@ public final class Decoder {
} }
try { try {
rsDecoder.decode(codewordsInts, ecCodewords / divisor); rsDecoder.decode(codewordsInts, ecCodewords / divisor);
} catch (ReedSolomonException rse) { } catch (ReedSolomonException ignored) {
throw ChecksumException.getChecksumInstance(); throw ChecksumException.getChecksumInstance();
} }
// Copy back into array of bytes -- only need to worry about the bytes that were data // Copy back into array of bytes -- only need to worry about the bytes that were data

View file

@ -76,7 +76,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
Result result; Result result;
try { try {
result = delegate.decode(image, hints); result = delegate.decode(image, hints);
} catch (ReaderException re) { } catch (ReaderException ignored) {
return; return;
} }
boolean alreadyFound = false; boolean alreadyFound = false;

View file

@ -60,7 +60,7 @@ public final class EAN13Writer extends UPCEANWriter {
if (!UPCEANReader.checkStandardUPCEANChecksum(contents)) { if (!UPCEANReader.checkStandardUPCEANChecksum(contents)) {
throw new IllegalArgumentException("Contents do not pass checksum"); throw new IllegalArgumentException("Contents do not pass checksum");
} }
} catch (FormatException fe) { } catch (FormatException ignored) {
throw new IllegalArgumentException("Illegal contents"); throw new IllegalArgumentException("Illegal contents");
} }

View file

@ -30,7 +30,7 @@ import java.util.Map;
* <p>Implements decoding of the ITF format, or Interleaved Two of Five.</p> * <p>Implements decoding of the ITF format, or Interleaved Two of Five.</p>
* *
* <p>This Reader will scan ITF barcodes of certain lengths only. * <p>This Reader will scan ITF barcodes of certain lengths only.
* At the moment it reads length 6, 10, 12, 14, 16, 24, and 44 as these have appeared "in the wild". Not all * At the moment it reads length 6, 8, 10, 12, 14, 16, 18, 20, 24, and 44 as these have appeared "in the wild". Not all
* lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of * lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of
* required checksum function.</p> * required checksum function.</p>
* *

View file

@ -63,7 +63,7 @@ public final class ITFWriter extends OneDimensionalCodeWriter {
int two = Character.digit(contents.charAt(i+1), 10); int two = Character.digit(contents.charAt(i+1), 10);
int[] encoding = new int[18]; int[] encoding = new int[18];
for (int j = 0; j < 5; j++) { for (int j = 0; j < 5; j++) {
encoding[(j << 1)] = ITFReader.PATTERNS[one][j]; encoding[j << 1] = ITFReader.PATTERNS[one][j];
encoding[(j << 1) + 1] = ITFReader.PATTERNS[two][j]; encoding[(j << 1) + 1] = ITFReader.PATTERNS[two][j];
} }
pos += appendPattern(result, pos, encoding, true); pos += appendPattern(result, pos, encoding, true);

View file

@ -75,7 +75,7 @@ public final class MultiFormatUPCEANReader extends OneDReader {
Result result; Result result;
try { try {
result = reader.decodeRow(rowNumber, row, startGuardPattern, hints); result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
} catch (ReaderException re) { } catch (ReaderException ignored) {
continue; continue;
} }
// Special case: a 12-digit code encoded in UPC-A is identical to a "0" // Special case: a 12-digit code encoded in UPC-A is identical to a "0"

View file

@ -133,7 +133,7 @@ public abstract class OneDReader implements Reader {
// Estimate black point for this row and load it: // Estimate black point for this row and load it:
try { try {
row = image.getBlackRow(rowNumber, row); row = image.getBlackRow(rowNumber, row);
} catch (NotFoundException nfe) { } catch (NotFoundException ignored) {
continue; continue;
} }

View file

@ -32,7 +32,7 @@ import java.util.Map;
public abstract class OneDimensionalCodeWriter implements Writer { public abstract class OneDimensionalCodeWriter implements Writer {
@Override @Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) public final BitMatrix encode(String contents, BarcodeFormat format, int width, int height)
throws WriterException { throws WriterException {
return encode(contents, format, width, height, null); return encode(contents, format, width, height, null);
} }

View file

@ -32,7 +32,7 @@ final class UPCEANExtensionSupport {
int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN); int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN);
try { try {
return fiveSupport.decodeRow(rowNumber, row, extensionStartRange); return fiveSupport.decodeRow(rowNumber, row, extensionStartRange);
} catch (ReaderException re) { } catch (ReaderException ignored) {
return twoSupport.decodeRow(rowNumber, row, extensionStartRange); return twoSupport.decodeRow(rowNumber, row, extensionStartRange);
} }
} }

View file

@ -35,12 +35,12 @@ public class DataCharacter {
} }
@Override @Override
public String toString() { public final String toString() {
return value + "(" + checksumPortion + ')'; return value + "(" + checksumPortion + ')';
} }
@Override @Override
public boolean equals(Object o) { public final boolean equals(Object o) {
if(!(o instanceof DataCharacter)) { if(!(o instanceof DataCharacter)) {
return false; return false;
} }
@ -49,7 +49,7 @@ public class DataCharacter {
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return value ^ checksumPortion; return value ^ checksumPortion;
} }

View file

@ -143,11 +143,11 @@ public final class RSS14Reader extends AbstractRSSReader {
} }
private static boolean checkChecksum(Pair leftPair, Pair rightPair) { private static boolean checkChecksum(Pair leftPair, Pair rightPair) {
int leftFPValue = leftPair.getFinderPattern().getValue(); //int leftFPValue = leftPair.getFinderPattern().getValue();
int rightFPValue = rightPair.getFinderPattern().getValue(); //int rightFPValue = rightPair.getFinderPattern().getValue();
if ((leftFPValue == 0 && rightFPValue == 8) || //if ((leftFPValue == 0 && rightFPValue == 8) ||
(leftFPValue == 8 && rightFPValue == 0)) { // (leftFPValue == 8 && rightFPValue == 0)) {
} //}
int checkValue = (leftPair.getChecksumPortion() + 16 * rightPair.getChecksumPortion()) % 79; int checkValue = (leftPair.getChecksumPortion() + 16 * rightPair.getChecksumPortion()) % 79;
int targetCheckValue = int targetCheckValue =
9 * leftPair.getFinderPattern().getValue() + rightPair.getFinderPattern().getValue(); 9 * leftPair.getFinderPattern().getValue() + rightPair.getFinderPattern().getValue();
@ -182,7 +182,7 @@ public final class RSS14Reader extends AbstractRSSReader {
return new Pair(1597 * outside.getValue() + inside.getValue(), return new Pair(1597 * outside.getValue() + inside.getValue(),
outside.getChecksumPortion() + 4 * inside.getChecksumPortion(), outside.getChecksumPortion() + 4 * inside.getChecksumPortion(),
pattern); pattern);
} catch (NotFoundException re) { } catch (NotFoundException ignored) {
return null; return null;
} }
} }

View file

@ -241,7 +241,6 @@ public final class RSSExpandedReader extends AbstractRSSReader {
return checkRows(rs, i + 1); return checkRows(rs, i + 1);
} catch (NotFoundException e) { } catch (NotFoundException e) {
// We failed, try the next candidate // We failed, try the next candidate
continue;
} }
} }
@ -456,7 +455,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
DataCharacter rightChar; DataCharacter rightChar;
try { try {
rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false); rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false);
} catch(NotFoundException nfe) { } catch(NotFoundException ignored) {
rightChar = null; rightChar = null;
} }
boolean mayBeLast = true; boolean mayBeLast = true;
@ -579,7 +578,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
int value; int value;
try { try {
value = parseFinderValue(counters, FINDER_PATTERNS); value = parseFinderValue(counters, FINDER_PATTERNS);
} catch (NotFoundException nfe) { } catch (NotFoundException ignored) {
return null; return null;
} }
return new FinderPattern(value, new int[] {start, end}, start, end, rowNumber); return new FinderPattern(value, new int[] {start, end}, start, end, rowNumber);

View file

@ -46,7 +46,7 @@ public class QRCodeReader implements Reader {
private final Decoder decoder = new Decoder(); private final Decoder decoder = new Decoder();
protected Decoder getDecoder() { protected final Decoder getDecoder() {
return decoder; return decoder;
} }
@ -64,7 +64,7 @@ public class QRCodeReader implements Reader {
} }
@Override @Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) public final Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
throws NotFoundException, ChecksumException, FormatException { throws NotFoundException, ChecksumException, FormatException {
DecoderResult decoderResult; DecoderResult decoderResult;
ResultPoint[] points; ResultPoint[] points;

View file

@ -163,7 +163,7 @@ final class DecodedBitStreamParser {
try { try {
result.append(new String(buffer, StringUtils.GB2312)); result.append(new String(buffer, StringUtils.GB2312));
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException ignored) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }
} }
@ -199,7 +199,7 @@ final class DecodedBitStreamParser {
// Shift_JIS may not be supported in some environments: // Shift_JIS may not be supported in some environments:
try { try {
result.append(new String(buffer, StringUtils.SHIFT_JIS)); result.append(new String(buffer, StringUtils.SHIFT_JIS));
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException ignored) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }
} }
@ -232,7 +232,7 @@ final class DecodedBitStreamParser {
} }
try { try {
result.append(new String(readBytes, encoding)); result.append(new String(readBytes, encoding));
} catch (UnsupportedEncodingException uce) { } catch (UnsupportedEncodingException ignored) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }
byteSegments.add(readBytes); byteSegments.add(readBytes);

View file

@ -133,7 +133,7 @@ public final class Decoder {
int numECCodewords = codewordBytes.length - numDataCodewords; int numECCodewords = codewordBytes.length - numDataCodewords;
try { try {
rsDecoder.decode(codewordsInts, numECCodewords); rsDecoder.decode(codewordsInts, numECCodewords);
} catch (ReedSolomonException rse) { } catch (ReedSolomonException ignored) {
throw ChecksumException.getChecksumInstance(); throw ChecksumException.getChecksumInstance();
} }
// Copy back into array of bytes -- only need to worry about the bytes that were data // Copy back into array of bytes -- only need to worry about the bytes that were data

View file

@ -95,7 +95,7 @@ public final class Version {
} }
try { try {
return getVersionForNumber((dimension - 17) >> 2); return getVersionForNumber((dimension - 17) >> 2);
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException ignored) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }
} }

View file

@ -214,7 +214,7 @@ public final class Encoder {
byte[] bytes; byte[] bytes;
try { try {
bytes = content.getBytes("Shift_JIS"); bytes = content.getBytes("Shift_JIS");
} catch (UnsupportedEncodingException uee) { } catch (UnsupportedEncodingException ignored) {
return false; return false;
} }
int length = bytes.length; int length = bytes.length;

View file

@ -179,7 +179,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
} else { } else {
misreadCounts[x]++; misreadCounts[x]++;
} }
} catch (ReaderException re) { } catch (ReaderException ignored) {
log.fine(String.format("could not read at rotation %f", rotation)); log.fine(String.format("could not read at rotation %f", rotation));
} }
try { try {
@ -188,7 +188,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
} else { } else {
tryHaderMisreadCounts[x]++; tryHaderMisreadCounts[x]++;
} }
} catch (ReaderException re) { } catch (ReaderException ignored) {
log.fine(String.format("could not read at rotation %f w/TH", rotation)); log.fine(String.format("could not read at rotation %f w/TH", rotation));
} }
} }

View file

@ -71,7 +71,7 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
testResults = new ArrayList<TestResult>(); testResults = new ArrayList<TestResult>();
} }
protected void addTest(int falsePositivesAllowed, float rotation) { protected final void addTest(int falsePositivesAllowed, float rotation) {
testResults.add(new TestResult(falsePositivesAllowed, rotation)); testResults.add(new TestResult(falsePositivesAllowed, rotation));
} }

View file

@ -34,12 +34,12 @@ public final class DataMatrixWriterTestCase extends Assert {
@Test @Test
public void testDataMatrixImageWriter() { public void testDataMatrixImageWriter() {
DataMatrixWriter writer = new DataMatrixWriter();
Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class); Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE); hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);
int bigEnough = 64; int bigEnough = 64;
DataMatrixWriter writer = new DataMatrixWriter();
BitMatrix matrix = writer.encode("Hello Google", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints); BitMatrix matrix = writer.encode("Hello Google", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
assertNotNull(matrix); assertNotNull(matrix);
assertTrue(bigEnough >= matrix.getWidth()); assertTrue(bigEnough >= matrix.getWidth());
@ -48,12 +48,12 @@ public final class DataMatrixWriterTestCase extends Assert {
@Test @Test
public void testDataMatrixWriter() { public void testDataMatrixWriter() {
DataMatrixWriter writer = new DataMatrixWriter();
Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class); Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE); hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);
int bigEnough = 14; int bigEnough = 14;
DataMatrixWriter writer = new DataMatrixWriter();
BitMatrix matrix = writer.encode("Hello Me", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints); BitMatrix matrix = writer.encode("Hello Me", BarcodeFormat.DATA_MATRIX, bigEnough, bigEnough, hints);
assertNotNull(matrix); assertNotNull(matrix);
assertEquals(bigEnough, matrix.getWidth()); assertEquals(bigEnough, matrix.getWidth());

View file

@ -223,7 +223,6 @@ public final class RSSExpandedImage2binaryTestCase extends Assert {
} }
private static void assertCorrectImage2binary(String path, String expected) throws IOException, NotFoundException { private static void assertCorrectImage2binary(String path, String expected) throws IOException, NotFoundException {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
File file = new File(path); File file = new File(path);
if (!file.exists()) { if (!file.exists()) {
@ -238,6 +237,7 @@ public final class RSSExpandedImage2binaryTestCase extends Assert {
List<ExpandedPair> pairs; List<ExpandedPair> pairs;
try { try {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
pairs = rssExpandedReader.decodeRow2pairs(rowNumber, row); pairs = rssExpandedReader.decodeRow2pairs(rowNumber, row);
} catch (ReaderException re) { } catch (ReaderException re) {
fail(re.toString()); fail(re.toString());

View file

@ -76,7 +76,6 @@ public final class RSSExpandedImage2resultTestCase extends Assert {
private static void assertCorrectImage2result(String path, ExpandedProductParsedResult expected) private static void assertCorrectImage2result(String path, ExpandedProductParsedResult expected)
throws IOException, NotFoundException { throws IOException, NotFoundException {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
File file = new File(path); File file = new File(path);
if (!file.exists()) { if (!file.exists()) {
@ -91,6 +90,7 @@ public final class RSSExpandedImage2resultTestCase extends Assert {
Result theResult; Result theResult;
try { try {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
theResult = rssExpandedReader.decodeRow(rowNumber, row, null); theResult = rssExpandedReader.decodeRow(rowNumber, row, null);
} catch (ReaderException re) { } catch (ReaderException re) {
fail(re.toString()); fail(re.toString());

View file

@ -266,7 +266,6 @@ public final class RSSExpandedImage2stringTestCase extends Assert {
} }
private static void assertCorrectImage2string(String path, String expected) throws IOException, NotFoundException { private static void assertCorrectImage2string(String path, String expected) throws IOException, NotFoundException {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
File file = new File(path); File file = new File(path);
if (!file.exists()) { if (!file.exists()) {
@ -281,6 +280,7 @@ public final class RSSExpandedImage2stringTestCase extends Assert {
Result result; Result result;
try { try {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
result = rssExpandedReader.decodeRow(rowNumber, row, null); result = rssExpandedReader.decodeRow(rowNumber, row, null);
} catch (ReaderException re) { } catch (ReaderException re) {
fail(re.toString()); fail(re.toString());

View file

@ -52,7 +52,6 @@ public final class RSSExpandedInternalTestCase extends Assert {
@Test @Test
public void testFindFinderPatterns() throws Exception { public void testFindFinderPatterns() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/2.png"; String path = "test/data/blackbox/rssexpanded-1/2.png";
File file = new File(path); File file = new File(path);
@ -67,6 +66,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
BitArray row = binaryMap.getBlackRow(rowNumber, null); BitArray row = binaryMap.getBlackRow(rowNumber, null);
List<ExpandedPair> previousPairs = new ArrayList<ExpandedPair>(); List<ExpandedPair> previousPairs = new ArrayList<ExpandedPair>();
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
previousPairs.add(pair1); previousPairs.add(pair1);
FinderPattern finderPattern = pair1.getFinderPattern(); FinderPattern finderPattern = pair1.getFinderPattern();
@ -96,7 +96,6 @@ public final class RSSExpandedInternalTestCase extends Assert {
@Test @Test
public void testRetrieveNextPairPatterns() throws Exception { public void testRetrieveNextPairPatterns() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.png"; String path = "test/data/blackbox/rssexpanded-1/3.png";
File file = new File(path); File file = new File(path);
@ -111,6 +110,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
BitArray row = binaryMap.getBlackRow(rowNumber, null); BitArray row = binaryMap.getBlackRow(rowNumber, null);
List<ExpandedPair> previousPairs = new ArrayList<ExpandedPair>(); List<ExpandedPair> previousPairs = new ArrayList<ExpandedPair>();
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber); ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
previousPairs.add(pair1); previousPairs.add(pair1);
FinderPattern finderPattern = pair1.getFinderPattern(); FinderPattern finderPattern = pair1.getFinderPattern();
@ -126,7 +126,6 @@ public final class RSSExpandedInternalTestCase extends Assert {
@Test @Test
public void testDecodeCheckCharacter() throws Exception { public void testDecodeCheckCharacter() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.png"; String path = "test/data/blackbox/rssexpanded-1/3.png";
File file = new File(path); File file = new File(path);
@ -143,6 +142,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
int value = 0;// A int value = 0;// A
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2); FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
//{1, 8, 4, 1, 1}; //{1, 8, 4, 1, 1};
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, true); DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, true);
assertEquals(98, dataCharacter.getValue()); assertEquals(98, dataCharacter.getValue());
@ -150,7 +150,6 @@ public final class RSSExpandedInternalTestCase extends Assert {
@Test @Test
public void testDecodeDataCharacter() throws Exception { public void testDecodeDataCharacter() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
String path = "test/data/blackbox/rssexpanded-1/3.png"; String path = "test/data/blackbox/rssexpanded-1/3.png";
File file = new File(path); File file = new File(path);
@ -167,6 +166,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
int value = 0; // A int value = 0; // A
FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2); FinderPattern finderPatternA1 = new FinderPattern(value, startEnd, startEnd[0], startEnd[1], image.getHeight() / 2);
//{1, 8, 4, 1, 1}; //{1, 8, 4, 1, 1};
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, false); DataCharacter dataCharacter = rssExpandedReader.decodeDataCharacter(row, finderPatternA1, true, false);
assertEquals(19, dataCharacter.getValue()); assertEquals(19, dataCharacter.getValue());

View file

@ -41,7 +41,7 @@ final class TestCaseUtil {
private TestCaseUtil() { private TestCaseUtil() {
} }
static BufferedImage getBufferedImage(String path) throws IOException { private static BufferedImage getBufferedImage(String path) throws IOException {
File file = new File(path); File file = new File(path);
if (!file.exists()) { if (!file.exists()) {
// Support running from project root too // Support running from project root too

View file

@ -110,9 +110,9 @@ public final class QRCodeWriterTestCase extends Assert {
BitMatrix goldenResult = createMatrixFromImage(image); BitMatrix goldenResult = createMatrixFromImage(image);
assertNotNull(goldenResult); assertNotNull(goldenResult);
QRCodeWriter writer = new QRCodeWriter();
Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class); Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
hints.put(EncodeHintType.ERROR_CORRECTION, ecLevel); hints.put(EncodeHintType.ERROR_CORRECTION, ecLevel);
QRCodeWriter writer = new QRCodeWriter();
BitMatrix generatedResult = writer.encode(contents, BarcodeFormat.QR_CODE, resolution, BitMatrix generatedResult = writer.encode(contents, BarcodeFormat.QR_CODE, resolution,
resolution, hints); resolution, hints);

View file

@ -455,9 +455,8 @@ public final class EncoderTestCase extends Assert {
} }
{ {
// Invalid data. // Invalid data.
BitArray bits = new BitArray();
try { try {
Encoder.appendAlphanumericBytes("abc", bits); Encoder.appendAlphanumericBytes("abc", new BitArray());
} catch (WriterException we) { } catch (WriterException we) {
// good // good
} }

View file

@ -189,10 +189,10 @@ public final class MatrixUtilTestCase extends Assert {
@Test @Test
public void testEmbedDataBits() throws WriterException { public void testEmbedDataBits() throws WriterException {
// Cells other than basic patterns should be filled with zero. // Cells other than basic patterns should be filled with zero.
BitArray bits = new BitArray();
ByteMatrix matrix = new ByteMatrix(21, 21); ByteMatrix matrix = new ByteMatrix(21, 21);
MatrixUtil.clearMatrix(matrix); MatrixUtil.clearMatrix(matrix);
MatrixUtil.embedBasicPatterns(Version.getVersionForNumber(1), matrix); MatrixUtil.embedBasicPatterns(Version.getVersionForNumber(1), matrix);
BitArray bits = new BitArray();
MatrixUtil.embedDataBits(bits, -1, matrix); MatrixUtil.embedDataBits(bits, -1, matrix);
String expected = String expected =
" 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" + " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" +

View file

@ -221,11 +221,11 @@ public final class StringsResourceTranslator {
} }
private static SortedMap<String,String> readLines(File file) throws IOException { private static SortedMap<String,String> readLines(File file) throws IOException {
SortedMap<String,String> entries = new TreeMap<String,String>();
BufferedReader reader = null; BufferedReader reader = null;
try { try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), UTF8)); reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), UTF8));
String line; String line;
SortedMap<String,String> entries = new TreeMap<String,String>();
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
Matcher m = ENTRY_PATTERN.matcher(line); Matcher m = ENTRY_PATTERN.matcher(line);
if (m.find()) { if (m.find()) {

View file

@ -55,7 +55,6 @@ public final class CommandLineRunner {
} }
Config config = new Config(); Config config = new Config();
Queue<String> inputs = new ConcurrentLinkedQueue<String>();
for (String arg : args) { for (String arg : args) {
if ("--try_harder".equals(arg)) { if ("--try_harder".equals(arg)) {
@ -89,6 +88,7 @@ public final class CommandLineRunner {
} }
config.setHints(buildHints(config)); config.setHints(buildHints(config));
Queue<String> inputs = new ConcurrentLinkedQueue<String>();
for (String arg : args) { for (String arg : args) {
if (!arg.startsWith("--")) { if (!arg.startsWith("--")) {
addArgumentToInputs(arg, config, inputs); addArgumentToInputs(arg, config, inputs);
@ -150,7 +150,6 @@ public final class CommandLineRunner {
// Manually turn on all formats, even those not yet considered production quality. // Manually turn on all formats, even those not yet considered production quality.
private static Map<DecodeHintType,?> buildHints(Config config) { private static Map<DecodeHintType,?> buildHints(Config config) {
Map<DecodeHintType, Object> hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
Collection<BarcodeFormat> vector = new ArrayList<BarcodeFormat>(8); Collection<BarcodeFormat> vector = new ArrayList<BarcodeFormat>(8);
vector.add(BarcodeFormat.UPC_A); vector.add(BarcodeFormat.UPC_A);
vector.add(BarcodeFormat.UPC_E); vector.add(BarcodeFormat.UPC_E);
@ -170,6 +169,7 @@ public final class CommandLineRunner {
vector.add(BarcodeFormat.CODABAR); vector.add(BarcodeFormat.CODABAR);
vector.add(BarcodeFormat.MAXICODE); vector.add(BarcodeFormat.MAXICODE);
} }
Map<DecodeHintType, Object> hints = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);
hints.put(DecodeHintType.POSSIBLE_FORMATS, vector); hints.put(DecodeHintType.POSSIBLE_FORMATS, vector);
if (config.isTryHarder()) { if (config.isTryHarder()) {
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

View file

@ -140,7 +140,7 @@ final class DecodeWorker implements Callable<Integer> {
BufferedImage image; BufferedImage image;
try { try {
image = ImageIO.read(uri.toURL()); image = ImageIO.read(uri.toURL());
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException ignored) {
throw new FileNotFoundException("Resource not found: " + uri); throw new FileNotFoundException("Resource not found: " + uri);
} }
if (image == null) { if (image == null) {
@ -176,7 +176,7 @@ final class DecodeWorker implements Callable<Integer> {
} }
return result; return result;
} catch (NotFoundException nfe) { } catch (NotFoundException ignored) {
System.out.println(uri.toString() + ": No barcode found"); System.out.println(uri.toString() + ": No barcode found");
return null; return null;
} }
@ -186,7 +186,7 @@ final class DecodeWorker implements Callable<Integer> {
BufferedImage image; BufferedImage image;
try { try {
image = ImageIO.read(uri.toURL()); image = ImageIO.read(uri.toURL());
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException ignored) {
throw new FileNotFoundException("Resource not found: " + uri); throw new FileNotFoundException("Resource not found: " + uri);
} }
if (image == null) { if (image == null) {
@ -229,7 +229,7 @@ final class DecodeWorker implements Callable<Integer> {
} }
} }
return results; return results;
} catch (NotFoundException nfe) { } catch (NotFoundException ignored) {
System.out.println(uri.toString() + ": No barcode found"); System.out.println(uri.toString() + ": No barcode found");
return null; return null;
} }
@ -296,7 +296,8 @@ final class DecodeWorker implements Callable<Integer> {
} }
} }
} }
} catch (NotFoundException nfe) { } catch (NotFoundException ignored) {
// continue
} }
writeResultImage(stride, height, pixels, uri, inputName, ".mono.png"); writeResultImage(stride, height, pixels, uri, inputName, ".mono.png");
@ -331,9 +332,9 @@ final class DecodeWorker implements Callable<Integer> {
if (!ImageIO.write(result, "png", outStream)) { if (!ImageIO.write(result, "png", outStream)) {
System.err.println("Could not encode an image to " + resultName); System.err.println("Could not encode an image to " + resultName);
} }
} catch (FileNotFoundException e) { } catch (FileNotFoundException ignored) {
System.err.println("Could not create " + resultName); System.err.println("Could not create " + resultName);
} catch (IOException e) { } catch (IOException ignored) {
System.err.println("Could not write to " + resultName); System.err.println("Could not write to " + resultName);
} finally { } finally {
try { try {

View file

@ -63,17 +63,17 @@ public final class Generator implements EntryPoint {
public void onModuleLoad() { public void onModuleLoad() {
loadGenerators(); loadGenerators();
HorizontalPanel mainPanel = new HorizontalPanel();
setupLeftPanel(); setupLeftPanel();
topPanel.getElement().setId("leftpanel"); topPanel.getElement().setId("leftpanel");
Widget leftPanel = topPanel; Widget leftPanel = topPanel;
HorizontalPanel mainPanel = new HorizontalPanel();
mainPanel.add(leftPanel); mainPanel.add(leftPanel);
SimplePanel div = new SimplePanel();
SimplePanel div2 = new SimplePanel(); SimplePanel div2 = new SimplePanel();
div2.add(result); div2.add(result);
div2.getElement().setId("innerresult"); div2.getElement().setId("innerresult");
SimplePanel div = new SimplePanel();
div.add(div2); div.add(div2);
div.getElement().setId("imageresult"); div.getElement().setId("imageresult");

View file

@ -12,12 +12,12 @@
<h1>Zebra Crossing <span>from the ZXing Project</span></h1> <h1>Zebra Crossing <span>from the ZXing Project</span></h1>
</div> </div>
<table width="600" cellpadding="4" cellspacing="8"> <table style="width:600px">
<tr> <tr>
<td valign="top"> <td style="vertical-align:top;padding:4px;margin:8px">
<img src="/zxingicon.png" width="128" height="128"/> <img src="/zxingicon.png" width="128" height="128" alt="ZXing"/>
</td> </td>
<td valign="top"> <td style="vertical-align:top;padding:4px;margin:8px">
<p>Welcome to the Zebra Crossing site at zxing.appspot.com.</p> <p>Welcome to the Zebra Crossing site at zxing.appspot.com.</p>
<p> This site features a <a href="/generator">QR Code Generator</a>, which <p> This site features a <a href="/generator">QR Code Generator</a>, which
allows you to create a two-dimensional barcode that can be scanned allows you to create a two-dimensional barcode that can be scanned

View file

@ -12,12 +12,12 @@
<h1>Zebra Crossing <span>from the ZXing Project</span></h1> <h1>Zebra Crossing <span>from the ZXing Project</span></h1>
</div> </div>
<table cellpadding="4" cellspacing="8"> <table>
<tr> <tr>
<td valign="top"> <td style="vertical-align:top;padding:4px;margin:8px">
<img src="/zxingiconsmall.png" width="48" height="48"/> <img src="/zxingiconsmall.png" width="48" height="48" alt="ZXing"/>
</td> </td>
<td valign="top"> <td style="vertical-align:top;padding:4px;margin:8px">
<p>A web page you are viewing would like to scan a barcode with your camera phone. To do <p>A web page you are viewing would like to scan a barcode with your camera phone. To do
this, you need to install a new application.</p> this, you need to install a new application.</p>
<p>If you are using an Android device, <p>If you are using an Android device,
@ -44,7 +44,7 @@
tail = query.indexOf ( "&" , head ); tail = query.indexOf ( "&" , head );
if (tail < 0) if (tail < 0)
tail = query.length; tail = query.length;
return unescape(query.substring(head, tail)); return decodeURIComponent(query.substring(head, tail));
} }
function process(form) { function process(form) {
if (window.ret == null) if (window.ret == null)

View file

@ -122,11 +122,11 @@ public final class DecodeServlet extends HttpServlet {
URL imageURL; URL imageURL;
try { try {
imageURL = new URI(imageURIString).toURL(); imageURL = new URI(imageURIString).toURL();
} catch (URISyntaxException urise) { } catch (URISyntaxException ignored) {
log.info("URI was not valid: " + imageURIString); log.info("URI was not valid: " + imageURIString);
response.sendRedirect("badurl.jspx"); response.sendRedirect("badurl.jspx");
return; return;
} catch (MalformedURLException mue) { } catch (MalformedURLException ignored) {
log.info("URI was not valid: " + imageURIString); log.info("URI was not valid: " + imageURIString);
response.sendRedirect("badurl.jspx"); response.sendRedirect("badurl.jspx");
return; return;
@ -135,7 +135,7 @@ public final class DecodeServlet extends HttpServlet {
HttpURLConnection connection; HttpURLConnection connection;
try { try {
connection = (HttpURLConnection) imageURL.openConnection(); connection = (HttpURLConnection) imageURL.openConnection();
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException ignored) {
log.info("URI could not be opened: " + imageURL); log.info("URI could not be opened: " + imageURL);
response.sendRedirect("badurl.jspx"); response.sendRedirect("badurl.jspx");
return; return;

View file

@ -18,7 +18,7 @@
<jsp:directive.page session="false"/> <jsp:directive.page session="false"/>
<script type="text/javascript"> <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); document.write(decodeURIComponent("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
var pageTracker = _gat._getTracker("UA-788492-5"); var pageTracker = _gat._getTracker("UA-788492-5");