Boldly move to Java 7 for everything, including Android.

git-svn-id: https://zxing.googlecode.com/svn/trunk@2981 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen@gmail.com 2013-12-02 18:18:46 +00:00
parent 1b0c3c7b3a
commit a53c659b0e
76 changed files with 328 additions and 357 deletions

View file

@ -18,4 +18,6 @@
application-package=com.google.zxing.client.android
external-libs-folder=libs
key.store=../private/ZXing.keystore
key.alias=zxing
key.alias=zxing
java.source=7
java.target=7

View file

@ -55,7 +55,7 @@ final class DecodeHintManager {
* @return name-value pairs
*/
private static Map<String,String> splitQuery(String query) {
Map<String,String> map = new HashMap<String,String>();
Map<String,String> map = new HashMap<>();
int pos = 0;
while (pos < query.length()) {
if (query.charAt(pos) == '&') {
@ -123,7 +123,7 @@ final class DecodeHintManager {
// Extract parameters
Map<String, String> parameters = splitQuery(query);
Map<DecodeHintType, Object> hints = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);
Map<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class);
for (DecodeHintType hintType: DecodeHintType.values()) {
@ -203,7 +203,7 @@ final class DecodeHintManager {
if (extras == null || extras.isEmpty()) {
return null;
}
Map<DecodeHintType,Object> hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
for (DecodeHintType hintType: DecodeHintType.values()) {

View file

@ -56,7 +56,7 @@ final class DecodeThread extends Thread {
this.activity = activity;
handlerInitLatch = new CountDownLatch(1);
hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
hints = new EnumMap<>(DecodeHintType.class);
if (baseHints != null) {
hints.putAll(baseHints);
}

View file

@ -38,7 +38,7 @@ public final class HttpHelper {
private static final String TAG = HttpHelper.class.getSimpleName();
private static final Collection<String> REDIRECTOR_DOMAINS = new HashSet<String>(Arrays.asList(
private static final Collection<String> REDIRECTOR_DOMAINS = new HashSet<>(Arrays.asList(
"amzn.to", "bit.ly", "bitly.com", "fb.me", "goo.gl", "is.gd", "j.mp", "lnkd.in", "ow.ly",
"R.BEETAGG.COM", "r.beetagg.com", "SCN.BY", "su.pr", "t.co", "tinyurl.com", "tr.im"
));
@ -102,7 +102,7 @@ public final class HttpHelper {
connection.setRequestProperty("Accept-Charset", "utf-8,*");
connection.setRequestProperty("User-Agent", "ZXing (Android)");
try {
int responseCode = safelyConnect(uri, connection);
int responseCode = safelyConnect(connection);
switch (responseCode) {
case HttpURLConnection.HTTP_OK:
return consume(connection, maxChars);
@ -150,10 +150,8 @@ public final class HttpHelper {
if (in != null) {
try {
in.close();
} catch (IOException ioe) {
} catch (IOException | NullPointerException ioe) {
// continue
} catch (NullPointerException npe) {
// another apparent Android / Harmony bug; continue
}
}
}
@ -171,7 +169,7 @@ public final class HttpHelper {
connection.setRequestMethod("HEAD");
connection.setRequestProperty("User-Agent", "ZXing (Android)");
try {
int responseCode = safelyConnect(uri.toString(), connection);
int responseCode = safelyConnect(connection);
switch (responseCode) {
case HttpURLConnection.HTTP_MULT_CHOICE:
case HttpURLConnection.HTTP_MOVED_PERM:
@ -208,35 +206,18 @@ public final class HttpHelper {
return (HttpURLConnection) conn;
}
private static int safelyConnect(String uri, HttpURLConnection connection) throws IOException {
private static int safelyConnect(HttpURLConnection connection) throws IOException {
try {
connection.connect();
} catch (NullPointerException npe) {
} catch (NullPointerException | IllegalArgumentException | IndexOutOfBoundsException | SecurityException e) {
// this is an Android bug: http://code.google.com/p/android/issues/detail?id=16895
throw new IOException(npe);
} catch (IllegalArgumentException iae) {
// Also seen this in the wild, not sure what to make of it. Probably a bad URL
throw new IOException(iae);
} catch (SecurityException se) {
// due to bad VPN settings?
Log.w(TAG, "Restricted URI? " + uri);
throw new IOException(se);
} catch (IndexOutOfBoundsException ioobe) {
// Another Android problem? https://groups.google.com/forum/?fromgroups#!topic/google-admob-ads-sdk/U-WfmYa9or0
throw new IOException(ioobe);
throw new IOException(e);
}
try {
return connection.getResponseCode();
} catch (NullPointerException npe) {
} catch (NullPointerException | StringIndexOutOfBoundsException | IllegalArgumentException e) {
// this is maybe this Android bug: http://code.google.com/p/android/issues/detail?id=15554
throw new IOException(npe);
} catch (IllegalArgumentException iae) {
// Again seen this in the wild for bad header fields in the server response! or bad reads
Log.w(TAG, "Bad server status? " + uri);
throw new IOException(iae);
} catch (StringIndexOutOfBoundsException sioobe) {
// Another Android bug: https://code.google.com/p/android/issues/detail?id=18856
throw new IOException(sioobe);
throw new IOException(e);
}
}

View file

@ -43,7 +43,7 @@ public final class LocaleManager {
*/
private static final Map<String,String> GOOGLE_COUNTRY_TLD;
static {
GOOGLE_COUNTRY_TLD = new HashMap<String,String>();
GOOGLE_COUNTRY_TLD = new HashMap<>();
GOOGLE_COUNTRY_TLD.put("AR", "com.ar"); // ARGENTINA
GOOGLE_COUNTRY_TLD.put("AU", "com.au"); // AUSTRALIA
GOOGLE_COUNTRY_TLD.put("BR", "com.br"); // BRAZIL
@ -84,7 +84,7 @@ public final class LocaleManager {
*/
private static final Map<String,String> GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD;
static {
GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD = new HashMap<String,String>();
GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD = new HashMap<>();
GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD.put("AU", "com.au"); // AUSTRALIA
//GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD.put(Locale.CHINA.getCountry(), "cn");
GOOGLE_PRODUCT_SEARCH_COUNTRY_TLD.put(Locale.FRANCE.getCountry(), "fr");

View file

@ -52,7 +52,7 @@ public final class PreferencesFragment
}
private void disableLastCheckedPref() {
Collection<CheckBoxPreference> checked = new ArrayList<CheckBoxPreference>(3);
Collection<CheckBoxPreference> checked = new ArrayList<>(3);
if (decode1D.isChecked()) {
checked.add(decode1D);
}

View file

@ -68,7 +68,7 @@ public final class ViewfinderView extends View {
laserColor = resources.getColor(R.color.viewfinder_laser);
resultPointColor = resources.getColor(R.color.possible_result_points);
scannerAlpha = 0;
possibleResultPoints = new ArrayList<ResultPoint>(5);
possibleResultPoints = new ArrayList<>(5);
lastPossibleResultPoints = null;
}
@ -119,7 +119,7 @@ public final class ViewfinderView extends View {
if (currentPossible.isEmpty()) {
lastPossibleResultPoints = null;
} else {
possibleResultPoints = new ArrayList<ResultPoint>(5);
possibleResultPoints = new ArrayList<>(5);
lastPossibleResultPoints = currentPossible;
paint.setAlpha(CURRENT_POINT_OPACITY);
paint.setColor(resultPointColor);

View file

@ -212,7 +212,7 @@ public final class SearchBookContentsActivity extends Activity {
if (count > 0) {
JSONArray results = json.getJSONArray("search_results");
SearchBookContentsResult.setQuery(queryTextView.getText().toString());
List<SearchBookContentsResult> items = new ArrayList<SearchBookContentsResult>(count);
List<SearchBookContentsResult> items = new ArrayList<>(count);
for (int x = 0; x < count; x++) {
items.add(parseResult(results.getJSONObject(x)));
}

View file

@ -35,7 +35,7 @@ final class AutoFocusManager implements Camera.AutoFocusCallback {
private static final long AUTO_FOCUS_INTERVAL_MS = 2000L;
private static final Collection<String> FOCUS_MODES_CALLING_AF;
static {
FOCUS_MODES_CALLING_AF = new ArrayList<String>(2);
FOCUS_MODES_CALLING_AF = new ArrayList<>(2);
FOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_AUTO);
FOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_MACRO);
}

View file

@ -216,7 +216,7 @@ final class CameraConfigurationManager {
}
// Sort by size, descending
List<Camera.Size> supportedPreviewSizes = new ArrayList<Camera.Size>(rawSupportedSizes);
List<Camera.Size> supportedPreviewSizes = new ArrayList<>(rawSupportedSizes);
Collections.sort(supportedPreviewSizes, new Comparator<Camera.Size>() {
@Override
public int compare(Camera.Size a, Camera.Size b) {

View file

@ -38,12 +38,9 @@ public final class ClipboardInterface {
if (text != null) {
try {
getManager(context).setPrimaryClip(ClipData.newPlainText(null, text));
} catch (NullPointerException npe) {
} catch (NullPointerException | IllegalStateException e) {
// Have seen this in the wild, bizarrely
Log.w(TAG, "Clipboard bug", npe);
} catch (IllegalStateException ise) {
// java.lang.IllegalStateException: beginBroadcast() called while already in a broadcast
Log.w(TAG, "Clipboard bug", ise);
Log.w(TAG, "Clipboard bug", e);
}
}
}

View file

@ -75,7 +75,7 @@ abstract class ContactEncoder {
return;
}
int count = 0;
Collection<String> uniques = new HashSet<String>(2);
Collection<String> uniques = new HashSet<>(2);
for (String value : values) {
String trimmed = trim(value);
if (trimmed != null && !trimmed.isEmpty() && !uniques.contains(trimmed)) {

View file

@ -214,82 +214,95 @@ final class QRCodeEncoder {
}
private void encodeQRCodeContents(Intent intent, String type) {
if (type.equals(Contents.Type.TEXT)) {
String data = intent.getStringExtra(Intents.Encode.DATA);
if (data != null && !data.isEmpty()) {
contents = data;
displayContents = data;
title = activity.getString(R.string.contents_text);
}
} else if (type.equals(Contents.Type.EMAIL)) {
String data = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
if (data != null) {
contents = "mailto:" + data;
displayContents = data;
title = activity.getString(R.string.contents_email);
}
} else if (type.equals(Contents.Type.PHONE)) {
String data = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
if (data != null) {
contents = "tel:" + data;
displayContents = PhoneNumberUtils.formatNumber(data);
title = activity.getString(R.string.contents_phone);
}
} else if (type.equals(Contents.Type.SMS)) {
String data = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
if (data != null) {
contents = "sms:" + data;
displayContents = PhoneNumberUtils.formatNumber(data);
title = activity.getString(R.string.contents_sms);
}
} else if (type.equals(Contents.Type.CONTACT)) {
Bundle bundle = intent.getBundleExtra(Intents.Encode.DATA);
if (bundle != null) {
String name = bundle.getString(ContactsContract.Intents.Insert.NAME);
String organization = bundle.getString(ContactsContract.Intents.Insert.COMPANY);
String address = bundle.getString(ContactsContract.Intents.Insert.POSTAL);
Collection<String> phones = new ArrayList<String>(Contents.PHONE_KEYS.length);
for (int x = 0; x < Contents.PHONE_KEYS.length; x++) {
phones.add(bundle.getString(Contents.PHONE_KEYS[x]));
switch (type) {
case Contents.Type.TEXT: {
String data = intent.getStringExtra(Intents.Encode.DATA);
if (data != null && !data.isEmpty()) {
contents = data;
displayContents = data;
title = activity.getString(R.string.contents_text);
}
Collection<String> emails = new ArrayList<String>(Contents.EMAIL_KEYS.length);
for (int x = 0; x < Contents.EMAIL_KEYS.length; x++) {
emails.add(bundle.getString(Contents.EMAIL_KEYS[x]));
break;
}
case Contents.Type.EMAIL: {
String data = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
if (data != null) {
contents = "mailto:" + data;
displayContents = data;
title = activity.getString(R.string.contents_email);
}
String url = bundle.getString(Contents.URL_KEY);
Iterable<String> urls = url == null ? null : Collections.singletonList(url);
String note = bundle.getString(Contents.NOTE_KEY);
break;
}
case Contents.Type.PHONE: {
String data = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
if (data != null) {
contents = "tel:" + data;
displayContents = PhoneNumberUtils.formatNumber(data);
title = activity.getString(R.string.contents_phone);
}
break;
}
case Contents.Type.SMS: {
String data = ContactEncoder.trim(intent.getStringExtra(Intents.Encode.DATA));
if (data != null) {
contents = "sms:" + data;
displayContents = PhoneNumberUtils.formatNumber(data);
title = activity.getString(R.string.contents_sms);
}
break;
}
case Contents.Type.CONTACT: {
Bundle bundle = intent.getBundleExtra(Intents.Encode.DATA);
if (bundle != null) {
String name = bundle.getString(ContactsContract.Intents.Insert.NAME);
String organization = bundle.getString(ContactsContract.Intents.Insert.COMPANY);
String address = bundle.getString(ContactsContract.Intents.Insert.POSTAL);
Collection<String> phones = new ArrayList<>(Contents.PHONE_KEYS.length);
for (int x = 0; x < Contents.PHONE_KEYS.length; x++) {
phones.add(bundle.getString(Contents.PHONE_KEYS[x]));
}
Collection<String> emails = new ArrayList<>(Contents.EMAIL_KEYS.length);
for (int x = 0; x < Contents.EMAIL_KEYS.length; x++) {
emails.add(bundle.getString(Contents.EMAIL_KEYS[x]));
}
String url = bundle.getString(Contents.URL_KEY);
Iterable<String> urls = url == null ? null : Collections.singletonList(url);
String note = bundle.getString(Contents.NOTE_KEY);
ContactEncoder mecardEncoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
String[] encoded = mecardEncoder.encode(Collections.singleton(name),
organization,
Collections.singleton(address),
phones,
emails,
urls,
note);
// Make sure we've encoded at least one field.
if (!encoded[1].isEmpty()) {
contents = encoded[0];
displayContents = encoded[1];
title = activity.getString(R.string.contents_contact);
}
ContactEncoder mecardEncoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
String[] encoded = mecardEncoder.encode(Collections.singleton(name),
organization,
Collections.singleton(address),
phones,
emails,
urls,
note);
// Make sure we've encoded at least one field.
if (!encoded[1].isEmpty()) {
contents = encoded[0];
displayContents = encoded[1];
title = activity.getString(R.string.contents_contact);
}
break;
}
} else if (type.equals(Contents.Type.LOCATION)) {
Bundle bundle = intent.getBundleExtra(Intents.Encode.DATA);
if (bundle != null) {
// These must use Bundle.getFloat(), not getDouble(), it's part of the API.
float latitude = bundle.getFloat("LAT", Float.MAX_VALUE);
float longitude = bundle.getFloat("LONG", Float.MAX_VALUE);
if (latitude != Float.MAX_VALUE && longitude != Float.MAX_VALUE) {
contents = "geo:" + latitude + ',' + longitude;
displayContents = latitude + "," + longitude;
title = activity.getString(R.string.contents_location);
case Contents.Type.LOCATION: {
Bundle bundle = intent.getBundleExtra(Intents.Encode.DATA);
if (bundle != null) {
// These must use Bundle.getFloat(), not getDouble(), it's part of the API.
float latitude = bundle.getFloat("LAT", Float.MAX_VALUE);
float longitude = bundle.getFloat("LONG", Float.MAX_VALUE);
if (latitude != Float.MAX_VALUE && longitude != Float.MAX_VALUE) {
contents = "geo:" + latitude + ',' + longitude;
displayContents = latitude + "," + longitude;
title = activity.getString(R.string.contents_location);
}
}
break;
}
}
}
@ -323,7 +336,7 @@ final class QRCodeEncoder {
Map<EncodeHintType,Object> hints = null;
String encoding = guessAppropriateEncoding(contentsToEncode);
if (encoding != null) {
hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, encoding);
}
BitMatrix result;

View file

@ -92,7 +92,7 @@ public final class HistoryManager {
public List<HistoryItem> buildHistoryItems() {
SQLiteOpenHelper helper = new DBHelper(activity);
List<HistoryItem> items = new ArrayList<HistoryItem>();
List<HistoryItem> items = new ArrayList<>();
SQLiteDatabase db = null;
Cursor cursor = null;
try {

View file

@ -71,7 +71,7 @@ final class AmazonInfoRetriever extends SupplementalInfoRetriever {
HttpHelper.ContentType.XML);
String detailPageURL = null;
Collection<String> authors = new ArrayList<String>();
Collection<String> authors = new ArrayList<>();
String title = null;
String formattedNewPrice = null;
String formattedUsedPrice = null;
@ -83,46 +83,58 @@ final class AmazonInfoRetriever extends SupplementalInfoRetriever {
boolean seenItem = false;
boolean seenLowestNewPrice = false;
boolean seenLowestUsedPrice = false;
for (int eventType = xpp.getEventType(); eventType != XmlPullParser.END_DOCUMENT; eventType = xpp.next()) {
boolean done = false;
for (int eventType = xpp.getEventType();
!done && eventType != XmlPullParser.END_DOCUMENT;
eventType = xpp.next()) {
if (eventType == XmlPullParser.START_TAG) {
String name = xpp.getName();
if ("Item".equals(name)) {
if (seenItem) {
break;
} else {
seenItem = true;
}
} else if ("DetailPageURL".equals(name)) {
assertTextNext(xpp);
detailPageURL = xpp.getText();
} else if ("Author".equals(name)) {
assertTextNext(xpp);
authors.add(xpp.getText());
} else if ("Title".equals(name)) {
assertTextNext(xpp);
title = xpp.getText();
} else if ("LowestNewPrice".equals(name)) {
seenLowestNewPrice = true;
seenLowestUsedPrice = false;
} else if ("LowestUsedPrice".equals(name)) {
seenLowestNewPrice = false;
seenLowestUsedPrice = true;
} else if ("FormattedPrice".equals(name)) {
if (seenLowestNewPrice || seenLowestUsedPrice) {
assertTextNext(xpp);
String theText = xpp.getText();
if (seenLowestNewPrice) {
formattedNewPrice = theText;
switch (name) {
case "Item":
if (seenItem) {
done = true; // terminates loop
} else {
formattedUsedPrice = theText;
seenItem = true;
}
seenLowestNewPrice = false;
break;
case "DetailPageURL":
assertTextNext(xpp);
detailPageURL = xpp.getText();
break;
case "Author":
assertTextNext(xpp);
authors.add(xpp.getText());
break;
case "Title":
assertTextNext(xpp);
title = xpp.getText();
break;
case "LowestNewPrice":
seenLowestNewPrice = true;
seenLowestUsedPrice = false;
}
} else if ("Errors".equals(name)) {
error = true;
break;
break;
case "LowestUsedPrice":
seenLowestNewPrice = false;
seenLowestUsedPrice = true;
break;
case "FormattedPrice":
if (seenLowestNewPrice || seenLowestUsedPrice) {
assertTextNext(xpp);
String theText = xpp.getText();
if (seenLowestNewPrice) {
formattedNewPrice = theText;
} else {
formattedUsedPrice = theText;
}
seenLowestNewPrice = false;
seenLowestUsedPrice = false;
}
break;
case "Errors":
error = true;
done = true; // terminates loop
break;
}
}
}
@ -135,7 +147,7 @@ final class AmazonInfoRetriever extends SupplementalInfoRetriever {
return false;
}
Collection<String> newTexts = new ArrayList<String>();
Collection<String> newTexts = new ArrayList<>();
maybeAddText(title, newTexts);
maybeAddTextSeries(authors, newTexts);
if (formattedNewPrice != null) {

View file

@ -81,7 +81,7 @@ final class BookResultInfoRetriever extends SupplementalInfoRetriever {
JSONArray authorsArray = volumeInfo.optJSONArray("authors");
if (authorsArray != null && !authorsArray.isNull(0)) {
authors = new ArrayList<String>(authorsArray.length());
authors = new ArrayList<>(authorsArray.length());
for (int i = 0; i < authorsArray.length(); i++) {
authors.add(authorsArray.getString(i));
}
@ -91,7 +91,7 @@ final class BookResultInfoRetriever extends SupplementalInfoRetriever {
throw new IOException(e);
}
Collection<String> newTexts = new ArrayList<String>();
Collection<String> newTexts = new ArrayList<>();
maybeAddText(title, newTexts);
maybeAddTextSeries(authors, newTexts);
maybeAddText(pages == null || pages.isEmpty() ? null : pages + "pp.", newTexts);

View file

@ -91,10 +91,10 @@ public abstract class SupplementalInfoRetriever extends AsyncTask<Object,Object,
private final Collection<String[]> newHistories;
SupplementalInfoRetriever(TextView textView, HistoryManager historyManager) {
textViewRef = new WeakReference<TextView>(textView);
historyManagerRef = new WeakReference<HistoryManager>(historyManager);
newContents = new ArrayList<Spannable>();
newHistories = new ArrayList<String[]>();
textViewRef = new WeakReference<>(textView);
historyManagerRef = new WeakReference<>(historyManager);
newContents = new ArrayList<>();
newHistories = new ArrayList<>();
}
@Override

View file

@ -58,7 +58,7 @@ final class LoadPackagesAsyncTask extends AsyncTask<Void,Void,List<AppInfo>> {
@Override
protected List<AppInfo> doInBackground(Void... objects) {
List<AppInfo> labelsPackages = new ArrayList<AppInfo>();
List<AppInfo> labelsPackages = new ArrayList<>();
PackageManager packageManager = activity.getPackageManager();
Iterable<ApplicationInfo> appInfos = packageManager.getInstalledApplications(0);
for (PackageItemInfo appInfo : appInfos) {

View file

@ -16,8 +16,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.zxing.client.androidtest"
android:versionName="1.4"
android:versionCode="9"
android:versionName="1.4.1"
android:versionCode="10"
android:installLocation="auto">
<uses-permission android:name="android.permission.CAMERA"/>

View file

@ -18,4 +18,6 @@
application-package=com.google.zxing.client.androidtest
external-libs-folder=libs
key.store=../private/ZXing.keystore
key.alias=zxing
key.alias=zxing
java.source=7
java.target=7

View file

@ -53,7 +53,7 @@ public final class BenchmarkAsyncTask extends AsyncTask<Object,Object,String> {
// Try to get in a known state before starting the benchmark
System.gc();
List<BenchmarkItem> items = new ArrayList<BenchmarkItem>();
List<BenchmarkItem> items = new ArrayList<>();
walkTree(reader, path, items);
int count = 0;

View file

@ -99,7 +99,7 @@ public final class MultiFormatReader implements Reader {
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> formats =
hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
Collection<Reader> readers = new ArrayList<Reader>();
Collection<Reader> readers = new ArrayList<>();
if (formats != null) {
boolean addOneDReader =
formats.contains(BarcodeFormat.UPC_A) ||

View file

@ -94,7 +94,7 @@ public final class Result {
public void putMetadata(ResultMetadataType type, Object value) {
if (resultMetadata == null) {
resultMetadata = new EnumMap<ResultMetadataType,Object>(ResultMetadataType.class);
resultMetadata = new EnumMap<>(ResultMetadataType.class);
}
resultMetadata.put(type, value);
}

View file

@ -75,16 +75,7 @@ public final class AztecReader implements Reader {
AztecDetectorResult detectorResult = detector.detect(true);
points = detectorResult.getPoints();
decoderResult = new Decoder().decode(detectorResult);
} catch (NotFoundException e) {
if (notFoundException != null) {
throw notFoundException;
}
if (formatException != null) {
throw formatException;
}
throw e;
} catch (FormatException e) {
// throw the exception from the non-mirror case, instead
} catch (NotFoundException | FormatException e) {
if (notFoundException != null) {
throw notFoundException;
}

View file

@ -203,7 +203,7 @@ public final class HighLevelEncoder {
// for the new character, merging the results, and then removing the
// non-optimal states.
private Collection<State> updateStateListForChar(Iterable<State> states, int index) {
Collection<State> result = new LinkedList<State>();
Collection<State> result = new LinkedList<>();
for (State state : states) {
updateStateForChar(state, index, result);
}
@ -252,7 +252,7 @@ public final class HighLevelEncoder {
}
private static Collection<State> updateStateListForPair(Iterable<State> states, int index, int pairCode) {
Collection<State> result = new LinkedList<State>();
Collection<State> result = new LinkedList<>();
for (State state : states) {
updateStateForPair(state, index, pairCode, result);
}
@ -284,7 +284,7 @@ public final class HighLevelEncoder {
}
private static Collection<State> simplifyStates(Iterable<State> states) {
List<State> result = new LinkedList<State>();
List<State> result = new LinkedList<>();
for (State newState : states) {
boolean add = true;
for (Iterator<State> iterator = result.iterator(); iterator.hasNext(); ) {

View file

@ -148,7 +148,7 @@ final class State {
BitArray toBitArray(byte[] text) {
// Reverse the tokens, so that they are in the order that they should
// be output
Deque<Token> symbols = new LinkedList<Token>();
Deque<Token> symbols = new LinkedList<>();
for (Token token = endBinaryShift(text.length).token; token != null; token = token.getPrevious()) {
symbols.addFirst(token);
}

View file

@ -78,7 +78,7 @@ public final class AddressBookAUResultParser extends ResultParser {
break;
}
if (values == null) {
values = new ArrayList<String>(max); // lazy init
values = new ArrayList<>(max); // lazy init
}
values.add(value);
}

View file

@ -72,7 +72,7 @@ public final class BizcardResultParser extends AbstractDoCoMoResultParser {
private static String[] buildPhoneNumbers(String number1,
String number2,
String number3) {
List<String> numbers = new ArrayList<String>(3);
List<String> numbers = new ArrayList<>(3);
if (number1 != null) {
numbers.add(number1);
}

View file

@ -62,7 +62,7 @@ public final class ExpandedProductResultParser extends ResultParser {
String price = null;
String priceIncrement = null;
String priceCurrency = null;
Map<String,String> uncommonAIs = new HashMap<String,String>();
Map<String,String> uncommonAIs = new HashMap<>();
int i = 0;
@ -77,54 +77,81 @@ public final class ExpandedProductResultParser extends ResultParser {
String value = findValue(i, rawText);
i += value.length();
if ("00".equals(ai)) {
sscc = value;
} else if ("01".equals(ai)) {
productID = value;
} else if ("10".equals(ai)) {
lotNumber = value;
} else if ("11".equals(ai)) {
productionDate = value;
} else if ("13".equals(ai)) {
packagingDate = value;
} else if ("15".equals(ai)) {
bestBeforeDate = value;
} else if ("17".equals(ai)) {
expirationDate = value;
} else if ("3100".equals(ai) || "3101".equals(ai)
|| "3102".equals(ai) || "3103".equals(ai)
|| "3104".equals(ai) || "3105".equals(ai)
|| "3106".equals(ai) || "3107".equals(ai)
|| "3108".equals(ai) || "3109".equals(ai)) {
weight = value;
weightType = ExpandedProductParsedResult.KILOGRAM;
weightIncrement = ai.substring(3);
} else if ("3200".equals(ai) || "3201".equals(ai)
|| "3202".equals(ai) || "3203".equals(ai)
|| "3204".equals(ai) || "3205".equals(ai)
|| "3206".equals(ai) || "3207".equals(ai)
|| "3208".equals(ai) || "3209".equals(ai)) {
weight = value;
weightType = ExpandedProductParsedResult.POUND;
weightIncrement = ai.substring(3);
} else if ("3920".equals(ai) || "3921".equals(ai)
|| "3922".equals(ai) || "3923".equals(ai)) {
price = value;
priceIncrement = ai.substring(3);
} else if ("3930".equals(ai) || "3931".equals(ai)
|| "3932".equals(ai) || "3933".equals(ai)) {
if (value.length() < 4) {
// The value must have more of 3 symbols (3 for currency and
// 1 at least for the price)
// ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern
return null;
}
price = value.substring(3);
priceCurrency = value.substring(0, 3);
priceIncrement = ai.substring(3);
} else {
// No match with common AIs
uncommonAIs.put(ai, value);
switch (ai) {
case "00":
sscc = value;
break;
case "01":
productID = value;
break;
case "10":
lotNumber = value;
break;
case "11":
productionDate = value;
break;
case "13":
packagingDate = value;
break;
case "15":
bestBeforeDate = value;
break;
case "17":
expirationDate = value;
break;
case "3100":
case "3101":
case "3102":
case "3103":
case "3104":
case "3105":
case "3106":
case "3107":
case "3108":
case "3109":
weight = value;
weightType = ExpandedProductParsedResult.KILOGRAM;
weightIncrement = ai.substring(3);
break;
case "3200":
case "3201":
case "3202":
case "3203":
case "3204":
case "3205":
case "3206":
case "3207":
case "3208":
case "3209":
weight = value;
weightType = ExpandedProductParsedResult.POUND;
weightIncrement = ai.substring(3);
break;
case "3920":
case "3921":
case "3922":
case "3923":
price = value;
priceIncrement = ai.substring(3);
break;
case "3930":
case "3931":
case "3932":
case "3933":
if (value.length() < 4) {
// The value must have more of 3 symbols (3 for currency and
// 1 at least for the price)
// ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern
return null;
}
price = value.substring(3);
priceCurrency = value.substring(0, 3);
priceIncrement = ai.substring(3);
break;
default:
// No match with common AIs
uncommonAIs.put(ai, value);
break;
}
}

View file

@ -171,7 +171,7 @@ public abstract class ResultParser {
if (paramStart < 0) {
return null;
}
Map<String,String> result = new HashMap<String,String>(3);
Map<String,String> result = new HashMap<>(3);
for (String keyValue : AMPERSAND.split(uri.substring(paramStart + 1))) {
appendKeyValue(keyValue, result);
}
@ -224,7 +224,7 @@ public abstract class ResultParser {
} else {
// found a match
if (matches == null) {
matches = new ArrayList<String>(3); // lazy init
matches = new ArrayList<>(3); // lazy init
}
String element = unescapeBackslash(rawText.substring(start, i));
if (trim) {

View file

@ -71,8 +71,8 @@ public final class SMSMMSResultParser extends ResultParser {
int lastComma = -1;
int comma;
List<String> numbers = new ArrayList<String>(1);
List<String> vias = new ArrayList<String>(1);
List<String> numbers = new ArrayList<>(1);
List<String> vias = new ArrayList<>(1);
while ((comma = smsURIWithoutQuery.indexOf(',', lastComma + 1)) > lastComma) {
String numberPart = smsURIWithoutQuery.substring(lastComma + 1, comma);
addNumberVia(numbers, vias, numberPart);

View file

@ -128,7 +128,7 @@ public final class VCardResultParser extends ResultParser {
if (metadataString != null) {
for (String metadatum : SEMICOLON.split(metadataString)) {
if (metadata == null) {
metadata = new ArrayList<String>(1);
metadata = new ArrayList<>(1);
}
metadata.add(metadatum);
String[] metadatumTokens = EQUALS.split(metadatum, 2);
@ -166,7 +166,7 @@ public final class VCardResultParser extends ResultParser {
} else if (i > matchStart) {
// found a match
if (matches == null) {
matches = new ArrayList<List<String>>(1); // lazy init
matches = new ArrayList<>(1); // lazy init
}
if (i >= 1 && rawText.charAt(i-1) == '\r') {
i--; // Back up over \r, which really should be there
@ -189,7 +189,7 @@ public final class VCardResultParser extends ResultParser {
element = VCARD_ESCAPES.matcher(element).replaceAll("$1");
}
if (metadata == null) {
List<String> match = new ArrayList<String>(1);
List<String> match = new ArrayList<>(1);
match.add(element);
matches.add(match);
} else {
@ -275,7 +275,7 @@ public final class VCardResultParser extends ResultParser {
if (lists == null || lists.isEmpty()) {
return null;
}
List<String> result = new ArrayList<String>(lists.size());
List<String> result = new ArrayList<>(lists.size());
for (List<String> list : lists) {
String value = list.get(0);
if (value != null && !value.isEmpty()) {
@ -289,7 +289,7 @@ public final class VCardResultParser extends ResultParser {
if (lists == null || lists.isEmpty()) {
return null;
}
List<String> result = new ArrayList<String>(lists.size());
List<String> result = new ArrayList<>(lists.size());
for (List<String> list : lists) {
String type = null;
for (int i = 1; i < list.size(); i++) {

View file

@ -58,8 +58,8 @@ public enum CharacterSetECI {
GB18030(29, "GB2312", "EUC_CN", "GBK"),
EUC_KR(30, "EUC-KR");
private static final Map<Integer,CharacterSetECI> VALUE_TO_ECI = new HashMap<Integer,CharacterSetECI>();
private static final Map<String,CharacterSetECI> NAME_TO_ECI = new HashMap<String,CharacterSetECI>();
private static final Map<Integer,CharacterSetECI> VALUE_TO_ECI = new HashMap<>();
private static final Map<String,CharacterSetECI> NAME_TO_ECI = new HashMap<>();
static {
for (CharacterSetECI eci : values()) {
for (int value : eci.values) {

View file

@ -32,7 +32,7 @@ public final class ReedSolomonEncoder {
public ReedSolomonEncoder(GenericGF field) {
this.field = field;
this.cachedGenerators = new ArrayList<GenericGFPoly>();
this.cachedGenerators = new ArrayList<>();
cachedGenerators.add(new GenericGFPoly(field, new int[]{1}));
}

View file

@ -83,7 +83,7 @@ final class DecodedBitStreamParser {
BitSource bits = new BitSource(bytes);
StringBuilder result = new StringBuilder(100);
StringBuilder resultTrailer = new StringBuilder(0);
List<byte[]> byteSegments = new ArrayList<byte[]>(1);
List<byte[]> byteSegments = new ArrayList<>(1);
Mode mode = Mode.ASCII_ENCODE;
do {
if (mode == Mode.ASCII_ENCODE) {

View file

@ -65,7 +65,7 @@ public final class Detector {
// Point A and D are across the diagonal from one another,
// as are B and C. Figure out which are the solid black lines
// by counting transitions
List<ResultPointsAndTransitions> transitions = new ArrayList<ResultPointsAndTransitions>(4);
List<ResultPointsAndTransitions> transitions = new ArrayList<>(4);
transitions.add(transitionsBetween(pointA, pointB));
transitions.add(transitionsBetween(pointA, pointC));
transitions.add(transitionsBetween(pointB, pointD));
@ -79,7 +79,7 @@ public final class Detector {
// Figure out which point is their intersection by tallying up the number of times we see the
// endpoints in the four endpoints. One will show up twice.
Map<ResultPoint,Integer> pointCount = new HashMap<ResultPoint,Integer>();
Map<ResultPoint,Integer> pointCount = new HashMap<>();
increment(pointCount, lSideOne.getFrom());
increment(pointCount, lSideOne.getTo());
increment(pointCount, lSideTwo.getFrom());

View file

@ -61,7 +61,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
@Override
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints)
throws NotFoundException {
List<Result> results = new ArrayList<Result>();
List<Result> results = new ArrayList<>();
doDecodeMultiple(image, hints, results, 0, 0, 0);
if (results.isEmpty()) {
throw NotFoundException.getNotFoundInstance();

View file

@ -52,7 +52,7 @@ public final class QRCodeMultiReader extends QRCodeReader implements MultipleBar
@Override
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
List<Result> results = new ArrayList<Result>();
List<Result> results = new ArrayList<>();
DetectorResult[] detectorResults = new MultiDetector(image.getBlackMatrix()).detectMulti(hints);
for (DetectorResult detectorResult : detectorResults) {
try {

View file

@ -55,7 +55,7 @@ public final class MultiDetector extends Detector {
throw NotFoundException.getNotFoundInstance();
}
List<DetectorResult> result = new ArrayList<DetectorResult>();
List<DetectorResult> result = new ArrayList<>();
for (FinderPatternInfo info : infos) {
try {
result.add(processFinderPatternInfo(info));

View file

@ -143,7 +143,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
* So, if the layout seems right, lets have the decoder try to decode.
*/
List<FinderPattern[]> results = new ArrayList<FinderPattern[]>(); // holder for the results
List<FinderPattern[]> results = new ArrayList<>(); // holder for the results
for (int i1 = 0; i1 < (size - 2); i1++) {
FinderPattern p1 = possibleCenters.get(i1);
@ -294,7 +294,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
} // end if foundPatternCross
} // for i=iSkip-1 ...
FinderPattern[][] patternInfo = selectMutipleBestPatterns();
List<FinderPatternInfo> result = new ArrayList<FinderPatternInfo>();
List<FinderPatternInfo> result = new ArrayList<>();
for (FinderPattern[] pattern : patternInfo) {
ResultPoint.orderBestPatterns(pattern);
result.add(new FinderPatternInfo(pattern));

View file

@ -241,7 +241,7 @@ public final class Code128Reader extends OneDReader {
int[] startPatternInfo = findStartPattern(row);
int startCode = startPatternInfo[2];
List<Byte> rawCodes = new ArrayList<Byte>(20);
List<Byte> rawCodes = new ArrayList<>(20);
rawCodes.add((byte) startCode);
int codeSet;

View file

@ -85,7 +85,7 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
}
}
Collection<int[]> patterns = new ArrayList<int[]>(); // temporary storage for patterns
Collection<int[]> patterns = new ArrayList<>(); // temporary storage for patterns
int checkSum = 0;
int checkWeight = 1;
int codeSet = 0; // selected code (CODE_CODE_B or CODE_CODE_C)

View file

@ -30,8 +30,8 @@ import java.util.List;
*/
final class EANManufacturerOrgSupport {
private final List<int[]> ranges = new ArrayList<int[]>();
private final List<String> countryIdentifiers = new ArrayList<String>();
private final List<int[]> ranges = new ArrayList<>();
private final List<String> countryIdentifiers = new ArrayList<>();
String lookupCountryIdentifier(String productCode) {
initIfNeeded();

View file

@ -44,7 +44,7 @@ public final class MultiFormatOneDReader extends OneDReader {
(Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
boolean useCode39CheckDigit = hints != null &&
hints.get(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT) != null;
Collection<OneDReader> readers = new ArrayList<OneDReader>();
Collection<OneDReader> readers = new ArrayList<>();
if (possibleFormats != null) {
if (possibleFormats.contains(BarcodeFormat.EAN_13) ||
possibleFormats.contains(BarcodeFormat.UPC_A) ||

View file

@ -43,7 +43,7 @@ public final class MultiFormatUPCEANReader extends OneDReader {
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats = hints == null ? null :
(Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
Collection<UPCEANReader> readers = new ArrayList<UPCEANReader>();
Collection<UPCEANReader> readers = new ArrayList<>();
if (possibleFormats != null) {
if (possibleFormats.contains(BarcodeFormat.EAN_13)) {
readers.add(new EAN13Reader());

View file

@ -147,7 +147,7 @@ public abstract class OneDReader implements Reader {
// don't want to clutter with noise from every single row scan -- just the scans
// that start on the center line.
if (hints != null && hints.containsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)) {
Map<DecodeHintType,Object> newHints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
Map<DecodeHintType,Object> newHints = new EnumMap<>(DecodeHintType.class);
newHints.putAll(hints);
newHints.remove(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
hints = newHints;

View file

@ -104,7 +104,7 @@ final class UPCEANExtension2Support {
if (raw.length() != 2) {
return null;
}
Map<ResultMetadataType,Object> result = new EnumMap<ResultMetadataType,Object>(ResultMetadataType.class);
Map<ResultMetadataType,Object> result = new EnumMap<>(ResultMetadataType.class);
result.put(ResultMetadataType.ISSUE_NUMBER, Integer.valueOf(raw));
return result;
}

View file

@ -137,7 +137,7 @@ final class UPCEANExtension5Support {
if (value == null) {
return null;
}
Map<ResultMetadataType,Object> result = new EnumMap<ResultMetadataType,Object>(ResultMetadataType.class);
Map<ResultMetadataType,Object> result = new EnumMap<>(ResultMetadataType.class);
result.put(ResultMetadataType.SUGGESTED_PRICE, value);
return result;
}

View file

@ -57,8 +57,8 @@ public final class RSS14Reader extends AbstractRSSReader {
private final List<Pair> possibleRightPairs;
public RSS14Reader() {
possibleLeftPairs = new ArrayList<Pair>();
possibleRightPairs = new ArrayList<Pair>();
possibleLeftPairs = new ArrayList<>();
possibleRightPairs = new ArrayList<>();
}
@Override

View file

@ -30,7 +30,7 @@ final class ExpandedRow {
private final boolean wasReversed;
ExpandedRow(List<ExpandedPair> pairs, int rowNumber, boolean wasReversed) {
this.pairs = new ArrayList<ExpandedPair>(pairs);
this.pairs = new ArrayList<>(pairs);
this.rowNumber = rowNumber;
this.wasReversed = wasReversed;
}

View file

@ -114,8 +114,8 @@ public final class RSSExpandedReader extends AbstractRSSReader {
private static final int MAX_PAIRS = 11;
private final List<ExpandedPair> pairs = new ArrayList<ExpandedPair>(MAX_PAIRS);
private final List<ExpandedRow> rows = new ArrayList<ExpandedRow>();
private final List<ExpandedPair> pairs = new ArrayList<>(MAX_PAIRS);
private final List<ExpandedRow> rows = new ArrayList<>();
private final int [] startEnd = new int[2];
//private final int [] currentSequence = new int[LONGEST_SEQUENCE_SIZE];
private boolean startFromEven = false;
@ -234,7 +234,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
return this.pairs;
}
List<ExpandedRow> rs = new ArrayList<ExpandedRow>();
List<ExpandedRow> rs = new ArrayList<>();
rs.addAll(collectedRows);
rs.add(row);
try {

View file

@ -74,16 +74,14 @@ public final class PDF417Reader implements Reader, MultipleBarcodeReader {
public Result[] decodeMultiple(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
try {
return decode(image, hints, true);
} catch (FormatException ignored) {
throw NotFoundException.getNotFoundInstance();
} catch (ChecksumException ignored) {
} catch (FormatException | ChecksumException ignored) {
throw NotFoundException.getNotFoundInstance();
}
}
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple)
throws NotFoundException, FormatException, ChecksumException {
List<Result> results = new ArrayList<Result>();
List<Result> results = new ArrayList<>();
PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple);
for (ResultPoint[] points : detectorResult.getPoints()) {
DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5],

View file

@ -28,7 +28,7 @@ import java.util.Map.Entry;
* @author Guenther Grau
*/
final class BarcodeValue {
private final Map<Integer,Integer> values = new HashMap<Integer,Integer>();
private final Map<Integer,Integer> values = new HashMap<>();
/**
* Add an occurrence of a value
@ -48,7 +48,7 @@ final class BarcodeValue {
*/
int[] getValue() {
int maxConfidence = -1;
Collection<Integer> result = new ArrayList<Integer>();
Collection<Integer> result = new ArrayList<>();
for (Entry<Integer,Integer> entry : values.entrySet()) {
if (entry.getValue() > maxConfidence) {
maxConfidence = entry.getValue();

View file

@ -249,10 +249,10 @@ public final class PDF417ScanningDecoder {
ChecksumException, NotFoundException {
BarcodeValue[][] barcodeMatrix = createBarcodeMatrix(detectionResult);
adjustCodewordCount(detectionResult, barcodeMatrix);
Collection<Integer> erasures = new ArrayList<Integer>();
Collection<Integer> erasures = new ArrayList<>();
int[] codewords = new int[detectionResult.getBarcodeRowCount() * detectionResult.getBarcodeColumnCount()];
List<int[]> ambiguousIndexValuesList = new ArrayList<int[]>();
List<Integer> ambiguousIndexesList = new ArrayList<Integer>();
List<int[]> ambiguousIndexValuesList = new ArrayList<>();
List<Integer> ambiguousIndexesList = new ArrayList<>();
for (int row = 0; row < detectionResult.getBarcodeRowCount(); row++) {
for (int column = 0; column < detectionResult.getBarcodeColumnCount(); column++) {
int[] values = barcodeMatrix[row][column + 1].getValue();

View file

@ -96,7 +96,7 @@ public final class Detector {
* @return List of ResultPoint arrays containing the coordinates of found barcodes
*/
private static List<ResultPoint[]> detect(boolean multiple, BitMatrix bitMatrix) {
List<ResultPoint[]> barcodeCoordinates = new ArrayList<ResultPoint[]>();
List<ResultPoint[]> barcodeCoordinates = new ArrayList<>();
int row = 0;
int column = 0;
boolean foundBarcodeInRow = false;

View file

@ -59,7 +59,7 @@ final class DecodedBitStreamParser {
Map<DecodeHintType,?> hints) throws FormatException {
BitSource bits = new BitSource(bytes);
StringBuilder result = new StringBuilder(50);
List<byte[]> byteSegments = new ArrayList<byte[]>(1);
List<byte[]> byteSegments = new ArrayList<>(1);
try {
CharacterSetECI currentCharacterSetECI = null;
boolean fc1InEffect = false;

View file

@ -125,17 +125,7 @@ public final class Decoder {
return result;
} catch (FormatException e) {
// Throw the exception from the original reading
if (fe != null) {
throw fe;
}
if (ce != null) {
throw ce;
}
throw e;
} catch (ChecksumException e) {
} catch (FormatException | ChecksumException e) {
// Throw the exception from the original reading
if (fe != null) {
throw fe;

View file

@ -67,7 +67,7 @@ final class AlignmentPatternFinder {
float moduleSize,
ResultPointCallback resultPointCallback) {
this.image = image;
this.possibleCenters = new ArrayList<AlignmentPattern>(5);
this.possibleCenters = new ArrayList<>(5);
this.startX = startX;
this.startY = startY;
this.width = width;

View file

@ -61,7 +61,7 @@ public class FinderPatternFinder {
public FinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) {
this.image = image;
this.possibleCenters = new ArrayList<FinderPattern>();
this.possibleCenters = new ArrayList<>();
this.crossCheckStateCount = new int[5];
this.resultPointCallback = resultPointCallback;
}

View file

@ -376,7 +376,7 @@ public final class Encoder {
int maxNumEcBytes = 0;
// Since, we know the number of reedsolmon blocks, we can initialize the vector with the number.
Collection<BlockPair> blocks = new ArrayList<BlockPair>(numRSBlocks);
Collection<BlockPair> blocks = new ArrayList<>(numRSBlocks);
for (int i = 0; i < numRSBlocks; ++i) {
int[] numDataBytesInBlock = new int[1];

View file

@ -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);
Collection<Integer> errors = new TreeSet<Integer>();
Collection<Integer> errors = new TreeSet<>();
while (errors.size() < 3) {
// Quick and dirty way of getting three distinct integers between 1 and n.
errors.add(random.nextInt(orientationPoints.size()));
@ -176,7 +176,7 @@ public final class DetectorTest extends Assert {
private static List<Point> getOrientationPoints(AztecCode code) {
int center = code.getMatrix().getWidth() / 2;
int offset = code.isCompact() ? 5 : 7;
List<Point> result = new ArrayList<Point>();
List<Point> result = new ArrayList<>();
for (int xSign = -1; xSign <= 1; xSign += 2) {
for (int ySign = -1; ySign <= 1; ySign += 2) {
result.add(new Point(center + xSign * offset, center + ySign * offset));

View file

@ -469,7 +469,7 @@ public final class EncoderTest extends Assert {
// 1. Perform an encode-decode round-trip because it can be lossy.
// 2. Aztec Decoder currently always decodes the data with a LATIN-1 charset:
String expectedData = new String(data.getBytes(Charset.forName(charset)), LATIN_1);
Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, charset);
hints.put(EncodeHintType.ERROR_CORRECTION, eccPercent);
AztecWriter writer = new AztecWriter();

View file

@ -42,7 +42,7 @@ public final class ExpandedProductParsedResultTestCase extends Assert {
@Test
public void test_RSSExpanded() {
Map<String,String> uncommonAIs = new HashMap<String,String>();
Map<String,String> uncommonAIs = new HashMap<>();
uncommonAIs.put("123", "544654");
Result result =
new Result("(01)66546(13)001205(3932)4455(3102)6544(123)544654", null, null, BarcodeFormat.RSS_EXPANDED);

View file

@ -86,7 +86,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
this.testBase = testBase;
this.barcodeReader = barcodeReader;
this.expectedFormat = expectedFormat;
testResults = new ArrayList<TestResult>();
testResults = new ArrayList<>();
System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n");
}
@ -261,7 +261,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
String suffix = String.format(" (%srotation: %d)", tryHarder ? "try harder, " : "", (int) rotation);
Map<DecodeHintType,Object> hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
if (tryHarder) {
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
}

View file

@ -68,7 +68,7 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
// Use the multiformat reader to evaluate all decoders in the system.
protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) {
super(testBasePathSuffix, new MultiFormatReader(), null);
testResults = new ArrayList<TestResult>();
testResults = new ArrayList<>();
}
protected final void addTest(int falsePositivesAllowed, float rotation) {
@ -143,7 +143,7 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
}
// Try "try harder" getMode
Map<DecodeHintType,Object> hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
try {
result = getReader().decode(bitmap, hints);

View file

@ -35,7 +35,7 @@ public final class DataMatrixWriterTestCase extends Assert {
@Test
public void testDataMatrixImageWriter() {
Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);
int bigEnough = 64;
@ -49,7 +49,7 @@ public final class DataMatrixWriterTestCase extends Assert {
@Test
public void testDataMatrixWriter() {
Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType,Object>(EncodeHintType.class);
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.DATA_MATRIX_SHAPE, SymbolShapeHint.FORCE_SQUARE);
int bigEnough = 14;

View file

@ -56,7 +56,7 @@ public final class BitArrayBuilderTest extends Assert {
}
private static BitArray buildBitArray(int[][] pairValues) {
List<ExpandedPair> pairs = new ArrayList<ExpandedPair>();
List<ExpandedPair> pairs = new ArrayList<>();
for(int i = 0; i < pairValues.length; ++i){
int [] pair = pairValues[i];

View file

@ -64,7 +64,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null);
List<ExpandedPair> previousPairs = new ArrayList<ExpandedPair>();
List<ExpandedPair> previousPairs = new ArrayList<>();
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
@ -108,7 +108,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null);
List<ExpandedPair> previousPairs = new ArrayList<ExpandedPair>();
List<ExpandedPair> previousPairs = new ArrayList<>();
RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
ExpandedPair pair1 = rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);

View file

@ -63,7 +63,7 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
private static final String TEST_BASE_PATH_SUFFIX = "src/test/resources/blackbox/pdf417-4";
private final PDF417Reader barcodeReader = new PDF417Reader();
private final List<TestResult> testResults = new ArrayList<TestResult>();
private final List<TestResult> testResults = new ArrayList<>();
private File testBase;
public PDF417BlackBox4TestCase() {
@ -109,7 +109,7 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
}
for (int x = 0; x < testCount; x++) {
List<Result> results = new ArrayList<Result>();
List<Result> results = new ArrayList<>();
for (File imageFile : testImageGroup.getValue()) {
BufferedImage image = ImageIO.read(imageFile);
float rotation = testResults.get(x).getRotation();
@ -211,7 +211,7 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
}
private Result[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderException {
Map<DecodeHintType,Object> hints = new EnumMap<DecodeHintType,Object>(DecodeHintType.class);
Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
if (tryHarder) {
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
}
@ -220,13 +220,13 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
}
private Map<String,List<File>> getImageFileLists() {
Map<String,List<File>> result = new HashMap<String,List<File>>();
Map<String,List<File>> result = new HashMap<>();
for (File file : getImageFiles()) {
String testImageFileName = file.getName();
String fileBaseName = testImageFileName.substring(0, testImageFileName.indexOf('-'));
List<File> files = result.get(fileBaseName);
if (files == null) {
files = new ArrayList<File>();
files = new ArrayList<>();
result.put(fileBaseName, files);
}
files.add(file);

View file

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

View file

@ -129,7 +129,7 @@ public final class EncoderTestCase extends Assert {
@Test
public void testSimpleUTF8ECI() throws WriterException {
Map<EncodeHintType,Object> hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
QRCode qrCode = Encoder.encode("hello", ErrorCorrectionLevel.H, hints);
String expected =

View file

@ -120,19 +120,6 @@
<version>3.0.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
<name>ZXing Google Glass Mirror API app</name>
<description>Experimental Barcode Scanner app for Google Glass Mirror API</description>

View file

@ -34,19 +34,6 @@
<artifactId>zxing-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
</plugins>
</build>
<name>ZXing Java SE extensions</name>
<description>Java SE-specific extensions to core ZXing library</description>

View file

@ -105,8 +105,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>6</source>
<target>6</target>
<source>7</source>
<target>7</target>
<compilerArgs>
<arg>-Xlint:all</arg>
</compilerArgs>

View file

@ -48,14 +48,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>

View file

@ -67,14 +67,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>7</source>
<target>7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>