Type weakening and dead code commenting again

git-svn-id: https://zxing.googlecode.com/svn/trunk@2876 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-08-26 17:27:54 +00:00
parent e23507a825
commit 1d086a09af
64 changed files with 324 additions and 309 deletions

View file

@ -67,7 +67,6 @@ import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* This activity opens the camera and does the actual scanning on a background thread. It draws a * This activity opens the camera and does the actual scanning on a background thread. It draws a
@ -84,13 +83,11 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
private static final long DEFAULT_INTENT_RESULT_DURATION_MS = 1500L; private static final long DEFAULT_INTENT_RESULT_DURATION_MS = 1500L;
private static final long BULK_MODE_SCAN_DELAY_MS = 1000L; private static final long BULK_MODE_SCAN_DELAY_MS = 1000L;
private static final String PRODUCT_SEARCH_URL_PREFIX = "http://www.google";
private static final String PRODUCT_SEARCH_URL_SUFFIX = "/m/products/scan";
private static final String[] ZXING_URLS = { "http://zxing.appspot.com/scan", "zxing://scan/" }; private static final String[] ZXING_URLS = { "http://zxing.appspot.com/scan", "zxing://scan/" };
public static final int HISTORY_REQUEST_CODE = 0x0000bacc; public static final int HISTORY_REQUEST_CODE = 0x0000bacc;
private static final Set<ResultMetadataType> DISPLAYABLE_METADATA_TYPES = private static final Collection<ResultMetadataType> DISPLAYABLE_METADATA_TYPES =
EnumSet.of(ResultMetadataType.ISSUE_NUMBER, EnumSet.of(ResultMetadataType.ISSUE_NUMBER,
ResultMetadataType.SUGGESTED_PRICE, ResultMetadataType.SUGGESTED_PRICE,
ResultMetadataType.ERROR_CORRECTION_LEVEL, ResultMetadataType.ERROR_CORRECTION_LEVEL,
@ -220,8 +217,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
} }
} else if (dataString != null && } else if (dataString != null &&
dataString.contains(PRODUCT_SEARCH_URL_PREFIX) && dataString.contains("http://www.google") &&
dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) { dataString.contains("/m/products/scan")) {
// Scan only products and send the result to mobile Product Search. // Scan only products and send the result to mobile Product Search.
source = IntentSource.PRODUCT_SEARCH_LINK; source = IntentSource.PRODUCT_SEARCH_LINK;
@ -430,9 +427,9 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
case NONE: case NONE:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (fromLiveScan && prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) { if (fromLiveScan && prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) {
String message = getResources().getString(R.string.msg_bulk_mode_scanned) Toast.makeText(getApplicationContext(),
+ " (" + rawResult.getText() + ')'; getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')',
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
// Wait a moment or else it will scan the same barcode continuously about 3 times // Wait a moment or else it will scan the same barcode continuously about 3 times
restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS); restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
} else { } else {
@ -506,9 +503,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
typeTextView.setText(resultHandler.getType().toString()); typeTextView.setText(resultHandler.getType().toString());
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
TextView timeTextView = (TextView) findViewById(R.id.time_text_view); TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
timeTextView.setText(formattedTime); timeTextView.setText(formatter.format(new Date(rawResult.getTimestamp())));
TextView metaTextView = (TextView) findViewById(R.id.meta_text_view); TextView metaTextView = (TextView) findViewById(R.id.meta_text_view);
@ -630,7 +626,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION, intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString()); metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
} }
Integer orientation = (Integer) metadata.get(ResultMetadataType.ORIENTATION); Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
if (orientation != null) { if (orientation != null) {
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue()); intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
} }

View file

@ -52,8 +52,8 @@ final class DecodeFormatManager {
private DecodeFormatManager() {} private DecodeFormatManager() {}
static Collection<BarcodeFormat> parseDecodeFormats(Intent intent) { static Collection<BarcodeFormat> parseDecodeFormats(Intent intent) {
List<String> scanFormats = null; Iterable<String> scanFormats = null;
String scanFormatsString = intent.getStringExtra(Intents.Scan.FORMATS); CharSequence scanFormatsString = intent.getStringExtra(Intents.Scan.FORMATS);
if (scanFormatsString != null) { if (scanFormatsString != null) {
scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString)); scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString));
} }

View file

@ -40,7 +40,7 @@ final class InactivityTimer {
private final Activity activity; private final Activity activity;
private final AsyncTaskExecInterface taskExec; private final AsyncTaskExecInterface taskExec;
private final BroadcastReceiver powerStatusReceiver; private final BroadcastReceiver powerStatusReceiver;
private InactivityAsyncTask inactivityTask; private AsyncTask<?,?,?> inactivityTask;
InactivityTimer(Activity activity) { InactivityTimer(Activity activity) {
this.activity = activity; this.activity = activity;

View file

@ -21,7 +21,7 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen; import android.preference.PreferenceGroup;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -62,7 +62,7 @@ public final class PreferencesActivity extends PreferenceActivity
super.onCreate(icicle); super.onCreate(icicle);
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
PreferenceScreen preferences = getPreferenceScreen(); PreferenceGroup preferences = getPreferenceScreen();
preferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(this); preferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
decode1D = (CheckBoxPreference) preferences.findPreference(KEY_DECODE_1D); decode1D = (CheckBoxPreference) preferences.findPreference(KEY_DECODE_1D);
decodeQR = (CheckBoxPreference) preferences.findPreference(KEY_DECODE_QR); decodeQR = (CheckBoxPreference) preferences.findPreference(KEY_DECODE_QR);

View file

@ -31,11 +31,11 @@ import java.net.URLEncoder;
*/ */
final class ScanFromWebPageManager { final class ScanFromWebPageManager {
private static final String CODE_PLACEHOLDER = "{CODE}"; private static final CharSequence CODE_PLACEHOLDER = "{CODE}";
private static final String RAW_CODE_PLACEHOLDER = "{RAWCODE}"; private static final CharSequence RAW_CODE_PLACEHOLDER = "{RAWCODE}";
private static final String META_PLACEHOLDER = "{META}"; private static final CharSequence META_PLACEHOLDER = "{META}";
private static final String FORMAT_PLACEHOLDER = "{FORMAT}"; private static final CharSequence FORMAT_PLACEHOLDER = "{FORMAT}";
private static final String TYPE_PLACEHOLDER = "{TYPE}"; private static final CharSequence TYPE_PLACEHOLDER = "{TYPE}";
private static final String RETURN_URL_PARAM = "ret"; private static final String RETURN_URL_PARAM = "ret";
private static final String RAW_PARAM = "raw"; private static final String RAW_PARAM = "raw";

View file

@ -64,10 +64,10 @@ public final class SearchBookContentsActivity extends Activity {
private String isbn; private String isbn;
private EditText queryTextView; private EditText queryTextView;
private Button queryButton; private View queryButton;
private ListView resultListView; private ListView resultListView;
private TextView headerView; private TextView headerView;
private NetworkTask networkTask; private AsyncTask<String,?,?> networkTask;
private final AsyncTaskExecInterface taskExec; private final AsyncTaskExecInterface taskExec;
public SearchBookContentsActivity() { public SearchBookContentsActivity() {
@ -127,7 +127,7 @@ public final class SearchBookContentsActivity extends Activity {
} }
queryTextView.setOnKeyListener(keyListener); queryTextView.setOnKeyListener(keyListener);
queryButton = (Button) findViewById(R.id.query_button); queryButton = findViewById(R.id.query_button);
queryButton.setOnClickListener(buttonListener); queryButton.setOnClickListener(buttonListener);
resultListView = (ListView) findViewById(R.id.result_list_view); resultListView = (ListView) findViewById(R.id.result_list_view);
@ -145,7 +145,7 @@ public final class SearchBookContentsActivity extends Activity {
@Override @Override
protected void onPause() { protected void onPause() {
NetworkTask oldTask = networkTask; AsyncTask<?,?,?> oldTask = networkTask;
if (oldTask != null) { if (oldTask != null) {
oldTask.cancel(true); oldTask.cancel(true);
networkTask = null; networkTask = null;
@ -156,7 +156,7 @@ public final class SearchBookContentsActivity extends Activity {
private void launchSearch() { private void launchSearch() {
String query = queryTextView.getText().toString(); String query = queryTextView.getText().toString();
if (query != null && !query.isEmpty()) { if (query != null && !query.isEmpty()) {
NetworkTask oldTask = networkTask; AsyncTask<?,?,?> oldTask = networkTask;
if (oldTask != null) { if (oldTask != null) {
oldTask.cancel(true); oldTask.cancel(true);
} }

View file

@ -45,7 +45,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
private boolean active; private boolean active;
private final boolean useAutoFocus; private final boolean useAutoFocus;
private final Camera camera; private final Camera camera;
private AutoFocusTask outstandingTask; private AsyncTask<?,?,?> outstandingTask;
private final AsyncTaskExecInterface taskExec; private final AsyncTaskExecInterface taskExec;
AutoFocusManager(Context context, Camera camera) { AutoFocusManager(Context context, Camera camera) {

View file

@ -16,7 +16,6 @@
package com.google.zxing.client.android.encode; package com.google.zxing.client.android.encode;
import android.provider.ContactsContract;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter; import com.google.zxing.MultiFormatWriter;
@ -30,11 +29,12 @@ import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ResultParser; import com.google.zxing.client.result.ResultParser;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import android.app.Activity; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.ContactsContract;
import android.telephony.PhoneNumberUtils; import android.telephony.PhoneNumberUtils;
import android.util.Log; import android.util.Log;
@ -61,7 +61,7 @@ final class QRCodeEncoder {
private static final int WHITE = 0xFFFFFFFF; private static final int WHITE = 0xFFFFFFFF;
private static final int BLACK = 0xFF000000; private static final int BLACK = 0xFF000000;
private final Activity activity; private final Context activity;
private String contents; private String contents;
private String displayContents; private String displayContents;
private String title; private String title;
@ -69,7 +69,7 @@ final class QRCodeEncoder {
private final int dimension; private final int dimension;
private final boolean useVCard; private final boolean useVCard;
QRCodeEncoder(Activity activity, Intent intent, int dimension, boolean useVCard) throws WriterException { QRCodeEncoder(Context activity, Intent intent, int dimension, boolean useVCard) throws WriterException {
this.activity = activity; this.activity = activity;
this.dimension = dimension; this.dimension = dimension;
this.useVCard = useVCard; this.useVCard = useVCard;
@ -259,7 +259,7 @@ final class QRCodeEncoder {
emails.add(bundle.getString(Contents.EMAIL_KEYS[x])); emails.add(bundle.getString(Contents.EMAIL_KEYS[x]));
} }
String url = bundle.getString(Contents.URL_KEY); String url = bundle.getString(Contents.URL_KEY);
Collection<String> urls = url == null ? null : Collections.singletonList(url); Iterable<String> urls = url == null ? null : Collections.singletonList(url);
String note = bundle.getString(Contents.NOTE_KEY); String note = bundle.getString(Contents.NOTE_KEY);
ContactEncoder mecardEncoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder(); ContactEncoder mecardEncoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();

View file

@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log; import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.Menu; import android.view.Menu;
@ -31,19 +32,18 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import com.google.zxing.client.android.CaptureActivity; import com.google.zxing.client.android.CaptureActivity;
import com.google.zxing.client.android.Intents; import com.google.zxing.client.android.Intents;
import com.google.zxing.client.android.R; import com.google.zxing.client.android.R;
import java.util.List;
public final class HistoryActivity extends ListActivity { public final class HistoryActivity extends ListActivity {
private static final String TAG = HistoryActivity.class.getSimpleName(); private static final String TAG = HistoryActivity.class.getSimpleName();
private HistoryManager historyManager; private HistoryManager historyManager;
private HistoryItemAdapter adapter; private ArrayAdapter<HistoryItem> adapter;
@Override @Override
protected void onCreate(Bundle icicle) { protected void onCreate(Bundle icicle) {
@ -51,7 +51,7 @@ public final class HistoryActivity extends ListActivity {
this.historyManager = new HistoryManager(this); this.historyManager = new HistoryManager(this);
adapter = new HistoryItemAdapter(this); adapter = new HistoryItemAdapter(this);
setListAdapter(adapter); setListAdapter(adapter);
ListView listview = getListView(); View listview = getListView();
registerForContextMenu(listview); registerForContextMenu(listview);
} }
@ -62,7 +62,7 @@ public final class HistoryActivity extends ListActivity {
} }
private void reloadHistoryItems() { private void reloadHistoryItems() {
List<HistoryItem> items = historyManager.buildHistoryItems(); Iterable<HistoryItem> items = historyManager.buildHistoryItems();
adapter.clear(); adapter.clear();
for (HistoryItem item : items) { for (HistoryItem item : items) {
adapter.add(item); adapter.add(item);
@ -114,7 +114,7 @@ public final class HistoryActivity extends ListActivity {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.menu_history_send: case R.id.menu_history_send:
CharSequence history = historyManager.buildHistory(); CharSequence history = historyManager.buildHistory();
Uri historyFile = HistoryManager.saveHistory(history.toString()); Parcelable historyFile = HistoryManager.saveHistory(history.toString());
if (historyFile == null) { if (historyFile == null) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.msg_unmount_usb); builder.setMessage(R.string.msg_unmount_usb);

View file

@ -16,7 +16,7 @@
package com.google.zxing.client.android.history; package com.google.zxing.client.android.history;
import android.app.Activity; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -31,28 +31,28 @@ import java.util.ArrayList;
final class HistoryItemAdapter extends ArrayAdapter<HistoryItem> { final class HistoryItemAdapter extends ArrayAdapter<HistoryItem> {
private final Activity activity; private final Context activity;
HistoryItemAdapter(Activity activity) { HistoryItemAdapter(Context activity) {
super(activity, R.layout.history_list_item, new ArrayList<HistoryItem>()); super(activity, R.layout.history_list_item, new ArrayList<HistoryItem>());
this.activity = activity; this.activity = activity;
} }
@Override @Override
public View getView(int position, View view, ViewGroup viewGroup) { public View getView(int position, View view, ViewGroup viewGroup) {
LinearLayout layout; View layout;
if (view instanceof LinearLayout) { if (view instanceof LinearLayout) {
layout = (LinearLayout) view; layout = view;
} else { } else {
LayoutInflater factory = LayoutInflater.from(activity); LayoutInflater factory = LayoutInflater.from(activity);
layout = (LinearLayout) factory.inflate(R.layout.history_list_item, viewGroup, false); layout = factory.inflate(R.layout.history_list_item, viewGroup, false);
} }
HistoryItem item = getItem(position); HistoryItem item = getItem(position);
Result result = item.getResult(); Result result = item.getResult();
String title; CharSequence title;
String detail; CharSequence detail;
if (result != null) { if (result != null) {
title = result.getText(); title = result.getText();
detail = item.getDisplayAndDetails(); detail = item.getDisplayAndDetails();

View file

@ -30,7 +30,6 @@ import java.io.IOException;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import com.google.zxing.client.android.common.executor.AsyncTaskExecInterface; import com.google.zxing.client.android.common.executor.AsyncTaskExecInterface;
import com.google.zxing.client.android.common.executor.AsyncTaskExecManager; import com.google.zxing.client.android.common.executor.AsyncTaskExecManager;
@ -75,8 +74,8 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
private final WeakReference<TextView> textViewRef; private final WeakReference<TextView> textViewRef;
private final WeakReference<HistoryManager> historyManagerRef; private final WeakReference<HistoryManager> historyManagerRef;
private final List<Spannable> newContents; private final Collection<Spannable> newContents;
private final List<String[]> newHistories; private final Collection<String[]> newHistories;
SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) { SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) {
textViewRef = new WeakReference<TextView>(textView); textViewRef = new WeakReference<TextView>(textView);
@ -99,7 +98,7 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
protected final void onPostExecute(Object arg) { protected final void onPostExecute(Object arg) {
TextView textView = textViewRef.get(); TextView textView = textViewRef.get();
if (textView != null) { if (textView != null) {
for (Spannable content : newContents) { for (CharSequence content : newContents) {
textView.append(content); textView.append(content);
} }
textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setMovementMethod(LinkMovementMethod.getInstance());

View file

@ -18,9 +18,10 @@ package com.google.zxing.client.android.share;
import android.app.ListActivity; import android.app.ListActivity;
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask;
import android.provider.Browser; import android.provider.Browser;
import android.view.View; import android.view.View;
import android.widget.ListAdapter; import android.widget.Adapter;
import android.widget.ListView; import android.widget.ListView;
import com.google.zxing.client.android.common.executor.AsyncTaskExecInterface; import com.google.zxing.client.android.common.executor.AsyncTaskExecInterface;
@ -28,7 +29,7 @@ import com.google.zxing.client.android.common.executor.AsyncTaskExecManager;
public final class AppPickerActivity extends ListActivity { public final class AppPickerActivity extends ListActivity {
private LoadPackagesAsyncTask backgroundTask; private AsyncTask<?,?,?> backgroundTask;
private final AsyncTaskExecInterface taskExec; private final AsyncTaskExecInterface taskExec;
public AppPickerActivity() { public AppPickerActivity() {
@ -44,7 +45,7 @@ public final class AppPickerActivity extends ListActivity {
@Override @Override
protected void onPause() { protected void onPause() {
LoadPackagesAsyncTask task = backgroundTask; AsyncTask<?,?,?> task = backgroundTask;
if (task != null) { if (task != null) {
task.cancel(true); task.cancel(true);
backgroundTask = null; backgroundTask = null;
@ -54,7 +55,7 @@ public final class AppPickerActivity extends ListActivity {
@Override @Override
protected void onListItemClick(ListView l, View view, int position, long id) { protected void onListItemClick(ListView l, View view, int position, long id) {
ListAdapter adapter = getListAdapter(); Adapter adapter = getListAdapter();
if (position >= 0 && position < adapter.getCount()) { if (position >= 0 && position < adapter.getCount()) {
String packageName = ((AppInfo) adapter.getItem(position)).getPackageName(); String packageName = ((AppInfo) adapter.getItem(position)).getPackageName();
Intent intent = new Intent(); Intent intent = new Intent();

View file

@ -62,19 +62,19 @@ final class BookmarkAdapter extends BaseAdapter {
@Override @Override
public View getView(int index, View view, ViewGroup viewGroup) { public View getView(int index, View view, ViewGroup viewGroup) {
LinearLayout layout; View layout;
if (view instanceof LinearLayout) { if (view instanceof LinearLayout) {
layout = (LinearLayout) view; layout = view;
} else { } else {
LayoutInflater factory = LayoutInflater.from(context); LayoutInflater factory = LayoutInflater.from(context);
layout = (LinearLayout) factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false); layout = factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false);
} }
if (!cursor.isClosed()) { if (!cursor.isClosed()) {
cursor.moveToPosition(index); cursor.moveToPosition(index);
String title = cursor.getString(BookmarkPickerActivity.TITLE_COLUMN); CharSequence title = cursor.getString(BookmarkPickerActivity.TITLE_COLUMN);
((TextView) layout.findViewById(R.id.bookmark_title)).setText(title); ((TextView) layout.findViewById(R.id.bookmark_title)).setText(title);
String url = cursor.getString(BookmarkPickerActivity.URL_COLUMN); CharSequence url = cursor.getString(BookmarkPickerActivity.URL_COLUMN);
((TextView) layout.findViewById(R.id.bookmark_url)).setText(url); ((TextView) layout.findViewById(R.id.bookmark_url)).setText(url);
} // Otherwise... just don't update as the object is shutting down } // Otherwise... just don't update as the object is shutting down
return layout; return layout;

View file

@ -18,6 +18,7 @@ package com.google.zxing.client.android.share;
import android.app.ListActivity; import android.app.ListActivity;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -59,8 +60,8 @@ final class LoadPackagesAsyncTask extends AsyncTask<Void,Void,List<AppInfo>> {
protected List<AppInfo> doInBackground(Void... objects) { protected List<AppInfo> doInBackground(Void... objects) {
List<AppInfo> labelsPackages = new ArrayList<AppInfo>(); List<AppInfo> labelsPackages = new ArrayList<AppInfo>();
PackageManager packageManager = activity.getPackageManager(); PackageManager packageManager = activity.getPackageManager();
List<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0); Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (ApplicationInfo appInfo : appInfos) { for (PackageItemInfo appInfo : appInfos) {
String packageName = appInfo.packageName; String packageName = appInfo.packageName;
if (!isHidden(packageName)) { if (!isHidden(packageName)) {
CharSequence label = appInfo.loadLabel(packageManager); CharSequence label = appInfo.loadLabel(packageManager);

View file

@ -51,7 +51,7 @@ public final class ShareActivity extends Activity {
private static final int PICK_CONTACT = 1; private static final int PICK_CONTACT = 1;
private static final int PICK_APP = 2; private static final int PICK_APP = 2;
private Button clipboardButton; private View clipboardButton;
private final Button.OnClickListener contactListener = new Button.OnClickListener() { private final Button.OnClickListener contactListener = new Button.OnClickListener() {
@Override @Override
@ -124,7 +124,7 @@ public final class ShareActivity extends Activity {
findViewById(R.id.share_contact_button).setOnClickListener(contactListener); findViewById(R.id.share_contact_button).setOnClickListener(contactListener);
findViewById(R.id.share_bookmark_button).setOnClickListener(bookmarkListener); findViewById(R.id.share_bookmark_button).setOnClickListener(bookmarkListener);
findViewById(R.id.share_app_button).setOnClickListener(appListener); findViewById(R.id.share_app_button).setOnClickListener(appListener);
clipboardButton = (Button) findViewById(R.id.share_clipboard_button); clipboardButton = findViewById(R.id.share_clipboard_button);
clipboardButton.setOnClickListener(clipboardListener); clipboardButton.setOnClickListener(clipboardListener);
findViewById(R.id.share_text_view).setOnKeyListener(textListener); findViewById(R.id.share_text_view).setOnKeyListener(textListener);
} }

View file

@ -21,7 +21,6 @@ import android.net.wifi.WifiManager;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.google.zxing.client.result.WifiParsedResult; import com.google.zxing.client.result.WifiParsedResult;
@ -170,7 +169,7 @@ public final class WifiConfigManager extends AsyncTask<WifiParsedResult,Object,O
} }
private static Integer findNetworkInExistingConfig(WifiManager wifiManager, String ssid) { private static Integer findNetworkInExistingConfig(WifiManager wifiManager, String ssid) {
List<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks(); Iterable<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
for (WifiConfiguration existingConfig : existingConfigs) { for (WifiConfiguration existingConfig : existingConfigs) {
if (existingConfig.SSID.equals(ssid)) { if (existingConfig.SSID.equals(ssid)) {
return existingConfig.networkId; return existingConfig.networkId;

View file

@ -31,7 +31,7 @@ public final class BenchmarkActivity extends Activity {
private static final String TAG = BenchmarkActivity.class.getSimpleName(); private static final String TAG = BenchmarkActivity.class.getSimpleName();
private static final String PATH = Environment.getExternalStorageDirectory().getPath() + "/zxingbenchmark"; private static final String PATH = Environment.getExternalStorageDirectory().getPath() + "/zxingbenchmark";
private Button runBenchmarkButton; private View runBenchmarkButton;
private TextView textView; private TextView textView;
private Thread benchmarkThread; private Thread benchmarkThread;
@ -81,7 +81,7 @@ public final class BenchmarkActivity extends Activity {
setContentView(R.layout.benchmark); setContentView(R.layout.benchmark);
runBenchmarkButton = (Button) findViewById(R.id.benchmark_run); runBenchmarkButton = findViewById(R.id.benchmark_run);
runBenchmarkButton.setOnClickListener(runBenchmark); runBenchmarkButton.setOnClickListener(runBenchmark);
textView = (TextView) findViewById(R.id.benchmark_help); textView = (TextView) findViewById(R.id.benchmark_help);

View file

@ -268,7 +268,7 @@ public final class ZXingTestActivity extends Activity {
integrator.shareText(data.toString(), type); // data.toString() isn't used integrator.shareText(data.toString(), type); // data.toString() isn't used
} }
private static String getFlattenedParams() { private static CharSequence getFlattenedParams() {
Camera camera = Camera.open(); Camera camera = Camera.open();
if (camera == null) { if (camera == null) {
return null; return null;
@ -307,7 +307,7 @@ public final class ZXingTestActivity extends Activity {
result.append("VERSION.RELEASE=").append(Build.VERSION.RELEASE).append('\n'); result.append("VERSION.RELEASE=").append(Build.VERSION.RELEASE).append('\n');
result.append("VERSION.SDK_INT=").append(Build.VERSION.SDK_INT).append('\n'); result.append("VERSION.SDK_INT=").append(Build.VERSION.SDK_INT).append('\n');
String flattened = getFlattenedParams(); CharSequence flattened = getFlattenedParams();
String[] params = SEMICOLON.split(flattened); String[] params = SEMICOLON.split(flattened);
Arrays.sort(params); Arrays.sort(params);
for (String param : params) { for (String param : params) {

View file

@ -39,7 +39,7 @@ public final class AztecWriter implements Writer {
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) {
String charset = hints == null ? null : (String) hints.get(EncodeHintType.CHARACTER_SET); String charset = hints == null ? null : (String) hints.get(EncodeHintType.CHARACTER_SET);
Number eccPercent = hints == null ? null : (Number) hints.get(EncodeHintType.ERROR_CORRECTION); Number eccPercent = hints == null ? null : (Number) hints.get(EncodeHintType.ERROR_CORRECTION);
Integer layers = hints == null ? null : (Integer)hints.get(EncodeHintType.AZTEC_LAYERS); Number layers = hints == null ? null : (Number) hints.get(EncodeHintType.AZTEC_LAYERS);
return encode(contents, return encode(contents,
format, format,
width, width,

View file

@ -158,7 +158,7 @@ public final class HighLevelEncoder {
* Convert the text represented by this High Level Encoder into a BitArray. * Convert the text represented by this High Level Encoder into a BitArray.
*/ */
public BitArray encode() { public BitArray encode() {
List<State> states = Collections.singletonList(State.INITIAL_STATE); Collection<State> states = Collections.singletonList(State.INITIAL_STATE);
for (int index = 0; index < text.length; index++) { for (int index = 0; index < text.length; index++) {
int pairCode; int pairCode;
int nextChar = index + 1 < text.length ? text[index + 1] : 0; int nextChar = index + 1 < text.length ? text[index + 1] : 0;
@ -202,7 +202,7 @@ public final class HighLevelEncoder {
// We update a set of states for a new character by updating each state // We update a set of states for a new character by updating each state
// for the new character, merging the results, and then removing the // for the new character, merging the results, and then removing the
// non-optimal states. // non-optimal states.
private List<State> updateStateListForChar(Iterable<State> states, int index) { private Collection<State> updateStateListForChar(Iterable<State> states, int index) {
Collection<State> result = new LinkedList<State>(); Collection<State> result = new LinkedList<State>();
for (State state : states) { for (State state : states) {
updateStateForChar(state, index, result); updateStateForChar(state, index, result);
@ -251,7 +251,7 @@ public final class HighLevelEncoder {
} }
} }
private static List<State> updateStateListForPair(Iterable<State> states, int index, int pairCode) { private static Collection<State> updateStateListForPair(Iterable<State> states, int index, int pairCode) {
Collection<State> result = new LinkedList<State>(); Collection<State> result = new LinkedList<State>();
for (State state : states) { for (State state : states) {
updateStateForPair(state, index, pairCode, result); updateStateForPair(state, index, pairCode, result);
@ -283,7 +283,7 @@ public final class HighLevelEncoder {
} }
} }
private static List<State> simplifyStates(Iterable<State> states) { private static Collection<State> simplifyStates(Iterable<State> states) {
List<State> result = new LinkedList<State>(); List<State> result = new LinkedList<State>();
for (State newState : states) { for (State newState : states) {
boolean add = true; boolean add = true;

View file

@ -157,7 +157,7 @@ public final class ExpandedProductResultParser extends ResultParser {
return null; return null;
} }
String rawTextAux = rawText.substring(i + 1); CharSequence rawTextAux = rawText.substring(i + 1);
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
for (int index = 0; index < rawTextAux.length(); index++) { for (int index = 0; index < rawTextAux.length(); index++) {

View file

@ -36,7 +36,7 @@ public final class GeoResultParser extends ResultParser {
@Override @Override
public GeoParsedResult parse(Result result) { public GeoParsedResult parse(Result result) {
String rawText = getMassagedText(result); CharSequence rawText = getMassagedText(result);
Matcher matcher = GEO_URL_PATTERN.matcher(rawText); Matcher matcher = GEO_URL_PATTERN.matcher(rawText);
if (!matcher.matches()) { if (!matcher.matches()) {
return null; return null;

View file

@ -20,7 +20,7 @@ import com.google.zxing.Result;
/** /**
* <p>Parses an "smtp:" URI result, whose format is not standardized but appears to be like: * <p>Parses an "smtp:" URI result, whose format is not standardized but appears to be like:
* {@code smtp(:subject(:body))}.</p> * {@code smtp[:subject[:body]]}.</p>
* *
* <p>See http://code.google.com/p/zxing/issues/detail?id=536</p> * <p>See http://code.google.com/p/zxing/issues/detail?id=536</p>
* *

View file

@ -23,7 +23,7 @@ import java.util.Arrays;
*/ */
public class DefaultPlacement { public class DefaultPlacement {
private final String codewords; private final CharSequence codewords;
private final int numrows; private final int numrows;
private final int numcols; private final int numcols;
private final byte[] bits; private final byte[] bits;
@ -35,7 +35,7 @@ public class DefaultPlacement {
* @param numcols the number of columns * @param numcols the number of columns
* @param numrows the number of rows * @param numrows the number of rows
*/ */
public DefaultPlacement(String codewords, int numcols, int numrows) { public DefaultPlacement(CharSequence codewords, int numcols, int numrows) {
this.codewords = codewords; this.codewords = codewords;
this.numcols = numcols; this.numcols = numcols;
this.numrows = numrows; this.numrows = numrows;

View file

@ -18,7 +18,6 @@ package com.google.zxing.datamatrix.encoder;
import com.google.zxing.Dimension; import com.google.zxing.Dimension;
import java.nio.charset.Charset;
import java.util.Arrays; import java.util.Arrays;
/** /**
@ -112,16 +111,19 @@ public final class HighLevelEncoder {
private HighLevelEncoder() { private HighLevelEncoder() {
} }
/** /*
* Converts the message to a byte array using the default encoding (cp437) as defined by the * Converts the message to a byte array using the default encoding (cp437) as defined by the
* specification * specification
* *
* @param msg the message * @param msg the message
* @return the byte array of the message * @return the byte array of the message
*/ */
/*
public static byte[] getBytesForMessage(String msg) { public static byte[] getBytesForMessage(String msg) {
return msg.getBytes(Charset.forName("cp437")); //See 4.4.3 and annex B of ISO/IEC 15438:2001(E) return msg.getBytes(Charset.forName("cp437")); //See 4.4.3 and annex B of ISO/IEC 15438:2001(E)
} }
*/
private static char randomize253State(char ch, int codewordPosition) { private static char randomize253State(char ch, int codewordPosition) {
int pseudoRandom = ((149 * codewordPosition) % 253) + 1; int pseudoRandom = ((149 * codewordPosition) % 253) + 1;

View file

@ -78,8 +78,8 @@ public class SymbolInfo {
public final int matrixWidth; public final int matrixWidth;
public final int matrixHeight; public final int matrixHeight;
private final int dataRegions; private final int dataRegions;
private int rsBlockData; private final int rsBlockData;
private int rsBlockError; private final int rsBlockError;
public SymbolInfo(boolean rectangular, int dataCapacity, int errorCodewords, public SymbolInfo(boolean rectangular, int dataCapacity, int errorCodewords,
int matrixWidth, int matrixHeight, int dataRegions) { int matrixWidth, int matrixHeight, int dataRegions) {
@ -210,11 +210,11 @@ public class SymbolInfo {
return dataCapacity / rsBlockData; return dataCapacity / rsBlockData;
} }
public int getDataCapacity() { public final int getDataCapacity() {
return dataCapacity; return dataCapacity;
} }
public int getErrorCodewords() { public final int getErrorCodewords() {
return errorCodewords; return errorCodewords;
} }

View file

@ -43,9 +43,11 @@ public final class MaxiCodeReader implements Reader {
private final Decoder decoder = new Decoder(); private final Decoder decoder = new Decoder();
/*
Decoder getDecoder() { Decoder getDecoder() {
return decoder; return decoder;
} }
*/
/** /**
* Locates and decodes a MaxiCode in an image. * Locates and decodes a MaxiCode in an image.

View file

@ -238,7 +238,7 @@ public final class CodaBarReader extends OneDReader {
} }
boolean isWhite = true; boolean isWhite = true;
int count = 0; int count = 0;
for (; i < end; i++) { while (i < end) {
if (row.get(i) ^ isWhite) { // that is, exactly one is true if (row.get(i) ^ isWhite) { // that is, exactly one is true
count++; count++;
} else { } else {
@ -246,6 +246,7 @@ public final class CodaBarReader extends OneDReader {
count = 1; count = 1;
isWhite = !isWhite; isWhite = !isWhite;
} }
i++;
} }
counterAppend(count); counterAppend(count);
} }

View file

@ -21,6 +21,7 @@ public final class RSSUtils {
private RSSUtils() {} private RSSUtils() {}
/*
static int[] getRSSwidths(int val, int n, int elements, int maxWidth, boolean noNarrow) { static int[] getRSSwidths(int val, int n, int elements, int maxWidth, boolean noNarrow) {
int[] widths = new int[elements]; int[] widths = new int[elements];
int bar; int bar;
@ -60,6 +61,7 @@ public final class RSSUtils {
widths[bar] = n; widths[bar] = n;
return widths; return widths;
} }
*/
public static int getRSSvalue(int[] widths, int maxWidth, boolean noNarrow) { public static int getRSSvalue(int[] widths, int maxWidth, boolean noNarrow) {
int elements = widths.length; int elements = widths.length;
@ -124,6 +126,7 @@ public final class RSSUtils {
return val; return val;
} }
/*
static int[] elements(int[] eDist, int N, int K) { static int[] elements(int[] eDist, int N, int K) {
int[] widths = new int[eDist.length + 2]; int[] widths = new int[eDist.length + 2];
int twoK = K << 1; int twoK = K << 1;
@ -151,6 +154,6 @@ public final class RSSUtils {
} }
return widths; return widths;
} }
*/
} }

View file

@ -29,7 +29,7 @@ public final class PDF417Common {
public static final int MIN_ROWS_IN_BARCODE = 3; public static final int MIN_ROWS_IN_BARCODE = 3;
public static final int MAX_ROWS_IN_BARCODE = 90; public static final int MAX_ROWS_IN_BARCODE = 90;
// One left row indication column + max 30 data columns + one right row indicator column // One left row indication column + max 30 data columns + one right row indicator column
public static final int MAX_CODEWORDS_IN_ROW = 32; //public static final int MAX_CODEWORDS_IN_ROW = 32;
public static final int MODULES_IN_CODEWORD = 17; public static final int MODULES_IN_CODEWORD = 17;
public static final int MODULES_IN_STOP_PATTERN = 18; public static final int MODULES_IN_STOP_PATTERN = 18;
public static final int BARS_IN_MODULE = 8; public static final int BARS_IN_MODULE = 8;

View file

@ -131,6 +131,7 @@ final class BoundingBox {
maxY = (int) Math.max(bottomLeft.getY(), bottomRight.getY()); maxY = (int) Math.max(bottomLeft.getY(), bottomRight.getY());
} }
/*
void setTopRight(ResultPoint topRight) { void setTopRight(ResultPoint topRight) {
this.topRight = topRight; this.topRight = topRight;
calculateMinMaxValues(); calculateMinMaxValues();
@ -140,6 +141,7 @@ final class BoundingBox {
this.bottomRight = bottomRight; this.bottomRight = bottomRight;
calculateMinMaxValues(); calculateMinMaxValues();
} }
*/
int getMinX() { int getMinX() {
return minX; return minX;

View file

@ -61,9 +61,11 @@ class DetectionResultColumn {
return imageRow - boundingBox.getMinY(); return imageRow - boundingBox.getMinY();
} }
/*
final int codewordIndexToImageRow(int codewordIndex) { final int codewordIndexToImageRow(int codewordIndex) {
return boundingBox.getMinY() + codewordIndex; return boundingBox.getMinY() + codewordIndex;
} }
*/
final void setCodeword(int imageRow, Codeword codeword) { final void setCodeword(int imageRow, Codeword codeword) {
codewords[imageRowToCodewordIndex(imageRow)] = codeword; codewords[imageRowToCodewordIndex(imageRow)] = codeword;

View file

@ -82,11 +82,9 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
maxRowHeight = Math.max(maxRowHeight, currentRowHeight); maxRowHeight = Math.max(maxRowHeight, currentRowHeight);
currentRowHeight = 1; currentRowHeight = 1;
barcodeRow = codeword.getRowNumber(); barcodeRow = codeword.getRowNumber();
} else if (rowDifference < 0) { } else if (rowDifference < 0 ||
codewords[codewordsRow] = null; codeword.getRowNumber() >= barcodeMetadata.getRowCount() ||
} else if (codeword.getRowNumber() >= barcodeMetadata.getRowCount()) { rowDifference > codewordsRow) {
codewords[codewordsRow] = null;
} else if (rowDifference > codewordsRow) {
codewords[codewordsRow] = null; codewords[codewordsRow] = null;
} else { } else {
int checkedRows; int checkedRows;

View file

@ -47,9 +47,11 @@ public final class BarcodeMatrix {
matrix[y].set(x, value); matrix[y].set(x, value);
} }
/*
void setMatrix(int x, int y, boolean black) { void setMatrix(int x, int y, boolean black) {
set(x, y, (byte) (black ? 1 : 0)); set(x, y, (byte) (black ? 1 : 0));
} }
*/
void startRow() { void startRow() {
++currentRow; ++currentRow;
@ -63,9 +65,11 @@ public final class BarcodeMatrix {
return getScaledMatrix(1, 1); return getScaledMatrix(1, 1);
} }
/*
public byte[][] getScaledMatrix(int scale) { public byte[][] getScaledMatrix(int scale) {
return getScaledMatrix(scale, scale); return getScaledMatrix(scale, scale);
} }
*/
public byte[][] getScaledMatrix(int xScale, int yScale) { public byte[][] getScaledMatrix(int xScale, int yScale) {
byte[][] matrixOut = new byte[height * yScale][width * xScale]; byte[][] matrixOut = new byte[height * yScale][width * xScale];

View file

@ -63,9 +63,11 @@ final class BarcodeRow {
} }
} }
/*
byte[] getRow() { byte[] getRow() {
return row; return row;
} }
*/
/** /**
* This function scales the row * This function scales the row

View file

@ -404,8 +404,7 @@ final class PDF417HighLevelEncoder {
String part = '1' + msg.substring(startpos + idx, startpos + idx + len); String part = '1' + msg.substring(startpos + idx, startpos + idx + len);
BigInteger bigint = new BigInteger(part); BigInteger bigint = new BigInteger(part);
do { do {
BigInteger c = bigint.mod(num900); tmp.append((char) bigint.mod(num900).intValue());
tmp.append((char) c.intValue());
bigint = bigint.divide(num900); bigint = bigint.divide(num900);
} while (!bigint.equals(num0)); } while (!bigint.equals(num0));

View file

@ -28,7 +28,7 @@ import com.google.zxing.ResultPoint;
public final class FinderPattern extends ResultPoint { public final class FinderPattern extends ResultPoint {
private final float estimatedModuleSize; private final float estimatedModuleSize;
private int count; private final int count;
FinderPattern(float posX, float posY, float estimatedModuleSize) { FinderPattern(float posX, float posY, float estimatedModuleSize) {
this(posX, posY, estimatedModuleSize, 1); this(posX, posY, estimatedModuleSize, 1);
@ -48,9 +48,11 @@ public final class FinderPattern extends ResultPoint {
return count; return count;
} }
/*
void incrementCount() { void incrementCount() {
this.count++; this.count++;
} }
*/
/** /**
* <p>Determines if this finder pattern "about equals" a finder pattern at the stated * <p>Determines if this finder pattern "about equals" a finder pattern at the stated

View file

@ -434,7 +434,7 @@ public class FinderPatternFinder {
if (max <= 1) { if (max <= 1) {
return 0; return 0;
} }
FinderPattern firstConfirmedCenter = null; ResultPoint firstConfirmedCenter = null;
for (FinderPattern center : possibleCenters) { for (FinderPattern center : possibleCenters) {
if (center.getCount() >= CENTER_QUORUM) { if (center.getCount() >= CENTER_QUORUM) {
if (firstConfirmedCenter == null) { if (firstConfirmedCenter == null) {

View file

@ -30,9 +30,9 @@ import org.junit.Test;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
/** /**
@ -92,7 +92,7 @@ public final class DetectorTest extends Assert {
// Try a few random three-bit errors; // Try a few random three-bit errors;
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
BitMatrix copy = clone(matrix); BitMatrix copy = clone(matrix);
Set<Integer> errors = new TreeSet<Integer>(); Collection<Integer> errors = new TreeSet<Integer>();
while (errors.size() < 3) { while (errors.size() < 3) {
// Quick and dirty way of getting three distinct integers between 1 and n. // Quick and dirty way of getting three distinct integers between 1 and n.
errors.add(random.nextInt(orientationPoints.size())); errors.add(random.nextInt(orientationPoints.size()));
@ -124,9 +124,8 @@ public final class DetectorTest extends Assert {
} }
// Returns a list of the four rotations of the BitMatrix. // Returns a list of the four rotations of the BitMatrix.
private static List<BitMatrix> getRotations(BitMatrix input) { private static Iterable<BitMatrix> getRotations(BitMatrix matrix0) {
BitMatrix matrix0 = input; BitMatrix matrix90 = rotateRight(matrix0);
BitMatrix matrix90 = rotateRight(input);
BitMatrix matrix180 = rotateRight(matrix90); BitMatrix matrix180 = rotateRight(matrix90);
BitMatrix matrix270 = rotateRight(matrix180); BitMatrix matrix270 = rotateRight(matrix180);
return Arrays.asList(matrix0, matrix90, matrix180, matrix270); return Arrays.asList(matrix0, matrix90, matrix180, matrix270);

View file

@ -29,9 +29,9 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.Graphics2D; import java.awt.Graphics;
import java.awt.geom.AffineTransform; import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D; import java.awt.geom.RectangularShape;
import java.awt.image.AffineTransformOp; import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp; import java.awt.image.BufferedImageOp;
@ -322,19 +322,16 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
} }
switch(original.getType()) { switch(original.getType()) {
case BufferedImage.TYPE_BYTE_INDEXED: case BufferedImage.TYPE_BYTE_INDEXED:
case BufferedImage.TYPE_BYTE_BINARY: case BufferedImage.TYPE_BYTE_BINARY:
BufferedImage argb = new BufferedImage(original.getWidth(), BufferedImage argb = new BufferedImage(original.getWidth(),
original.getHeight(), original.getHeight(),
BufferedImage.TYPE_INT_ARGB); BufferedImage.TYPE_INT_ARGB);
Graphics2D g = argb.createGraphics(); Graphics g = argb.createGraphics();
g.drawImage(original, 0, 0, null); g.drawImage(original, 0, 0, null);
g.dispose(); g.dispose();
original = argb; original = argb;
break; break;
default:
// nothing
break;
} }
double radians = Math.toRadians(degrees); double radians = Math.toRadians(degrees);
@ -344,7 +341,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
at.rotate(radians, original.getWidth() / 2.0, original.getHeight() / 2.0); at.rotate(radians, original.getWidth() / 2.0, original.getHeight() / 2.0);
BufferedImageOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC); BufferedImageOp op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
Rectangle2D r = op.getBounds2D(original); RectangularShape r = op.getBounds2D(original);
int width = (int) Math.ceil(r.getWidth()); int width = (int) Math.ceil(r.getWidth());
int height = (int) Math.ceil(r.getHeight()); int height = (int) Math.ceil(r.getHeight());

View file

@ -1,65 +1,65 @@
/* /*
* Copyright 2008 ZXing authors * Copyright 2008 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.zxing.common; package com.google.zxing.common;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
/** /**
* Class that lets one easily build an array of bytes by appending bits at a time. * Class that lets one easily build an array of bytes by appending bits at a time.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class BitSourceBuilder { public final class BitSourceBuilder {
private final ByteArrayOutputStream output; private final ByteArrayOutputStream output;
private int nextByte; private int nextByte;
private int bitsLeftInNextByte; private int bitsLeftInNextByte;
public BitSourceBuilder() { public BitSourceBuilder() {
output = new ByteArrayOutputStream(); output = new ByteArrayOutputStream();
nextByte = 0; nextByte = 0;
bitsLeftInNextByte = 8; bitsLeftInNextByte = 8;
} }
public void write(int value, int numBits) { public void write(int value, int numBits) {
if (numBits <= bitsLeftInNextByte) { if (numBits <= bitsLeftInNextByte) {
nextByte <<= numBits; nextByte <<= numBits;
nextByte |= value; nextByte |= value;
bitsLeftInNextByte -= numBits; bitsLeftInNextByte -= numBits;
if (bitsLeftInNextByte == 0) { if (bitsLeftInNextByte == 0) {
output.write(nextByte); output.write(nextByte);
nextByte = 0; nextByte = 0;
bitsLeftInNextByte = 8; bitsLeftInNextByte = 8;
} }
} else { } else {
int bitsToWriteNow = bitsLeftInNextByte; int bitsToWriteNow = bitsLeftInNextByte;
int numRestOfBits = numBits - bitsToWriteNow; int numRestOfBits = numBits - bitsToWriteNow;
int mask = 0xFF >> (8 - bitsToWriteNow); int mask = 0xFF >> (8 - bitsToWriteNow);
int valueToWriteNow = (value >>> numRestOfBits) & mask; int valueToWriteNow = (value >>> numRestOfBits) & mask;
write(valueToWriteNow, bitsToWriteNow); write(valueToWriteNow, bitsToWriteNow);
write(value, numRestOfBits); write(value, numRestOfBits);
} }
} }
public byte[] toByteArray() { public byte[] toByteArray() {
if (bitsLeftInNextByte < 8) { if (bitsLeftInNextByte < 8) {
write(0, bitsLeftInNextByte); write(0, bitsLeftInNextByte);
} }
return output.toByteArray(); return output.toByteArray();
} }
} }

View file

@ -29,7 +29,7 @@ public final class ErrorCorrectionTestCase extends Assert {
//Sample from Annexe R in ISO/IEC 16022:2000(E) //Sample from Annexe R in ISO/IEC 16022:2000(E)
char[] cw = {142, 164, 186}; char[] cw = {142, 164, 186};
SymbolInfo symbolInfo = SymbolInfo.lookup(3); SymbolInfo symbolInfo = SymbolInfo.lookup(3);
String s = ErrorCorrection.encodeECC200(String.valueOf(cw), symbolInfo); CharSequence s = ErrorCorrection.encodeECC200(String.valueOf(cw), symbolInfo);
assertEquals("142 164 186 114 25 5 88 102", HighLevelEncodeTestCase.visualize(s)); assertEquals("142 164 186 114 25 5 88 102", HighLevelEncodeTestCase.visualize(s));
//"A" encoded (ASCII encoding + 2 padding characters) //"A" encoded (ASCII encoding + 2 padding characters)

View file

@ -353,7 +353,7 @@ public final class HighLevelEncodeTestCase extends Assert {
*/ */
private static String encodeHighLevel(String msg) { private static String encodeHighLevel(String msg) {
String encoded = HighLevelEncoder.encodeHighLevel(msg); CharSequence encoded = HighLevelEncoder.encodeHighLevel(msg);
//DecodeHighLevel.decode(encoded); //DecodeHighLevel.decode(encoded);
return visualize(encoded); return visualize(encoded);
} }

View file

@ -31,7 +31,7 @@ public final class CodaBarWriterTestCase extends Assert {
public void testEncode() throws WriterException { public void testEncode() throws WriterException {
// 1001001011 0 110101001 0 101011001 0 110101001 0 101001101 0 110010101 0 1101101011 0 // 1001001011 0 110101001 0 101011001 0 110101001 0 101001101 0 110010101 0 1101101011 0
// 1001001011 // 1001001011
String resultStr = "0000000000" + CharSequence resultStr = "0000000000" +
"1001001011011010100101010110010110101001010100110101100101010110110101101001001011" "1001001011011010100101010110010110101001010100110101100101010110110101101001001011"
+ "0000000000"; + "0000000000";
BitMatrix result = new CodaBarWriter().encode("B515-3/B", BarcodeFormat.CODABAR, resultStr.length(), 0); BitMatrix result = new CodaBarWriter().encode("B515-3/B", BarcodeFormat.CODABAR, resultStr.length(), 0);

View file

@ -29,7 +29,7 @@ public final class EAN13WriterTestCase extends Assert {
@Test @Test
public void testEncode() throws WriterException { public void testEncode() throws WriterException {
String testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000"; CharSequence testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000";
BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0); BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) { for (int i = 0; i < testStr.length(); i++) {
assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0));

View file

@ -29,7 +29,7 @@ public final class EAN8WriterTestCase extends Assert {
@Test @Test
public void testEncode() throws WriterException { public void testEncode() throws WriterException {
String testStr = "0001010001011010111101111010110111010101001110111001010001001011100101000"; CharSequence testStr = "0001010001011010111101111010110111010101001110111001010001001011100101000";
BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0); BitMatrix result = new EAN8Writer().encode("96385074", BarcodeFormat.EAN_8, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) { for (int i = 0; i < testStr.length(); i++) {
assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0));

View file

@ -1,34 +1,34 @@
/* /*
* Copyright 2008 ZXing authors * Copyright 2008 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.zxing.oned; package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
/** /**
* @author kevin.osullivan@sita.aero * @author kevin.osullivan@sita.aero
*/ */
public final class ITFBlackBox1TestCase extends AbstractBlackBoxTestCase { public final class ITFBlackBox1TestCase extends AbstractBlackBoxTestCase {
public ITFBlackBox1TestCase() { public ITFBlackBox1TestCase() {
super("test/data/blackbox/itf-1", new MultiFormatReader(), BarcodeFormat.ITF); super("test/data/blackbox/itf-1", new MultiFormatReader(), BarcodeFormat.ITF);
addTest(9, 13, 0.0f); addTest(9, 13, 0.0f);
addTest(12, 13, 180.0f); addTest(12, 13, 180.0f);
} }
} }

View file

@ -1,34 +1,34 @@
/* /*
* Copyright 2008 ZXing authors * Copyright 2008 ZXing authors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.zxing.oned; package com.google.zxing.oned;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
/** /**
* @author dswitkin@google.com (Daniel Switkin) * @author dswitkin@google.com (Daniel Switkin)
*/ */
public final class ITFBlackBox2TestCase extends AbstractBlackBoxTestCase { public final class ITFBlackBox2TestCase extends AbstractBlackBoxTestCase {
public ITFBlackBox2TestCase() { public ITFBlackBox2TestCase() {
super("test/data/blackbox/itf-2", new MultiFormatReader(), BarcodeFormat.ITF); super("test/data/blackbox/itf-2", new MultiFormatReader(), BarcodeFormat.ITF);
addTest(13, 13, 0.0f); addTest(13, 13, 0.0f);
addTest(13, 13, 180.0f); addTest(13, 13, 180.0f);
} }
} }

View file

@ -30,7 +30,7 @@ public final class UPCAWriterTestCase extends Assert {
@Test @Test
public void testEncode() throws WriterException { public void testEncode() throws WriterException {
String testStr = "00010101000110110111011000100010110101111011110101010111001011101001001110110011011011001011100101000"; CharSequence testStr = "00010101000110110111011000100010110101111011110101010111001011101001001110110011011011001011100101000";
BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0); BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) { for (int i = 0; i < testStr.length(); i++) {
assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0));
@ -39,7 +39,7 @@ public final class UPCAWriterTestCase extends Assert {
@Test @Test
public void testAddChecksumAndEncode() throws WriterException { public void testAddChecksumAndEncode() throws WriterException {
String testStr = "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000"; CharSequence testStr = "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000";
BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0); BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) { for (int i = 0; i < testStr.length(); i++) {
assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0)); assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0));

View file

@ -46,7 +46,7 @@ public final class BinaryUtil {
* Constructs a BitArray from a String like the one returned from BitArray.toString() * Constructs a BitArray from a String like the one returned from BitArray.toString()
*/ */
public static BitArray buildBitArrayFromString(CharSequence data) { public static BitArray buildBitArrayFromString(CharSequence data) {
String dotsAndXs = ZERO.matcher(ONE.matcher(data).replaceAll("X")).replaceAll("."); CharSequence dotsAndXs = ZERO.matcher(ONE.matcher(data).replaceAll("X")).replaceAll(".");
BitArray binary = new BitArray(SPACE.matcher(dotsAndXs).replaceAll("").length()); BitArray binary = new BitArray(SPACE.matcher(dotsAndXs).replaceAll("").length());
int counter = 0; int counter = 0;
@ -69,7 +69,7 @@ public final class BinaryUtil {
public static BitArray buildBitArrayFromStringWithoutSpaces(CharSequence data) { public static BitArray buildBitArrayFromStringWithoutSpaces(CharSequence data) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String dotsAndXs = ZERO.matcher(ONE.matcher(data).replaceAll("X")).replaceAll("."); CharSequence dotsAndXs = ZERO.matcher(ONE.matcher(data).replaceAll("X")).replaceAll(".");
int current = 0; int current = 0;
while (current < dotsAndXs.length()) { while (current < dotsAndXs.length()) {
sb.append(' '); sb.append(' ');

View file

@ -43,7 +43,7 @@ public final class BinaryUtilTest extends Assert {
@Test @Test
public void testBuildBitArrayFromString(){ public void testBuildBitArrayFromString(){
String data = " ..X..X.. ..XXX... XXXXXXXX ........"; CharSequence data = " ..X..X.. ..XXX... XXXXXXXX ........";
check(data); check(data);
data = " XXX..X.."; data = " XXX..X..";
@ -66,7 +66,7 @@ public final class BinaryUtilTest extends Assert {
@Test @Test
public void testBuildBitArrayFromStringWithoutSpaces(){ public void testBuildBitArrayFromStringWithoutSpaces(){
String data = " ..X..X.. ..XXX... XXXXXXXX ........"; CharSequence data = " ..X..X.. ..XXX... XXXXXXXX ........";
checkWithoutSpaces(data); checkWithoutSpaces(data);
data = " XXX..X.."; data = " XXX..X..";
@ -83,7 +83,7 @@ public final class BinaryUtilTest extends Assert {
} }
private static void checkWithoutSpaces(CharSequence data){ private static void checkWithoutSpaces(CharSequence data){
String dataWithoutSpaces = SPACE.matcher(data).replaceAll(""); CharSequence dataWithoutSpaces = SPACE.matcher(data).replaceAll("");
BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(dataWithoutSpaces); BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(dataWithoutSpaces);
assertEquals(data, binary.toString()); assertEquals(data, binary.toString());
} }

View file

@ -28,6 +28,7 @@ package com.google.zxing.oned.rss.expanded;
import java.util.List; import java.util.List;
import com.google.zxing.oned.OneDReader;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -73,7 +74,7 @@ public final class RSSExpandedStackedInternalTestCase extends Assert {
@Test @Test
public void testCompleteDecode() throws Exception { public void testCompleteDecode() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); OneDReader rssExpandedReader = new RSSExpandedReader();
BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("test/data/blackbox/rssexpandedstacked-2/1000.png"); BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("test/data/blackbox/rssexpandedstacked-2/1000.png");

View file

@ -38,21 +38,21 @@ public final class AI01_3103_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_3103_1() throws Exception { public void test01_3103_1() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750; CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750;
String expected = "(01)90012345678908(3103)001750"; String expected = "(01)90012345678908(3103)001750";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
} }
@Test @Test
public void test01_3103_2() throws Exception { public void test01_3103_2() throws Exception {
String data = header + compressedGtin_900000000000008 + compressed15bitWeight_0; CharSequence data = header + compressedGtin_900000000000008 + compressed15bitWeight_0;
String expected = "(01)90000000000003(3103)000000"; String expected = "(01)90000000000003(3103)000000";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
} }
@Test(expected = NotFoundException.class) @Test(expected = NotFoundException.class)
public void test01_3103_invalid() throws Exception { public void test01_3103_invalid() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750 + ".."; CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750 + "..";
assertCorrectBinaryString(data, ""); assertCorrectBinaryString(data, "");
} }
} }

View file

@ -37,7 +37,7 @@ public final class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_3202_1() throws Exception { public void test01_3202_1() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750; CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750;
String expected = "(01)90012345678908(3202)001750"; String expected = "(01)90012345678908(3202)001750";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -45,7 +45,7 @@ public final class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_3203_1() throws Exception { public void test01_3203_1() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_11750; CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_11750;
String expected = "(01)90012345678908(3203)001750"; String expected = "(01)90012345678908(3203)001750";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);

View file

@ -44,7 +44,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_310X_1X_endDate() throws Exception { public void test01_310X_1X_endDate() throws Exception {
String data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_End; CharSequence data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_End;
String expected = "(01)90012345678908(3100)001750"; String expected = "(01)90012345678908(3100)001750";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -52,7 +52,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_310X_11_1() throws Exception { public void test01_310X_11_1() throws Exception {
String data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_310x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(11)100312"; String expected = "(01)90012345678908(3100)001750(11)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -60,7 +60,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_320X_11_1() throws Exception { public void test01_320X_11_1() throws Exception {
String data = header_320x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_320x_11 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(11)100312"; String expected = "(01)90012345678908(3200)001750(11)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -68,7 +68,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_310X_13_1() throws Exception { public void test01_310X_13_1() throws Exception {
String data = header_310x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_310x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(13)100312"; String expected = "(01)90012345678908(3100)001750(13)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -76,7 +76,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_320X_13_1() throws Exception { public void test01_320X_13_1() throws Exception {
String data = header_320x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_320x_13 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(13)100312"; String expected = "(01)90012345678908(3200)001750(13)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -84,7 +84,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_310X_15_1() throws Exception { public void test01_310X_15_1() throws Exception {
String data = header_310x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_310x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(15)100312"; String expected = "(01)90012345678908(3100)001750(15)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -92,7 +92,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_320X_15_1() throws Exception { public void test01_320X_15_1() throws Exception {
String data = header_320x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_320x_15 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(15)100312"; String expected = "(01)90012345678908(3200)001750(15)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -100,7 +100,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_310X_17_1() throws Exception { public void test01_310X_17_1() throws Exception {
String data = header_310x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_310x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3100)001750(17)100312"; String expected = "(01)90012345678908(3100)001750(17)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -108,7 +108,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test @Test
public void test01_320X_17_1() throws Exception { public void test01_320X_17_1() throws Exception {
String data = header_320x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010; CharSequence data = header_320x_17 + compressedGtin_900123456798908 + compressed20bitWeight_1750 + compressedDate_March_12th_2010;
String expected = "(01)90012345678908(3200)001750(17)100312"; String expected = "(01)90012345678908(3200)001750(17)100312";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);

View file

@ -40,7 +40,7 @@ public abstract class AbstractDecoderTest extends Assert {
protected static final String numeric_10 = "..X..XX"; protected static final String numeric_10 = "..X..XX";
protected static final String numeric_12 = "..X.X.X"; protected static final String numeric_12 = "..X.X.X";
protected static final String numeric_1FNC1 = "..XXX.X"; protected static final String numeric_1FNC1 = "..XXX.X";
protected static final String numeric_FNC11 = "XXX.XXX"; //protected static final String numeric_FNC11 = "XXX.XXX";
protected static final String numeric2alpha = "...."; protected static final String numeric2alpha = "....";

View file

@ -37,7 +37,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test @Test
public void testAnyAIDecoder_1() throws Exception { public void testAnyAIDecoder_1() throws Exception {
String data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2numeric + numeric_12; CharSequence data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2numeric + numeric_12;
String expected = "(10)12A12"; String expected = "(10)12A12";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -45,7 +45,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test @Test
public void testAnyAIDecoder_2() throws Exception { public void testAnyAIDecoder_2() throws Exception {
String data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2isoiec646 + i646_B; CharSequence data = header + numeric_10 + numeric_12 + numeric2alpha + alpha_A + alpha2isoiec646 + i646_B;
String expected = "(10)12AB"; String expected = "(10)12AB";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -53,7 +53,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test @Test
public void testAnyAIDecoder_3() throws Exception { public void testAnyAIDecoder_3() throws Exception {
String data = header + numeric_10 + numeric2alpha + alpha2isoiec646 + i646_B + i646_C + isoiec646_2alpha + alpha_A + alpha2numeric + numeric_10; CharSequence data = header + numeric_10 + numeric2alpha + alpha2isoiec646 + i646_B + i646_C + isoiec646_2alpha + alpha_A + alpha2numeric + numeric_10;
String expected = "(10)BCA10"; String expected = "(10)BCA10";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -61,7 +61,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test @Test
public void testAnyAIDecoder_numericFNC1_secondDigit() throws Exception { public void testAnyAIDecoder_numericFNC1_secondDigit() throws Exception {
String data = header + numeric_10 + numeric_1FNC1; CharSequence data = header + numeric_10 + numeric_1FNC1;
String expected = "(10)1"; String expected = "(10)1";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -69,7 +69,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test @Test
public void testAnyAIDecoder_alphaFNC1() throws Exception { public void testAnyAIDecoder_alphaFNC1() throws Exception {
String data = header + numeric_10 + numeric2alpha + alpha_A + alpha_FNC1; CharSequence data = header + numeric_10 + numeric2alpha + alpha_A + alpha_FNC1;
String expected = "(10)A"; String expected = "(10)A";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);
@ -77,7 +77,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test @Test
public void testAnyAIDecoder_646FNC1() throws Exception { public void testAnyAIDecoder_646FNC1() throws Exception {
String data = header + numeric_10 + numeric2alpha + alpha_A + isoiec646_2alpha + i646_B + i646_FNC1; CharSequence data = header + numeric_10 + numeric2alpha + alpha_A + isoiec646_2alpha + i646_B + i646_FNC1;
String expected = "(10)AB"; String expected = "(10)AB";
assertCorrectBinaryString(data, expected); assertCorrectBinaryString(data, expected);

View file

@ -98,7 +98,7 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
log.fine(String.format("Starting Image Group %s", testImageGroup.getKey())); log.fine(String.format("Starting Image Group %s", testImageGroup.getKey()));
String fileBaseName = testImageGroup.getKey(); String fileBaseName = testImageGroup.getKey();
String expectedText = null; String expectedText;
File expectedTextFile = new File(testBase, fileBaseName + ".txt"); File expectedTextFile = new File(testBase, fileBaseName + ".txt");
if (expectedTextFile.exists()) { if (expectedTextFile.exists()) {
expectedText = readFileAsString(expectedTextFile, UTF8); expectedText = readFileAsString(expectedTextFile, UTF8);

View file

@ -40,6 +40,7 @@ abstract class AbstractErrorCorrectionTestCase extends Assert {
} }
} }
/*
static int[] erase(int[] received, int howMany, Random random) { static int[] erase(int[] received, int howMany, Random random) {
BitSet erased = new BitSet(received.length); BitSet erased = new BitSet(received.length);
int[] erasures = new int[howMany]; int[] erasures = new int[howMany];
@ -56,11 +57,13 @@ abstract class AbstractErrorCorrectionTestCase extends Assert {
} }
return erasures; return erasures;
} }
*/
static Random getRandom() { static Random getRandom() {
return new SecureRandom(new byte[] {(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF}); return new SecureRandom(new byte[] {(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF});
} }
/*
static void assertArraysEqual(int[] expected, static void assertArraysEqual(int[] expected,
int expectedOffset, int expectedOffset,
int[] actual, int[] actual,
@ -70,5 +73,6 @@ abstract class AbstractErrorCorrectionTestCase extends Assert {
assertEquals(expected[expectedOffset + i], actual[actualOffset + i]); assertEquals(expected[expectedOffset + i], actual[actualOffset + i]);
} }
} }
*/
} }

View file

@ -127,22 +127,22 @@ public final class BitVectorTestCase extends Assert {
@Test @Test
public void testXOR() { public void testXOR() {
{ BitArray v1 = new BitArray();
BitArray v1 = new BitArray(); v1.appendBits(0x5555aaaa, 32);
v1.appendBits(0x5555aaaa, 32); BitArray v2 = new BitArray();
BitArray v2 = new BitArray(); v2.appendBits(0xaaaa5555, 32);
v2.appendBits(0xaaaa5555, 32); v1.xor(v2);
v1.xor(v2); assertEquals(0xffffffffL, getUnsignedInt(v1, 0));
assertEquals(0xffffffffL, getUnsignedInt(v1, 0)); }
}
{ @Test
BitArray v1 = new BitArray(); public void testXOR2() {
v1.appendBits(0x2a, 7); // 010 1010 BitArray v1 = new BitArray();
BitArray v2 = new BitArray(); v1.appendBits(0x2a, 7); // 010 1010
v2.appendBits(0x55, 7); // 101 0101 BitArray v2 = new BitArray();
v1.xor(v2); v2.appendBits(0x55, 7); // 101 0101
assertEquals(0xfe000000L, getUnsignedInt(v1, 0)); // 1111 1110 v1.xor(v2);
} assertEquals(0xfe000000L, getUnsignedInt(v1, 0)); // 1111 1110
} }
@Test @Test

View file

@ -111,7 +111,7 @@ public final class StringsResourceTranslator {
File translatedFile, File translatedFile,
Collection<String> forceRetranslation) throws IOException { Collection<String> forceRetranslation) throws IOException {
SortedMap<String,String> english = readLines(englishFile); Map<String, String> english = readLines(englishFile);
SortedMap<String,String> translated = readLines(translatedFile); SortedMap<String,String> translated = readLines(translatedFile);
String parentName = translatedFile.getParentFile().getName(); String parentName = translatedFile.getParentFile().getName();
@ -226,7 +226,7 @@ public final class StringsResourceTranslator {
return entries; return entries;
} }
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), UTF8))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), UTF8))) {
String line; CharSequence line;
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

@ -39,6 +39,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JTextArea; import javax.swing.JTextArea;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import javax.swing.text.JTextComponent;
/** /**
* <p>Simple GUI frontend to the library. Right now, only decodes a local file. * <p>Simple GUI frontend to the library. Right now, only decodes a local file.
@ -49,7 +50,7 @@ import javax.swing.WindowConstants;
public final class GUIRunner extends JFrame { public final class GUIRunner extends JFrame {
private final JLabel imageLabel; private final JLabel imageLabel;
private final JTextArea textArea; private final JTextComponent textArea;
private GUIRunner() { private GUIRunner() {
imageLabel = new JLabel(); imageLabel = new JLabel();

View file

@ -140,7 +140,7 @@ public final class DecodeServlet extends HttpServlet {
} }
imageURIString = imageURIString.trim(); imageURIString = imageURIString.trim();
for (String substring : blockedURLSubstrings) { for (CharSequence substring : blockedURLSubstrings) {
if (imageURIString.contains(substring)) { if (imageURIString.contains(substring)) {
log.info("Disallowed URI " + imageURIString); log.info("Disallowed URI " + imageURIString);
response.sendRedirect("badurl.jspx"); response.sendRedirect("badurl.jspx");
@ -326,14 +326,14 @@ public final class DecodeServlet extends HttpServlet {
ServletRequest request, ServletRequest request,
HttpServletResponse response) throws IOException, ServletException { HttpServletResponse response) throws IOException, ServletException {
Reader reader = new MultiFormatReader();
LuminanceSource source = new BufferedImageLuminanceSource(image); LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source)); BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source));
Collection<Result> results = new ArrayList<>(1); Collection<Result> results = new ArrayList<>(1);
ReaderException savedException = null;
try { try {
Reader reader = new MultiFormatReader();
ReaderException savedException = null;
try { try {
// Look for multiple barcodes // Look for multiple barcodes
MultipleBarcodeReader multiReader = new GenericMultipleBarcodeReader(reader); MultipleBarcodeReader multiReader = new GenericMultipleBarcodeReader(reader);

View file

@ -48,7 +48,7 @@ public final class OutputUtils {
return result.toString(); return result.toString();
} }
public static char hexChar(int value) { private static char hexChar(int value) {
if (value < 0 || value > 15) { if (value < 0 || value > 15) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }