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.EnumSet;
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
@ -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 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/" };
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,
ResultMetadataType.SUGGESTED_PRICE,
ResultMetadataType.ERROR_CORRECTION_LEVEL,
@ -220,8 +217,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
}
} else if (dataString != null &&
dataString.contains(PRODUCT_SEARCH_URL_PREFIX) &&
dataString.contains(PRODUCT_SEARCH_URL_SUFFIX)) {
dataString.contains("http://www.google") &&
dataString.contains("/m/products/scan")) {
// Scan only products and send the result to mobile Product Search.
source = IntentSource.PRODUCT_SEARCH_LINK;
@ -430,9 +427,9 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
case NONE:
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (fromLiveScan && prefs.getBoolean(PreferencesActivity.KEY_BULK_MODE, false)) {
String message = getResources().getString(R.string.msg_bulk_mode_scanned)
+ " (" + rawResult.getText() + ')';
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(),
getResources().getString(R.string.msg_bulk_mode_scanned) + " (" + rawResult.getText() + ')',
Toast.LENGTH_SHORT).show();
// Wait a moment or else it will scan the same barcode continuously about 3 times
restartPreviewAfterDelay(BULK_MODE_SCAN_DELAY_MS);
} else {
@ -506,9 +503,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
typeTextView.setText(resultHandler.getType().toString());
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);
timeTextView.setText(formattedTime);
timeTextView.setText(formatter.format(new Date(rawResult.getTimestamp())));
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,
metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
}
Integer orientation = (Integer) metadata.get(ResultMetadataType.ORIENTATION);
Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
if (orientation != null) {
intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,7 +16,6 @@
package com.google.zxing.client.android.encode;
import android.provider.ContactsContract;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
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.common.BitMatrix;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
@ -61,7 +61,7 @@ final class QRCodeEncoder {
private static final int WHITE = 0xFFFFFFFF;
private static final int BLACK = 0xFF000000;
private final Activity activity;
private final Context activity;
private String contents;
private String displayContents;
private String title;
@ -69,7 +69,7 @@ final class QRCodeEncoder {
private final int dimension;
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.dimension = dimension;
this.useVCard = useVCard;
@ -259,7 +259,7 @@ final class QRCodeEncoder {
emails.add(bundle.getString(Contents.EMAIL_KEYS[x]));
}
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);
ContactEncoder mecardEncoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();

View file

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

View file

@ -16,7 +16,7 @@
package com.google.zxing.client.android.history;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
@ -31,28 +31,28 @@ import java.util.ArrayList;
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>());
this.activity = activity;
}
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
LinearLayout layout;
View layout;
if (view instanceof LinearLayout) {
layout = (LinearLayout) view;
layout = view;
} else {
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);
Result result = item.getResult();
String title;
String detail;
CharSequence title;
CharSequence detail;
if (result != null) {
title = result.getText();
detail = item.getDisplayAndDetails();

View file

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

View file

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

View file

@ -62,19 +62,19 @@ final class BookmarkAdapter extends BaseAdapter {
@Override
public View getView(int index, View view, ViewGroup viewGroup) {
LinearLayout layout;
View layout;
if (view instanceof LinearLayout) {
layout = (LinearLayout) view;
layout = view;
} else {
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()) {
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);
String url = cursor.getString(BookmarkPickerActivity.URL_COLUMN);
CharSequence url = cursor.getString(BookmarkPickerActivity.URL_COLUMN);
((TextView) layout.findViewById(R.id.bookmark_url)).setText(url);
} // Otherwise... just don't update as the object is shutting down
return layout;

View file

@ -18,6 +18,7 @@ package com.google.zxing.client.android.share;
import android.app.ListActivity;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageItemInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@ -59,8 +60,8 @@ final class LoadPackagesAsyncTask extends AsyncTask<Void,Void,List<AppInfo>> {
protected List<AppInfo> doInBackground(Void... objects) {
List<AppInfo> labelsPackages = new ArrayList<AppInfo>();
PackageManager packageManager = activity.getPackageManager();
List<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (ApplicationInfo appInfo : appInfos) {
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (PackageItemInfo appInfo : appInfos) {
String packageName = appInfo.packageName;
if (!isHidden(packageName)) {
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_APP = 2;
private Button clipboardButton;
private View clipboardButton;
private final Button.OnClickListener contactListener = new Button.OnClickListener() {
@Override
@ -124,7 +124,7 @@ public final class ShareActivity extends Activity {
findViewById(R.id.share_contact_button).setOnClickListener(contactListener);
findViewById(R.id.share_bookmark_button).setOnClickListener(bookmarkListener);
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);
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.util.Log;
import java.util.List;
import java.util.regex.Pattern;
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) {
List<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
Iterable<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
for (WifiConfiguration existingConfig : existingConfigs) {
if (existingConfig.SSID.equals(ssid)) {
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 PATH = Environment.getExternalStorageDirectory().getPath() + "/zxingbenchmark";
private Button runBenchmarkButton;
private View runBenchmarkButton;
private TextView textView;
private Thread benchmarkThread;
@ -81,7 +81,7 @@ public final class BenchmarkActivity extends Activity {
setContentView(R.layout.benchmark);
runBenchmarkButton = (Button) findViewById(R.id.benchmark_run);
runBenchmarkButton = findViewById(R.id.benchmark_run);
runBenchmarkButton.setOnClickListener(runBenchmark);
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
}
private static String getFlattenedParams() {
private static CharSequence getFlattenedParams() {
Camera camera = Camera.open();
if (camera == 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.SDK_INT=").append(Build.VERSION.SDK_INT).append('\n');
String flattened = getFlattenedParams();
CharSequence flattened = getFlattenedParams();
String[] params = SEMICOLON.split(flattened);
Arrays.sort(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) {
String charset = hints == null ? null : (String) hints.get(EncodeHintType.CHARACTER_SET);
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,
format,
width,

View file

@ -158,7 +158,7 @@ public final class HighLevelEncoder {
* Convert the text represented by this High Level Encoder into a BitArray.
*/
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++) {
int pairCode;
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
// for the new character, merging the results, and then removing the
// 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>();
for (State state : states) {
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>();
for (State state : states) {
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>();
for (State newState : states) {
boolean add = true;

View file

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

View file

@ -36,7 +36,7 @@ public final class GeoResultParser extends ResultParser {
@Override
public GeoParsedResult parse(Result result) {
String rawText = getMassagedText(result);
CharSequence rawText = getMassagedText(result);
Matcher matcher = GEO_URL_PATTERN.matcher(rawText);
if (!matcher.matches()) {
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:
* {@code smtp(:subject(:body))}.</p>
* {@code smtp[:subject[:body]]}.</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 {
private final String codewords;
private final CharSequence codewords;
private final int numrows;
private final int numcols;
private final byte[] bits;
@ -35,7 +35,7 @@ public class DefaultPlacement {
* @param numcols the number of columns
* @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.numcols = numcols;
this.numrows = numrows;

View file

@ -18,7 +18,6 @@ package com.google.zxing.datamatrix.encoder;
import com.google.zxing.Dimension;
import java.nio.charset.Charset;
import java.util.Arrays;
/**
@ -112,16 +111,19 @@ public final class HighLevelEncoder {
private HighLevelEncoder() {
}
/**
/*
* Converts the message to a byte array using the default encoding (cp437) as defined by the
* specification
*
* @param msg the message
* @return the byte array of the message
*/
/*
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)
}
*/
private static char randomize253State(char ch, int codewordPosition) {
int pseudoRandom = ((149 * codewordPosition) % 253) + 1;

View file

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

View file

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

View file

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

View file

@ -21,6 +21,7 @@ public final class RSSUtils {
private RSSUtils() {}
/*
static int[] getRSSwidths(int val, int n, int elements, int maxWidth, boolean noNarrow) {
int[] widths = new int[elements];
int bar;
@ -60,6 +61,7 @@ public final class RSSUtils {
widths[bar] = n;
return widths;
}
*/
public static int getRSSvalue(int[] widths, int maxWidth, boolean noNarrow) {
int elements = widths.length;
@ -124,6 +126,7 @@ public final class RSSUtils {
return val;
}
/*
static int[] elements(int[] eDist, int N, int K) {
int[] widths = new int[eDist.length + 2];
int twoK = K << 1;
@ -151,6 +154,6 @@ public final class RSSUtils {
}
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 MAX_ROWS_IN_BARCODE = 90;
// 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_STOP_PATTERN = 18;
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());
}
/*
void setTopRight(ResultPoint topRight) {
this.topRight = topRight;
calculateMinMaxValues();
@ -140,6 +141,7 @@ final class BoundingBox {
this.bottomRight = bottomRight;
calculateMinMaxValues();
}
*/
int getMinX() {
return minX;

View file

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

View file

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

View file

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

View file

@ -63,9 +63,11 @@ final class BarcodeRow {
}
}
/*
byte[] getRow() {
return 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);
BigInteger bigint = new BigInteger(part);
do {
BigInteger c = bigint.mod(num900);
tmp.append((char) c.intValue());
tmp.append((char) bigint.mod(num900).intValue());
bigint = bigint.divide(num900);
} while (!bigint.equals(num0));

View file

@ -28,7 +28,7 @@ import com.google.zxing.ResultPoint;
public final class FinderPattern extends ResultPoint {
private final float estimatedModuleSize;
private int count;
private final int count;
FinderPattern(float posX, float posY, float estimatedModuleSize) {
this(posX, posY, estimatedModuleSize, 1);
@ -48,9 +48,11 @@ public final class FinderPattern extends ResultPoint {
return count;
}
/*
void incrementCount() {
this.count++;
}
*/
/**
* <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) {
return 0;
}
FinderPattern firstConfirmedCenter = null;
ResultPoint firstConfirmedCenter = null;
for (FinderPattern center : possibleCenters) {
if (center.getCount() >= CENTER_QUORUM) {
if (firstConfirmedCenter == null) {

View file

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

View file

@ -29,9 +29,9 @@ import org.junit.Assert;
import org.junit.Test;
import javax.imageio.ImageIO;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RectangularShape;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
@ -322,19 +322,16 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
}
switch(original.getType()) {
case BufferedImage.TYPE_BYTE_INDEXED:
case BufferedImage.TYPE_BYTE_BINARY:
BufferedImage argb = new BufferedImage(original.getWidth(),
original.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics2D g = argb.createGraphics();
g.drawImage(original, 0, 0, null);
g.dispose();
original = argb;
break;
default:
// nothing
break;
case BufferedImage.TYPE_BYTE_INDEXED:
case BufferedImage.TYPE_BYTE_BINARY:
BufferedImage argb = new BufferedImage(original.getWidth(),
original.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Graphics g = argb.createGraphics();
g.drawImage(original, 0, 0, null);
g.dispose();
original = argb;
break;
}
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);
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 height = (int) Math.ceil(r.getHeight());

View file

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

View file

@ -31,7 +31,7 @@ public final class CodaBarWriterTestCase extends Assert {
public void testEncode() throws WriterException {
// 1001001011 0 110101001 0 101011001 0 110101001 0 101001101 0 110010101 0 1101101011 0
// 1001001011
String resultStr = "0000000000" +
CharSequence resultStr = "0000000000" +
"1001001011011010100101010110010110101001010100110101100101010110110101101001001011"
+ "0000000000";
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
public void testEncode() throws WriterException {
String testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000";
CharSequence testStr = "00010100010110100111011001100100110111101001110101010110011011011001000010101110010011101000100101000";
BitMatrix result = new EAN13Writer().encode("5901234123457", BarcodeFormat.EAN_13, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) {
assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0));

View file

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

View file

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

View file

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

View file

@ -30,7 +30,7 @@ public final class UPCAWriterTestCase extends Assert {
@Test
public void testEncode() throws WriterException {
String testStr = "00010101000110110111011000100010110101111011110101010111001011101001001110110011011011001011100101000";
CharSequence testStr = "00010101000110110111011000100010110101111011110101010111001011101001001110110011011011001011100101000";
BitMatrix result = new UPCAWriter().encode("485963095124", BarcodeFormat.UPC_A, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) {
assertEquals("Element " + i, testStr.charAt(i) == '1', result.get(i, 0));
@ -39,7 +39,7 @@ public final class UPCAWriterTestCase extends Assert {
@Test
public void testAddChecksumAndEncode() throws WriterException {
String testStr = "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000";
CharSequence testStr = "00010100110010010011011110101000110110001010111101010100010010010001110100111001011001101101100101000";
BitMatrix result = new UPCAWriter().encode("12345678901", BarcodeFormat.UPC_A, testStr.length(), 0);
for (int i = 0; i < testStr.length(); i++) {
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()
*/
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());
int counter = 0;
@ -69,7 +69,7 @@ public final class BinaryUtil {
public static BitArray buildBitArrayFromStringWithoutSpaces(CharSequence data) {
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;
while (current < dotsAndXs.length()) {
sb.append(' ');

View file

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

View file

@ -28,6 +28,7 @@ package com.google.zxing.oned.rss.expanded;
import java.util.List;
import com.google.zxing.oned.OneDReader;
import org.junit.Assert;
import org.junit.Test;
@ -73,7 +74,7 @@ public final class RSSExpandedStackedInternalTestCase extends Assert {
@Test
public void testCompleteDecode() throws Exception {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
OneDReader rssExpandedReader = new RSSExpandedReader();
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
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";
assertCorrectBinaryString(data, expected);
}
@Test
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";
assertCorrectBinaryString(data, expected);
}
@Test(expected = NotFoundException.class)
public void test01_3103_invalid() throws Exception {
String data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750 + "..";
CharSequence data = header + compressedGtin_900123456798908 + compressed15bitWeight_1750 + "..";
assertCorrectBinaryString(data, "");
}
}

View file

@ -37,7 +37,7 @@ public final class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -45,7 +45,7 @@ public final class AI01_3202_3203_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);

View file

@ -44,7 +44,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -52,7 +52,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -60,7 +60,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -68,7 +68,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -76,7 +76,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -84,7 +84,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -92,7 +92,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -100,7 +100,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -108,7 +108,7 @@ public final class AI01_3X0X_1X_DecoderTest extends AbstractDecoderTest {
@Test
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";
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_12 = "..X.X.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 = "....";

View file

@ -37,7 +37,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -45,7 +45,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -53,7 +53,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -61,7 +61,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -69,7 +69,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test
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";
assertCorrectBinaryString(data, expected);
@ -77,7 +77,7 @@ public final class AnyAIDecoderTest extends AbstractDecoderTest {
@Test
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";
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()));
String fileBaseName = testImageGroup.getKey();
String expectedText = null;
String expectedText;
File expectedTextFile = new File(testBase, fileBaseName + ".txt");
if (expectedTextFile.exists()) {
expectedText = readFileAsString(expectedTextFile, UTF8);

View file

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

View file

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

View file

@ -111,7 +111,7 @@ public final class StringsResourceTranslator {
File translatedFile,
Collection<String> forceRetranslation) throws IOException {
SortedMap<String,String> english = readLines(englishFile);
Map<String, String> english = readLines(englishFile);
SortedMap<String,String> translated = readLines(translatedFile);
String parentName = translatedFile.getParentFile().getName();
@ -226,7 +226,7 @@ public final class StringsResourceTranslator {
return entries;
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), UTF8))) {
String line;
CharSequence line;
while ((line = reader.readLine()) != null) {
Matcher m = ENTRY_PATTERN.matcher(line);
if (m.find()) {

View file

@ -39,6 +39,7 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
import javax.swing.text.JTextComponent;
/**
* <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 {
private final JLabel imageLabel;
private final JTextArea textArea;
private final JTextComponent textArea;
private GUIRunner() {
imageLabel = new JLabel();

View file

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

View file

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