mirror of
https://github.com/zxing/zxing.git
synced 2025-01-12 11:47:26 -08:00
A bunch of code style related changes
git-svn-id: https://zxing.googlecode.com/svn/trunk@1795 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
87887ab18c
commit
df65c5b83e
|
@ -39,7 +39,7 @@ public final class IntentResult {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return name of format, like "QR_CODE", "UPC_A". See <code>BarcodeFormat</code> for more format names.
|
||||
* @return name of format, like "QR_CODE", "UPC_A". See {@code BarcodeFormat} for more format names.
|
||||
*/
|
||||
public String getFormatName() {
|
||||
return formatName;
|
||||
|
|
|
@ -422,8 +422,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
paint.setStrokeWidth(4.0f);
|
||||
drawLine(canvas, paint, points[0], points[1]);
|
||||
} else if (points.length == 4 &&
|
||||
(rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A)) ||
|
||||
(rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) {
|
||||
(rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A) ||
|
||||
rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) {
|
||||
// Hacky special case -- draw two lines, for the barcode and metadata
|
||||
drawLine(canvas, paint, points[0], points[1]);
|
||||
drawLine(canvas, paint, points[2], points[3]);
|
||||
|
@ -590,7 +590,7 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
|
|||
Intent intent = new Intent(this, HelpActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
|
||||
// Show the default page on a clean install, and the what's new page on an upgrade.
|
||||
String page = (lastVersion == 0) ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE;
|
||||
String page = lastVersion == 0 ? HelpActivity.DEFAULT_PAGE : HelpActivity.WHATS_NEW_PAGE;
|
||||
intent.putExtra(HelpActivity.REQUESTED_PAGE_KEY, page);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
|
|
|
@ -18,7 +18,6 @@ package com.google.zxing.client.android.book;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
@ -121,7 +120,7 @@ public final class SearchBookContentsActivity extends Activity {
|
|||
CookieManager.getInstance().removeExpiredCookie();
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) {
|
||||
if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public final class CalendarResultHandler extends ResultHandler {
|
|||
long milliseconds = date.getTime();
|
||||
if (when.length() == 16 && when.charAt(15) == 'Z') {
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
int offset = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET));
|
||||
int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
|
||||
milliseconds += offset;
|
||||
}
|
||||
ParsedResult.maybeAppend(DateFormat.getDateTimeInstance().format(milliseconds), result);
|
||||
|
|
|
@ -247,13 +247,13 @@ public abstract class ResultHandler {
|
|||
intent.setType(Contacts.People.CONTENT_ITEM_TYPE);
|
||||
putExtra(intent, Contacts.Intents.Insert.NAME, names != null ? names[0] : null);
|
||||
|
||||
int phoneCount = Math.min((phoneNumbers != null) ? phoneNumbers.length : 0,
|
||||
int phoneCount = Math.min(phoneNumbers != null ? phoneNumbers.length : 0,
|
||||
Contents.PHONE_KEYS.length);
|
||||
for (int x = 0; x < phoneCount; x++) {
|
||||
putExtra(intent, Contents.PHONE_KEYS[x], phoneNumbers[x]);
|
||||
}
|
||||
|
||||
int emailCount = Math.min((emails != null) ? emails.length : 0, Contents.EMAIL_KEYS.length);
|
||||
int emailCount = Math.min(emails != null ? emails.length : 0, Contents.EMAIL_KEYS.length);
|
||||
for (int x = 0; x < emailCount; x++) {
|
||||
putExtra(intent, Contents.EMAIL_KEYS[x], emails[x]);
|
||||
}
|
||||
|
|
|
@ -36,8 +36,9 @@ import android.widget.TextView;
|
|||
* @author dswitkin@google.com (Daniel Switkin)
|
||||
*/
|
||||
public final class BookmarkAdapter extends BaseAdapter {
|
||||
private Context context;
|
||||
private Cursor cursor;
|
||||
|
||||
private final Context context;
|
||||
private final Cursor cursor;
|
||||
|
||||
public BookmarkAdapter(Context context, Cursor cursor) {
|
||||
this.context = context;
|
||||
|
|
|
@ -199,7 +199,7 @@ public final class WifiActivity extends Activity {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (intent == null || (!intent.getAction().equals(Intents.WifiConnect.ACTION))) {
|
||||
if (intent == null || !intent.getAction().equals(Intents.WifiConnect.ACTION)) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
@ -211,11 +211,11 @@ public final class WifiActivity extends Activity {
|
|||
statusView = (TextView) findViewById(R.id.networkStatus);
|
||||
|
||||
NetworkType networkT;
|
||||
if (networkType.equals("WPA")) {
|
||||
if ("WPA".equals(networkType)) {
|
||||
networkT = NetworkType.NETWORK_WPA;
|
||||
} else if (networkType.equals("WEP")) {
|
||||
} else if ("WEP".equals(networkType)) {
|
||||
networkT = NetworkType.NETWORK_WEP;
|
||||
} else if (networkType.equals("nopass")) {
|
||||
} else if ("nopass".equals(networkType)) {
|
||||
networkT = NetworkType.NETWORK_NOPASS;
|
||||
} else {
|
||||
doError(R.string.wifi_type_incorrect);
|
||||
|
|
|
@ -73,7 +73,7 @@ final class WifiReceiver extends BroadcastReceiver {
|
|||
delayKill.run();
|
||||
}
|
||||
if (state == NetworkInfo.State.DISCONNECTED){
|
||||
Log.d(TAG, "Got state: " + state + " for ssid: " + ssid);
|
||||
Log.d(TAG, "Got state Disconnected for ssid: " + ssid);
|
||||
parent.gotError();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ final class CameraManager {
|
|||
private int autoFocusMessage;
|
||||
private boolean initialized;
|
||||
private boolean previewing;
|
||||
private int previewFormat;
|
||||
private String previewFormatString;
|
||||
private final boolean useOneShotPreviewCallback;
|
||||
|
||||
/**
|
||||
|
@ -263,8 +261,8 @@ final class CameraManager {
|
|||
Camera.Parameters parameters = camera.getParameters();
|
||||
Camera.Size size = parameters.getPreviewSize();
|
||||
Log.v(TAG, "Default preview size: " + size.width + ", " + size.height);
|
||||
previewFormat = parameters.getPreviewFormat();
|
||||
previewFormatString = parameters.get("preview-format");
|
||||
int previewFormat = parameters.getPreviewFormat();
|
||||
String previewFormatString = parameters.get("preview-format");
|
||||
Log.v(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
|
||||
|
||||
// Ensure that the camera resolution is a multiple of 8, as the screen may not be.
|
||||
|
|
|
@ -66,6 +66,7 @@ public final class RGBLuminanceSource extends LuminanceSource {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getRow(int y, byte[] row) {
|
||||
if (y < 0 || y >= getHeight()) {
|
||||
throw new IllegalArgumentException("Requested row is outside the image: " + y);
|
||||
|
@ -81,6 +82,7 @@ public final class RGBLuminanceSource extends LuminanceSource {
|
|||
|
||||
// Since this class does not support cropping, the underlying byte array already contains
|
||||
// exactly what the caller is asking for, so give it to them without a copy.
|
||||
@Override
|
||||
public byte[] getMatrix() {
|
||||
return luminances;
|
||||
}
|
||||
|
|
|
@ -65,23 +65,22 @@ public final class ZXingTestActivity extends Activity {
|
|||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case ABOUT_ID:
|
||||
int versionCode = 0;
|
||||
String versionName = "unknown";
|
||||
try {
|
||||
PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0);
|
||||
versionCode = info.versionCode;
|
||||
versionName = info.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(getString(R.string.app_name) + " " + versionName + " (" + versionCode +
|
||||
")");
|
||||
builder.setMessage(getString(R.string.about_message));
|
||||
builder.setPositiveButton(R.string.ok_button, null);
|
||||
builder.show();
|
||||
break;
|
||||
if (item.getItemId() == ABOUT_ID) {
|
||||
int versionCode = 0;
|
||||
String versionName = "unknown";
|
||||
try {
|
||||
PackageInfo info = getPackageManager().getPackageInfo(PACKAGE_NAME, 0);
|
||||
versionCode = info.versionCode;
|
||||
versionName = info.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(
|
||||
getString(R.string.app_name) + ' ' + versionName + " (" + versionCode + ')');
|
||||
builder.setMessage(getString(R.string.about_message));
|
||||
builder.setPositiveButton(R.string.ok_button, null);
|
||||
builder.show();
|
||||
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
@ -215,7 +214,7 @@ public final class ZXingTestActivity extends Activity {
|
|||
}
|
||||
};
|
||||
|
||||
private void showDialog(int title, String message) {
|
||||
private void showDialog(int title, CharSequence message) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(title);
|
||||
builder.setMessage(message);
|
||||
|
|
|
@ -73,7 +73,9 @@ public class ResultPoint {
|
|||
float oneTwoDistance = distance(patterns[1], patterns[2]);
|
||||
float zeroTwoDistance = distance(patterns[0], patterns[2]);
|
||||
|
||||
ResultPoint pointA, pointB, pointC;
|
||||
ResultPoint pointA;
|
||||
ResultPoint pointB;
|
||||
ResultPoint pointC;
|
||||
// Assume one closest to other two is B; A and C will just be guesses at first
|
||||
if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
|
||||
pointB = patterns[0];
|
||||
|
|
|
@ -147,7 +147,7 @@ public final class Decoder {
|
|||
code = readCode(correctedBits, startIndex, 8);
|
||||
startIndex += 8;
|
||||
|
||||
result.append((char)(code));
|
||||
result.append((char) code);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -152,7 +152,7 @@ public final class Detector {
|
|||
|
||||
/**
|
||||
*
|
||||
* <p> Gets the aztec code corners from the bull's eye corners and the parameters </p>
|
||||
* <p>Gets the Aztec code corners from the bull's eye corners and the parameters </p>
|
||||
*
|
||||
* @param bullEyeCornerPoints the array of bull's eye corners
|
||||
* @return the array of aztec code corners
|
||||
|
@ -160,7 +160,8 @@ public final class Detector {
|
|||
*/
|
||||
private ResultPoint[] getMatrixCornerPoints(Point[] bullEyeCornerPoints) throws NotFoundException {
|
||||
|
||||
float ratio = (2*nbLayers+(nbLayers>4?1:0)+(nbLayers-4)/8)/(2.0f*nbCenterLayers);
|
||||
float ratio = (2 * nbLayers + (nbLayers > 4 ? 1 : 0) + (nbLayers - 4) / 8)
|
||||
/ (2.0f * nbCenterLayers);
|
||||
|
||||
int dx = bullEyeCornerPoints[0].x-bullEyeCornerPoints[2].x;
|
||||
dx+=dx>0?1:-1;
|
||||
|
@ -609,7 +610,7 @@ public final class Detector {
|
|||
}
|
||||
|
||||
private boolean isValid(int x, int y) {
|
||||
return (x >= 0 && x < image.width && y > 0 && y < image.height);
|
||||
return x >= 0 && x < image.width && y > 0 && y < image.height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ final class ExpandedProductResultParser extends ResultParser {
|
|||
// product barcodes with complementary data.
|
||||
public static ExpandedProductParsedResult parse(Result result) {
|
||||
BarcodeFormat format = result.getBarcodeFormat();
|
||||
if (!(BarcodeFormat.RSS_EXPANDED.equals(format))) {
|
||||
if (!BarcodeFormat.RSS_EXPANDED.equals(format)) {
|
||||
// ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,9 @@ final class GeoResultParser extends ResultParser {
|
|||
return null;
|
||||
}
|
||||
int longitudeEnd = geoURIWithoutQuery.indexOf(',', latitudeEnd + 1);
|
||||
double latitude, longitude, altitude;
|
||||
double latitude;
|
||||
double longitude;
|
||||
double altitude;
|
||||
try {
|
||||
latitude = Double.parseDouble(geoURIWithoutQuery.substring(0, latitudeEnd));
|
||||
if (latitude > 90.0 || latitude < -90.0) {
|
||||
|
|
|
@ -146,26 +146,30 @@ public abstract class ResultParser {
|
|||
|
||||
for (int i = first; i < max; i++) {
|
||||
char c = escapedArray[i];
|
||||
if (c == '+') {
|
||||
// + is translated directly into a space
|
||||
unescaped.append(' ');
|
||||
} else if (c == '%') {
|
||||
// Are there even two more chars? if not we will just copy the escaped sequence and be done
|
||||
if (i >= max - 2) {
|
||||
unescaped.append('%'); // append that % and move on
|
||||
} else {
|
||||
int firstDigitValue = parseHexDigit(escapedArray[++i]);
|
||||
int secondDigitValue = parseHexDigit(escapedArray[++i]);
|
||||
if (firstDigitValue < 0 || secondDigitValue < 0) {
|
||||
// bad digit, just move on
|
||||
unescaped.append('%');
|
||||
unescaped.append(escapedArray[i-1]);
|
||||
unescaped.append(escapedArray[i]);
|
||||
switch (c) {
|
||||
case '+':
|
||||
// + is translated directly into a space
|
||||
unescaped.append(' ');
|
||||
break;
|
||||
case '%':
|
||||
// Are there even two more chars? if not we will just copy the escaped sequence and be done
|
||||
if (i >= max - 2) {
|
||||
unescaped.append('%'); // append that % and move on
|
||||
} else {
|
||||
int firstDigitValue = parseHexDigit(escapedArray[++i]);
|
||||
int secondDigitValue = parseHexDigit(escapedArray[++i]);
|
||||
if (firstDigitValue < 0 || secondDigitValue < 0) {
|
||||
// bad digit, just move on
|
||||
unescaped.append('%');
|
||||
unescaped.append(escapedArray[i - 1]);
|
||||
unescaped.append(escapedArray[i]);
|
||||
}
|
||||
unescaped.append((char) ((firstDigitValue << 4) + secondDigitValue));
|
||||
}
|
||||
unescaped.append((char) ((firstDigitValue << 4) + secondDigitValue));
|
||||
}
|
||||
} else {
|
||||
unescaped.append(c);
|
||||
break;
|
||||
default:
|
||||
unescaped.append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return unescaped.toString();
|
||||
|
|
|
@ -106,11 +106,11 @@ final class VCardResultParser extends ResultParser {
|
|||
if (equals >= 0) {
|
||||
String key = metadata.substring(0, equals);
|
||||
String value = metadata.substring(equals+1);
|
||||
if (key.equalsIgnoreCase("ENCODING")) {
|
||||
if (value.equalsIgnoreCase("QUOTED-PRINTABLE")) {
|
||||
if ("ENCODING".equalsIgnoreCase(key)) {
|
||||
if ("QUOTED-PRINTABLE".equalsIgnoreCase(value)) {
|
||||
quotedPrintable = true;
|
||||
}
|
||||
} else if (key.equalsIgnoreCase("CHARSET")) {
|
||||
} else if ("CHARSET".equalsIgnoreCase(key)) {
|
||||
quotedPrintableCharset = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,12 @@ final class VEventResultParser extends ResultParser {
|
|||
longitude = Double.NaN;
|
||||
} else {
|
||||
int semicolon = geoString.indexOf(';');
|
||||
latitude = Double.parseDouble(geoString.substring(0, semicolon));
|
||||
longitude = Double.parseDouble(geoString.substring(semicolon + 1));
|
||||
try {
|
||||
latitude = Double.parseDouble(geoString.substring(0, semicolon));
|
||||
longitude = Double.parseDouble(geoString.substring(semicolon + 1));
|
||||
} catch (NumberFormatException nfe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -81,7 +81,7 @@ public final class CharacterSetECI extends ECI {
|
|||
|
||||
/**
|
||||
* @param value character set ECI value
|
||||
* @return {@link CharacterSetECI} representing ECI of given value, or null if it is legal but
|
||||
* @return CharacterSetECI representing ECI of given value, or null if it is legal but
|
||||
* unsupported
|
||||
* @throws IllegalArgumentException if ECI value is invalid
|
||||
*/
|
||||
|
@ -97,7 +97,7 @@ public final class CharacterSetECI extends ECI {
|
|||
|
||||
/**
|
||||
* @param name character set ECI encoding name
|
||||
* @return {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal
|
||||
* @return CharacterSetECI representing ECI for character encoding, or null if it is legal
|
||||
* but unsupported
|
||||
*/
|
||||
public static CharacterSetECI getCharacterSetECIByName(String name) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class ECI {
|
|||
|
||||
/**
|
||||
* @param value ECI value
|
||||
* @return {@link ECI} representing ECI of given value, or null if it is legal but unsupported
|
||||
* @return ECI representing ECI of given value, or null if it is legal but unsupported
|
||||
* @throws IllegalArgumentException if ECI value is invalid
|
||||
*/
|
||||
public static ECI getECIByValue(int value) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class GridSampler {
|
|||
private static GridSampler gridSampler = new DefaultGridSampler();
|
||||
|
||||
/**
|
||||
* Sets the implementation of {@link GridSampler} used by the library. One global
|
||||
* Sets the implementation of GridSampler used by the library. One global
|
||||
* instance is stored, which may sound problematic. But, the implementation provided
|
||||
* ought to be appropriate for the entire platform, and all uses of this library
|
||||
* in the whole lifetime of the JVM. For instance, an Android activity can swap in
|
||||
|
@ -52,7 +52,7 @@ public abstract class GridSampler {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the current implementation of {@link GridSampler}
|
||||
* @return the current implementation of GridSampler
|
||||
*/
|
||||
public static GridSampler getInstance() {
|
||||
return gridSampler;
|
||||
|
|
|
@ -102,10 +102,10 @@ public final class HybridBinarizer extends GlobalHistogramBinarizer {
|
|||
if ((xoffset + 8) >= width) {
|
||||
xoffset = width - 8;
|
||||
}
|
||||
int left = (x > 1) ? x : 2;
|
||||
left = (left < subWidth - 2) ? left : subWidth - 3;
|
||||
int top = (y > 1) ? y : 2;
|
||||
top = (top < subHeight - 2) ? top : subHeight - 3;
|
||||
int left = x > 1 ? x : 2;
|
||||
left = left < subWidth - 2 ? left : subWidth - 3;
|
||||
int top = y > 1 ? y : 2;
|
||||
top = top < subHeight - 2 ? top : subHeight - 3;
|
||||
int sum = 0;
|
||||
for (int z = -2; z <= 2; z++) {
|
||||
int[] blackRow = blackPoints[top + z];
|
||||
|
|
|
@ -132,7 +132,7 @@ public final class StringUtils {
|
|||
((value >= 0xF0 && value <= 0xFF) || value == 0x80 || value == 0xA0)) {
|
||||
canBeShiftJIS = false;
|
||||
}
|
||||
if (((value >= 0x81 && value <= 0x9F) || (value >= 0xE0 && value <= 0xEF))) {
|
||||
if ((value >= 0x81 && value <= 0x9F) || (value >= 0xE0 && value <= 0xEF)) {
|
||||
// These start double-byte characters in Shift_JIS. Let's see if it's followed by a valid
|
||||
// second byte.
|
||||
if (lastWasPossibleDoubleByteStart) {
|
||||
|
|
|
@ -177,7 +177,7 @@ public final class ReedSolomonDecoder {
|
|||
// Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug.
|
||||
// Below is a funny-looking workaround from Steven Parkes
|
||||
int term = field.multiply(errorLocations[j], xiInverse);
|
||||
int termPlus1 = ((term & 0x1) == 0) ? (term | 1) : (term & ~1);
|
||||
int termPlus1 = (term & 0x1) == 0 ? term | 1 : term & ~1;
|
||||
denominator = field.multiply(denominator, termPlus1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ final class DataBlock {
|
|||
*
|
||||
* @param rawCodewords bytes as read directly from the Data Matrix Code
|
||||
* @param version version of the Data Matrix Code
|
||||
* @return {@link DataBlock}s containing original bytes, "de-interleaved" from representation in the
|
||||
* @return DataBlocks containing original bytes, "de-interleaved" from representation in the
|
||||
* Data Matrix Code
|
||||
*/
|
||||
static DataBlock[] getDataBlocks(byte[] rawCodewords,
|
||||
|
@ -95,7 +95,7 @@ final class DataBlock {
|
|||
int max = result[0].codewords.length;
|
||||
for (int i = longerBlocksNumDataCodewords; i < max; i++) {
|
||||
for (int j = 0; j < numResultBlocks; j++) {
|
||||
int iOffset = (specialVersion && j > 7) ? i - 1 : i;
|
||||
int iOffset = specialVersion && j > 7 ? i - 1 : i;
|
||||
result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public final class Version {
|
|||
*
|
||||
* @param numRows Number of rows in modules
|
||||
* @param numColumns Number of columns in modules
|
||||
* @return {@link Version} for a Data Matrix Code of those dimensions
|
||||
* @return Version for a Data Matrix Code of those dimensions
|
||||
* @throws FormatException if dimensions do correspond to a valid Data Matrix size
|
||||
*/
|
||||
public static Version getVersionForDimensions(int numRows, int numColumns) throws FormatException {
|
||||
|
|
|
@ -302,7 +302,7 @@ public final class Detector {
|
|||
}
|
||||
|
||||
private boolean isValid(ResultPoint p) {
|
||||
return (p.getX() >= 0 && p.getX() < image.width && p.getY() > 0 && p.getY() < image.height);
|
||||
return p.getX() >= 0 && p.getX() < image.width && p.getY() > 0 && p.getY() < image.height;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -157,7 +157,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
|
||||
// Compare the expected module sizes; if they are really off, skip
|
||||
float vModSize12 = (p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize()) /
|
||||
(Math.min(p1.getEstimatedModuleSize(), p2.getEstimatedModuleSize()));
|
||||
Math.min(p1.getEstimatedModuleSize(), p2.getEstimatedModuleSize());
|
||||
float vModSize12A = Math.abs(p1.getEstimatedModuleSize() - p2.getEstimatedModuleSize());
|
||||
if (vModSize12A > DIFF_MODSIZE_CUTOFF && vModSize12 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
|
||||
// break, since elements are ordered by the module size deviation there cannot be
|
||||
|
@ -173,7 +173,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
|
||||
// Compare the expected module sizes; if they are really off, skip
|
||||
float vModSize23 = (p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize()) /
|
||||
(Math.min(p2.getEstimatedModuleSize(), p3.getEstimatedModuleSize()));
|
||||
Math.min(p2.getEstimatedModuleSize(), p3.getEstimatedModuleSize());
|
||||
float vModSize23A = Math.abs(p2.getEstimatedModuleSize() - p3.getEstimatedModuleSize());
|
||||
if (vModSize23A > DIFF_MODSIZE_CUTOFF && vModSize23 >= DIFF_MODSIZE_CUTOFF_PERCENT) {
|
||||
// break, since elements are ordered by the module size deviation there cannot be
|
||||
|
@ -191,14 +191,14 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
float dB = ResultPoint.distance(info.getTopLeft(), info.getTopRight());
|
||||
|
||||
// Check the sizes
|
||||
float estimatedModuleCount = ((dA + dB) / p1.getEstimatedModuleSize()) / 2;
|
||||
float estimatedModuleCount = (dA + dB) / (p1.getEstimatedModuleSize() * 2.0f);
|
||||
if (estimatedModuleCount > MAX_MODULE_COUNT_PER_EDGE ||
|
||||
estimatedModuleCount < MIN_MODULE_COUNT_PER_EDGE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calculate the difference of the edge lengths in percent
|
||||
float vABBC = Math.abs(((dA - dB) / Math.min(dA, dB)));
|
||||
float vABBC = Math.abs((dA - dB) / Math.min(dA, dB));
|
||||
if (vABBC >= 0.1f) {
|
||||
continue;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ final class MultiFinderPatternFinder extends FinderPatternFinder {
|
|||
// Calculate the diagonal length by assuming a 90° angle at topleft
|
||||
float dCpy = (float) Math.sqrt(dA * dA + dB * dB);
|
||||
// Compare to the real distance in %
|
||||
float vPyC = Math.abs(((dC - dCpy) / Math.min(dC, dCpy)));
|
||||
float vPyC = Math.abs((dC - dCpy) / Math.min(dC, dCpy));
|
||||
|
||||
if (vPyC >= 0.1f) {
|
||||
continue;
|
||||
|
|
|
@ -105,7 +105,7 @@ public final class CodaBarReader extends OneDReader {
|
|||
int whiteSpaceAfterEnd = nextStart - lastStart - lastPatternSize;
|
||||
// If 50% of last pattern size, following last pattern, is not whitespace, fail
|
||||
// (but if it's whitespace to the very end of the image, that's OK)
|
||||
if ((nextStart) != end && (whiteSpaceAfterEnd / 2 < lastPatternSize)) {
|
||||
if (nextStart != end && (whiteSpaceAfterEnd / 2 < lastPatternSize)) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public final class Code39Writer extends UPCEANWriter {
|
|||
private static void toIntArray(int a, int[] toReturn) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
int temp = a & (1 << i);
|
||||
toReturn[i] = (temp == 0) ? 1 : 2;
|
||||
toReturn[i] = temp == 0 ? 1 : 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
|||
int checkDigit = 0;
|
||||
for (int i = 0; i < 13; i++) {
|
||||
int digit = buffer.charAt(i) - '0';
|
||||
checkDigit += (((i & 0x01) == 0) ? 3 * digit : digit);
|
||||
checkDigit += (i & 0x01) == 0 ? 3 * digit : digit;
|
||||
}
|
||||
checkDigit = 10 - (checkDigit % 10);
|
||||
if (checkDigit == 10) {
|
||||
|
|
|
@ -95,11 +95,12 @@ public final class RSSUtils {
|
|||
}
|
||||
n -= elmWidth;
|
||||
}
|
||||
return (val);
|
||||
return val;
|
||||
}
|
||||
|
||||
static int combins(int n, int r) {
|
||||
int maxDenom, minDenom;
|
||||
int maxDenom;
|
||||
int minDenom;
|
||||
if (n - r > r) {
|
||||
minDenom = r;
|
||||
maxDenom = n - r;
|
||||
|
@ -120,7 +121,7 @@ public final class RSSUtils {
|
|||
val /= j;
|
||||
j++;
|
||||
}
|
||||
return (val);
|
||||
return val;
|
||||
}
|
||||
|
||||
static int[] elements(int[] eDist, int N, int K) {
|
||||
|
|
|
@ -41,7 +41,7 @@ final class BitArrayBuilder {
|
|||
|
||||
static BitArray buildBitArray(Vector pairs) {
|
||||
int charNumber = (pairs.size() << 1) - 1;
|
||||
if ((((ExpandedPair)pairs.lastElement()).getRightChar()) == null) {
|
||||
if (((ExpandedPair) pairs.lastElement()).getRightChar() == null) {
|
||||
charNumber -= 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ public final class RSSExpandedReader extends AbstractRSSReader{
|
|||
} else if (previousPairs.isEmpty()) {
|
||||
rowOffset = 0;
|
||||
} else{
|
||||
ExpandedPair lastPair = ((ExpandedPair)previousPairs.lastElement());
|
||||
ExpandedPair lastPair = (ExpandedPair) previousPairs.lastElement();
|
||||
rowOffset = lastPair.getFinderPattern().getStartEnd()[1];
|
||||
}
|
||||
boolean searchingEvenPair = previousPairs.size() % 2 != 0;
|
||||
|
|
|
@ -67,7 +67,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
|
|||
int checkDigit = 0;
|
||||
for (int i = 0; i < 13; i++) {
|
||||
int digit = buf.charAt(i + currentPos) - '0';
|
||||
checkDigit += (((i & 0x01) == 0) ? 3 * digit : digit);
|
||||
checkDigit += (i & 0x01) == 0 ? 3 * digit : digit;
|
||||
}
|
||||
|
||||
checkDigit = 10 - (checkDigit % 10);
|
||||
|
|
|
@ -127,7 +127,7 @@ public final class Decoder {
|
|||
*/
|
||||
private static int correctErrors(int[] codewords, int[] erasures, int numECCodewords) throws FormatException {
|
||||
if ((erasures != null && erasures.length > numECCodewords / 2 + MAX_ERRORS) ||
|
||||
(numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS)) {
|
||||
numECCodewords < 0 || numECCodewords > MAX_EC_CODEWORDS) {
|
||||
// Too many errors or EC Codewords is corrupted
|
||||
throw FormatException.getFormatInstance();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ final class DataBlock {
|
|||
* @param rawCodewords bytes as read directly from the QR Code
|
||||
* @param version version of the QR Code
|
||||
* @param ecLevel error-correction level of the QR Code
|
||||
* @return {@link DataBlock}s containing original bytes, "de-interleaved" from representation in the
|
||||
* @return DataBlocks containing original bytes, "de-interleaved" from representation in the
|
||||
* QR Code
|
||||
*/
|
||||
static DataBlock[] getDataBlocks(byte[] rawCodewords,
|
||||
|
|
|
@ -70,7 +70,7 @@ abstract class DataMask {
|
|||
/**
|
||||
* @param reference a value between 0 and 7 indicating one of the eight possible
|
||||
* data mask patterns a QR Code may use
|
||||
* @return {@link DataMask} encapsulating the data mask pattern
|
||||
* @return DataMask encapsulating the data mask pattern
|
||||
*/
|
||||
static DataMask forReference(int reference) {
|
||||
if (reference < 0 || reference > 7) {
|
||||
|
|
|
@ -139,7 +139,7 @@ final class DecodedBitStreamParser {
|
|||
assembledTwoBytes += 0x0A6A1;
|
||||
}
|
||||
buffer[offset] = (byte) ((assembledTwoBytes >> 8) & 0xFF);
|
||||
buffer[offset + 1] = (byte) ((assembledTwoBytes) & 0xFF);
|
||||
buffer[offset + 1] = (byte) (assembledTwoBytes & 0xFF);
|
||||
offset += 2;
|
||||
count--;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public final class ErrorCorrectionLevel {
|
|||
|
||||
/**
|
||||
* @param bits int containing the two bits encoding a QR Code's error correction level
|
||||
* @return {@link ErrorCorrectionLevel} representing the encoded error correction level
|
||||
* @return ErrorCorrectionLevel representing the encoded error correction level
|
||||
*/
|
||||
public static ErrorCorrectionLevel forBits(int bits) {
|
||||
if (bits < 0 || bits >= FOR_BITS.length) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class Mode {
|
|||
|
||||
/**
|
||||
* @param bits four bits encoding a QR Code data mode
|
||||
* @return {@link Mode} encoded by these bits
|
||||
* @return Mode encoded by these bits
|
||||
* @throws IllegalArgumentException if bits do not correspond to a known mode
|
||||
*/
|
||||
public static Mode forBits(int bits) {
|
||||
|
@ -84,7 +84,7 @@ public final class Mode {
|
|||
/**
|
||||
* @param version version in question
|
||||
* @return number of bits used, in this QR Code symbol {@link Version}, to encode the
|
||||
* count of characters that will follow encoded in this {@link Mode}
|
||||
* count of characters that will follow encoded in this Mode
|
||||
*/
|
||||
public int getCharacterCountBits(Version version) {
|
||||
if (characterCountBitsForVersions == null) {
|
||||
|
|
|
@ -90,7 +90,7 @@ public final class Version {
|
|||
* <p>Deduces version information purely from QR Code dimensions.</p>
|
||||
*
|
||||
* @param dimension dimension in modules
|
||||
* @return {@link Version} for a QR Code of that dimension
|
||||
* @return Version for a QR Code of that dimension
|
||||
* @throws FormatException if dimension is not 1 mod 4
|
||||
*/
|
||||
public static Version getProvisionalVersionForDimension(int dimension) throws FormatException {
|
||||
|
|
|
@ -94,7 +94,7 @@ final class AlignmentPatternFinder {
|
|||
int[] stateCount = new int[3];
|
||||
for (int iGen = 0; iGen < height; iGen++) {
|
||||
// Search from middle outwards
|
||||
int i = middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1));
|
||||
int i = middleI + ((iGen & 0x01) == 0 ? (iGen + 1) >> 1 : -((iGen + 1) >> 1));
|
||||
stateCount[0] = 0;
|
||||
stateCount[1] = 0;
|
||||
stateCount[2] = 0;
|
||||
|
|
|
@ -139,11 +139,11 @@ public class Detector {
|
|||
return new DetectorResult(bits, points);
|
||||
}
|
||||
|
||||
public PerspectiveTransform createTransform(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft,
|
||||
ResultPoint alignmentPattern,
|
||||
int dimension) {
|
||||
public static PerspectiveTransform createTransform(ResultPoint topLeft,
|
||||
ResultPoint topRight,
|
||||
ResultPoint bottomLeft,
|
||||
ResultPoint alignmentPattern,
|
||||
int dimension) {
|
||||
float dimMinusThree = (float) dimension - 3.5f;
|
||||
float bottomRightX;
|
||||
float bottomRightY;
|
||||
|
|
|
@ -559,7 +559,7 @@ public class FinderPatternFinder {
|
|||
public int compare(Object center1, Object center2) {
|
||||
float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average);
|
||||
float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average);
|
||||
return dA < dB ? -1 : (dA == dB ? 0 : 1);
|
||||
return dA < dB ? -1 : dA == dB ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ public class FinderPatternFinder {
|
|||
if (((FinderPattern) center2).getCount() == ((FinderPattern) center1).getCount()) {
|
||||
float dA = Math.abs(((FinderPattern) center2).getEstimatedModuleSize() - average);
|
||||
float dB = Math.abs(((FinderPattern) center1).getEstimatedModuleSize() - average);
|
||||
return dA < dB ? 1 : (dA == dB ? 0 : -1);
|
||||
return dA < dB ? 1 : dA == dB ? 0 : -1;
|
||||
} else {
|
||||
return ((FinderPattern) center2).getCount() - ((FinderPattern) center1).getCount();
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ public final class Encoder {
|
|||
// If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24).
|
||||
int numPaddingBytes = numDataBytes - bits.getSizeInBytes();
|
||||
for (int i = 0; i < numPaddingBytes; ++i) {
|
||||
bits.appendBits(((i & 0x01) == 0) ? 0xEC : 0x11, 8);
|
||||
bits.appendBits((i & 0x01) == 0 ? 0xEC : 0x11, 8);
|
||||
}
|
||||
if (bits.getSize() != capacity) {
|
||||
throw new WriterException("Bits size does not equal capacity");
|
||||
|
|
|
@ -138,7 +138,8 @@ public final class MaskUtil {
|
|||
if (!QRCode.isValidMaskPattern(maskPattern)) {
|
||||
throw new IllegalArgumentException("Invalid mask pattern");
|
||||
}
|
||||
int intermediate, temp;
|
||||
int intermediate;
|
||||
int temp;
|
||||
switch (maskPattern) {
|
||||
case 0:
|
||||
intermediate = (y + x) & 0x1;
|
||||
|
@ -161,11 +162,11 @@ public final class MaskUtil {
|
|||
break;
|
||||
case 6:
|
||||
temp = y * x;
|
||||
intermediate = (((temp & 0x1) + (temp % 3)) & 0x1);
|
||||
intermediate = ((temp & 0x1) + (temp % 3)) & 0x1;
|
||||
break;
|
||||
case 7:
|
||||
temp = y * x;
|
||||
intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1);
|
||||
intermediate = ((temp % 3) + ((y + x) & 0x1)) & 0x1;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid mask pattern: " + maskPattern);
|
||||
|
|
|
@ -365,9 +365,9 @@ public final class MatrixUtil {
|
|||
|
||||
// Check if "value" is valid.
|
||||
private static boolean isValidValue(int value) {
|
||||
return (value == -1 || // Empty.
|
||||
return value == -1 || // Empty.
|
||||
value == 0 || // Light (white).
|
||||
value == 1); // Dark (black).
|
||||
value == 1; // Dark (black).
|
||||
}
|
||||
|
||||
private static void embedTimingPatterns(ByteMatrix matrix) throws WriterException {
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.junit.Test;
|
|||
* @author Vikram Aggarwal
|
||||
*/
|
||||
public final class WifiParsedResultTestCase extends Assert {
|
||||
|
||||
@Test
|
||||
public void testNoPassword() {
|
||||
doTest("WIFI:S:NoPassword;P:;T:;;", "NoPassword", "", "");
|
||||
doTest("WIFI:S:No Password;P:;T:;;", "No Password", "", "");
|
||||
|
|
|
@ -328,8 +328,8 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
|
|||
// to keep it centered
|
||||
at = new AffineTransform();
|
||||
at.rotate(radians, width / 2.0, height / 2.0);
|
||||
at.translate(((width - original.getWidth()) / 2.0),
|
||||
((height - original.getHeight()) / 2.0));
|
||||
at.translate((width - original.getWidth()) / 2.0,
|
||||
(height - original.getHeight()) / 2.0);
|
||||
op = new AffineTransformOp(at, AffineTransformOp.TYPE_BICUBIC);
|
||||
|
||||
return op.filter(original, null);
|
||||
|
|
|
@ -120,7 +120,7 @@ public final class BitMatrixTestCase extends Assert {
|
|||
assertEquals(200, array3.getSize());
|
||||
|
||||
for (int x = 0; x < 102; x++) {
|
||||
boolean on = ((x & 0x03) == 0);
|
||||
boolean on = (x & 0x03) == 0;
|
||||
assertEquals(on, array.get(x));
|
||||
assertEquals(on, array2.get(x));
|
||||
assertEquals(on, array3.get(x));
|
||||
|
|
|
@ -66,7 +66,8 @@ public abstract class AbstractDecoderTest extends Assert {
|
|||
protected static final String compressedDate_March_12th_2010 = "....XXXX.X..XX..";
|
||||
protected static final String compressedDate_End = "X..X.XX.........";
|
||||
|
||||
protected void assertCorrectBinaryString(String binaryString, String expectedNumber) throws NotFoundException {
|
||||
protected static void assertCorrectBinaryString(String binaryString, String expectedNumber)
|
||||
throws NotFoundException {
|
||||
BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(binaryString);
|
||||
AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary);
|
||||
String result = decoder.parseInformation();
|
||||
|
|
|
@ -27,7 +27,9 @@ import org.junit.Test;
|
|||
* @author mysen@google.com (Chris Mysen) - ported from C++
|
||||
*/
|
||||
public final class MatrixUtilTestCase extends Assert {
|
||||
public void testtoString() {
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
ByteMatrix array = new ByteMatrix(3, 3);
|
||||
array.set(0, 0, 0);
|
||||
array.set(1, 0, 1);
|
||||
|
@ -254,6 +256,7 @@ public final class MatrixUtilTestCase extends Assert {
|
|||
1, // Version 1
|
||||
3, // Mask pattern 3
|
||||
matrix);
|
||||
assertEquals(expected, matrix.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.util.regex.Pattern;
|
|||
*
|
||||
* <p>Pass the Android client res/ directory as first argument, and optionally message keys
|
||||
* who should be forced to retranslate.
|
||||
* Usage: <code>StringsResourceTranslator android/res/ [key_1 ...]</p>
|
||||
* Usage: {@code StringsResourceTranslator android/res/ [key_1 ...]}</p>
|
||||
*
|
||||
* @author Sean Owen
|
||||
*/
|
||||
|
|
|
@ -70,6 +70,7 @@ import java.util.Collection;
|
|||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
@ -112,6 +113,7 @@ public final class DecodeServlet extends HttpServlet {
|
|||
possibleFormats.add(BarcodeFormat.CODABAR);
|
||||
possibleFormats.add(BarcodeFormat.ITF);
|
||||
possibleFormats.add(BarcodeFormat.RSS_14);
|
||||
possibleFormats.add(BarcodeFormat.RSS_EXPANDED);
|
||||
possibleFormats.add(BarcodeFormat.QR_CODE);
|
||||
possibleFormats.add(BarcodeFormat.DATA_MATRIX);
|
||||
possibleFormats.add(BarcodeFormat.AZTEC);
|
||||
|
@ -163,7 +165,9 @@ public final class DecodeServlet extends HttpServlet {
|
|||
try {
|
||||
imageURI = new URI(imageURIString);
|
||||
} catch (URISyntaxException urise) {
|
||||
log.fine("URI was not valid: " + imageURIString);
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine("URI was not valid: " + imageURIString);
|
||||
}
|
||||
response.sendRedirect("badurl.jspx");
|
||||
return;
|
||||
}
|
||||
|
@ -181,7 +185,9 @@ public final class DecodeServlet extends HttpServlet {
|
|||
getResponse = client.execute(getRequest);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// Thrown if hostname is bad or null
|
||||
log.fine(iae.toString());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine(iae.toString());
|
||||
}
|
||||
getRequest.abort();
|
||||
response.sendRedirect("badurl.jspx");
|
||||
return;
|
||||
|
@ -191,14 +197,18 @@ public final class DecodeServlet extends HttpServlet {
|
|||
// javax.net.ssl.SSLPeerUnverifiedException,
|
||||
// org.apache.http.NoHttpResponseException,
|
||||
// org.apache.http.client.ClientProtocolException,
|
||||
log.fine(ioe.toString());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine(ioe.toString());
|
||||
}
|
||||
getRequest.abort();
|
||||
response.sendRedirect("badurl.jspx");
|
||||
return;
|
||||
}
|
||||
|
||||
if (getResponse.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK) {
|
||||
log.fine("Unsuccessful return code: " + getResponse.getStatusLine().getStatusCode());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine("Unsuccessful return code: " + getResponse.getStatusLine().getStatusCode());
|
||||
}
|
||||
response.sendRedirect("badurl.jspx");
|
||||
return;
|
||||
}
|
||||
|
@ -257,7 +267,9 @@ public final class DecodeServlet extends HttpServlet {
|
|||
}
|
||||
}
|
||||
} catch (FileUploadException fue) {
|
||||
log.fine(fue.toString());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine(fue.toString());
|
||||
}
|
||||
response.sendRedirect("badimage.jspx");
|
||||
}
|
||||
|
||||
|
@ -270,17 +282,23 @@ public final class DecodeServlet extends HttpServlet {
|
|||
try {
|
||||
image = ImageIO.read(is);
|
||||
} catch (IOException ioe) {
|
||||
log.fine(ioe.toString());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine(ioe.toString());
|
||||
}
|
||||
// Includes javax.imageio.IIOException
|
||||
response.sendRedirect("badimage.jspx");
|
||||
return;
|
||||
} catch (CMMException cmme) {
|
||||
log.fine(cmme.toString());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine(cmme.toString());
|
||||
}
|
||||
// Have seen this in logs
|
||||
response.sendRedirect("badimage.jspx");
|
||||
return;
|
||||
} catch (IllegalArgumentException iae) {
|
||||
log.fine(iae.toString());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine(iae.toString());
|
||||
}
|
||||
// Have seen this in logs for some JPEGs
|
||||
response.sendRedirect("badimage.jspx");
|
||||
return;
|
||||
|
@ -291,7 +309,9 @@ public final class DecodeServlet extends HttpServlet {
|
|||
}
|
||||
if (image.getHeight() <= 1 || image.getWidth() <= 1 ||
|
||||
image.getHeight() * image.getWidth() > MAX_PIXELS) {
|
||||
log.fine("Dimensions too large: " + image.getWidth() + 'x' + image.getHeight());
|
||||
if (log.isLoggable(Level.FINE)) {
|
||||
log.fine("Dimensions too large: " + image.getWidth() + 'x' + image.getHeight());
|
||||
}
|
||||
response.sendRedirect("badimage.jspx");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue