mirror of
https://github.com/zxing/zxing.git
synced 2024-11-09 20:44:03 -08:00
Implement more style checks around whitespace
This commit is contained in:
parent
ddfc0cac11
commit
08e5431d99
|
@ -78,7 +78,7 @@ final class DecodeFormatManager {
|
|||
|
||||
static Set<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
|
||||
List<String> formats = inputUri.getQueryParameters(Intents.Scan.FORMATS);
|
||||
if (formats != null && formats.size() == 1 && formats.get(0) != null){
|
||||
if (formats != null && formats.size() == 1 && formats.get(0) != null) {
|
||||
formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
|
||||
}
|
||||
return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
|
||||
|
|
|
@ -103,7 +103,7 @@ final class DecodeHintManager {
|
|||
String name = query.substring(pos, equ);
|
||||
name = name.replace('+', ' '); // Preemptively decode +
|
||||
name = Uri.decode(name);
|
||||
String text = query.substring(equ+1, amp);
|
||||
String text = query.substring(equ + 1, amp);
|
||||
text = text.replace('+', ' '); // Preemptively decode +
|
||||
text = Uri.decode(text);
|
||||
if (!map.containsKey(name)) {
|
||||
|
|
|
@ -86,7 +86,7 @@ final class InactivityTimer {
|
|||
|
||||
private final class PowerStatusReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent){
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
|
||||
// 0 indicates that we're on battery
|
||||
boolean onBatteryNow = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) <= 0;
|
||||
|
|
|
@ -91,12 +91,12 @@ public final class ExpandedProductParsedResult extends ParsedResult {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o){
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof ExpandedProductParsedResult)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ExpandedProductParsedResult other = (ExpandedProductParsedResult)o;
|
||||
ExpandedProductParsedResult other = (ExpandedProductParsedResult) o;
|
||||
|
||||
return equalsOrNull(productID, other.productID)
|
||||
&& equalsOrNull(sscc, other.sscc)
|
||||
|
@ -118,7 +118,7 @@ public final class ExpandedProductParsedResult extends ParsedResult {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int hashCode(){
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash ^= hashNotNull(productID);
|
||||
hash ^= hashNotNull(sscc);
|
||||
|
|
|
@ -146,14 +146,14 @@ public final class VCardResultParser extends ResultParser {
|
|||
|
||||
int matchStart = i; // Found the start of a match here
|
||||
|
||||
while ((i = rawText.indexOf((int) '\n', i)) >= 0) { // Really, end in \r\n
|
||||
while ((i = rawText.indexOf('\n', i)) >= 0) { // Really, end in \r\n
|
||||
if (i < rawText.length() - 1 && // But if followed by tab or space,
|
||||
(rawText.charAt(i+1) == ' ' || // this is only a continuation
|
||||
rawText.charAt(i+1) == '\t')) {
|
||||
(rawText.charAt(i + 1) == ' ' || // this is only a continuation
|
||||
rawText.charAt(i + 1) == '\t')) {
|
||||
i += 2; // Skip \n and continutation whitespace
|
||||
} else if (quotedPrintable && // If preceded by = in quoted printable
|
||||
((i >= 1 && rawText.charAt(i-1) == '=') || // this is a continuation
|
||||
(i >= 2 && rawText.charAt(i-2) == '='))) {
|
||||
((i >= 1 && rawText.charAt(i - 1) == '=') || // this is a continuation
|
||||
(i >= 2 && rawText.charAt(i - 2) == '='))) {
|
||||
i++; // Skip \n
|
||||
} else {
|
||||
break;
|
||||
|
@ -168,7 +168,7 @@ public final class VCardResultParser extends ResultParser {
|
|||
if (matches == null) {
|
||||
matches = new ArrayList<>(1); // lazy init
|
||||
}
|
||||
if (i >= 1 && rawText.charAt(i-1) == '\r') {
|
||||
if (i >= 1 && rawText.charAt(i - 1) == '\r') {
|
||||
i--; // Back up over \r, which really should be there
|
||||
}
|
||||
String element = rawText.substring(matchStart, i);
|
||||
|
@ -218,9 +218,9 @@ public final class VCardResultParser extends ResultParser {
|
|||
break;
|
||||
case '=':
|
||||
if (i < length - 2) {
|
||||
char nextChar = value.charAt(i+1);
|
||||
char nextChar = value.charAt(i + 1);
|
||||
if (nextChar != '\r' && nextChar != '\n') {
|
||||
char nextNextChar = value.charAt(i+2);
|
||||
char nextNextChar = value.charAt(i + 2);
|
||||
int firstDigit = parseHexDigit(nextChar);
|
||||
int secondDigit = parseHexDigit(nextNextChar);
|
||||
if (firstDigit >= 0 && secondDigit >= 0) {
|
||||
|
|
|
@ -102,7 +102,7 @@ public final class BitMatrix implements Cloneable {
|
|||
|
||||
// no EOL at end?
|
||||
if (bitsPos > rowStartPos) {
|
||||
if(rowLength == -1) {
|
||||
if (rowLength == -1) {
|
||||
rowLength = bitsPos - rowStartPos;
|
||||
} else if (bitsPos - rowStartPos != rowLength) {
|
||||
throw new IllegalArgumentException("row lengths do not match");
|
||||
|
@ -254,7 +254,7 @@ public final class BitMatrix implements Cloneable {
|
|||
int height = getHeight();
|
||||
BitArray topRow = new BitArray(width);
|
||||
BitArray bottomRow = new BitArray(width);
|
||||
for (int i = 0; i < (height+1) / 2; i++) {
|
||||
for (int i = 0; i < (height + 1) / 2; i++) {
|
||||
topRow = getRow(i, topRow);
|
||||
bottomRow = getRow(height - 1 - i, bottomRow);
|
||||
topRow.reverse();
|
||||
|
@ -335,7 +335,7 @@ public final class BitMatrix implements Cloneable {
|
|||
|
||||
int theBits = bits[bitsOffset];
|
||||
int bit = 0;
|
||||
while ((theBits << (31-bit)) == 0) {
|
||||
while ((theBits << (31 - bit)) == 0) {
|
||||
bit++;
|
||||
}
|
||||
x += bit;
|
||||
|
|
|
@ -118,7 +118,7 @@ public class GlobalHistogramBinarizer extends Binarizer {
|
|||
byte[] localLuminances = source.getMatrix();
|
||||
for (int y = 0; y < height; y++) {
|
||||
int offset = y * width;
|
||||
for (int x = 0; x< width; x++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
int pixel = localLuminances[offset + x] & 0xff;
|
||||
if (pixel < blackPoint) {
|
||||
matrix.set(x, y);
|
||||
|
|
|
@ -70,10 +70,10 @@ public final class GenericGF {
|
|||
x *= 2; // we're assuming the generator alpha is 2
|
||||
if (x >= size) {
|
||||
x ^= primitive;
|
||||
x &= size-1;
|
||||
x &= size - 1;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < size-1; i++) {
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
logTable[expTable[i]] = i;
|
||||
}
|
||||
// logTable[0] == 0 but this should never be used
|
||||
|
|
|
@ -94,22 +94,22 @@ final class BitMatrixParser {
|
|||
if ((row == numRows) && (column == 0) && !corner1Read) {
|
||||
result[resultOffset++] = (byte) readCorner1(numRows, numColumns);
|
||||
row -= 2;
|
||||
column +=2;
|
||||
column += 2;
|
||||
corner1Read = true;
|
||||
} else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) {
|
||||
} else if ((row == numRows - 2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) {
|
||||
result[resultOffset++] = (byte) readCorner2(numRows, numColumns);
|
||||
row -= 2;
|
||||
column +=2;
|
||||
column += 2;
|
||||
corner2Read = true;
|
||||
} else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) {
|
||||
} else if ((row == numRows + 4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) {
|
||||
result[resultOffset++] = (byte) readCorner3(numRows, numColumns);
|
||||
row -= 2;
|
||||
column +=2;
|
||||
column += 2;
|
||||
corner3Read = true;
|
||||
} else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) {
|
||||
} else if ((row == numRows - 2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) {
|
||||
result[resultOffset++] = (byte) readCorner4(numRows, numColumns);
|
||||
row -= 2;
|
||||
column +=2;
|
||||
column += 2;
|
||||
corner4Read = true;
|
||||
} else {
|
||||
// Sweep upward diagonally to the right
|
||||
|
@ -118,10 +118,10 @@ final class BitMatrixParser {
|
|||
result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns);
|
||||
}
|
||||
row -= 2;
|
||||
column +=2;
|
||||
column += 2;
|
||||
} while ((row >= 0) && (column < numColumns));
|
||||
row += 1;
|
||||
column +=3;
|
||||
column += 3;
|
||||
|
||||
// Sweep downward diagonally to the left
|
||||
do {
|
||||
|
@ -129,10 +129,10 @@ final class BitMatrixParser {
|
|||
result[resultOffset++] = (byte) readUtah(row, column, numRows, numColumns);
|
||||
}
|
||||
row += 2;
|
||||
column -=2;
|
||||
column -= 2;
|
||||
} while ((row < numRows) && (column >= 0));
|
||||
row += 3;
|
||||
column +=1;
|
||||
column += 1;
|
||||
}
|
||||
} while ((row < numRows) || (column < numColumns));
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ public final class Detector {
|
|||
|
||||
correctedTopRight =
|
||||
correctTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight);
|
||||
if (correctedTopRight == null){
|
||||
if (correctedTopRight == null) {
|
||||
correctedTopRight = topRight;
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ public final class Detector {
|
|||
int dimension = Math.min(dimensionRight, dimensionTop);
|
||||
// correct top right point to match the white module
|
||||
correctedTopRight = correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension);
|
||||
if (correctedTopRight == null){
|
||||
if (correctedTopRight == null) {
|
||||
correctedTopRight = topRight;
|
||||
}
|
||||
|
||||
|
@ -224,19 +224,19 @@ public final class Detector {
|
|||
int dimensionTop,
|
||||
int dimensionRight) {
|
||||
|
||||
float corr = distance(bottomLeft, bottomRight) / (float)dimensionTop;
|
||||
float corr = distance(bottomLeft, bottomRight) / (float) dimensionTop;
|
||||
int norm = distance(topLeft, topRight);
|
||||
float cos = (topRight.getX() - topLeft.getX()) / norm;
|
||||
float sin = (topRight.getY() - topLeft.getY()) / norm;
|
||||
|
||||
ResultPoint c1 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin);
|
||||
ResultPoint c1 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
|
||||
|
||||
corr = distance(bottomLeft, topLeft) / (float)dimensionRight;
|
||||
corr = distance(bottomLeft, topLeft) / (float) dimensionRight;
|
||||
norm = distance(bottomRight, topRight);
|
||||
cos = (topRight.getX() - bottomRight.getX()) / norm;
|
||||
sin = (topRight.getY() - bottomRight.getY()) / norm;
|
||||
|
||||
ResultPoint c2 = new ResultPoint(topRight.getX()+corr*cos, topRight.getY()+corr*sin);
|
||||
ResultPoint c2 = new ResultPoint(topRight.getX() + corr * cos, topRight.getY() + corr * sin);
|
||||
|
||||
if (!isValid(c1)) {
|
||||
if (isValid(c2)) {
|
||||
|
@ -244,7 +244,7 @@ public final class Detector {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
if (!isValid(c2)){
|
||||
if (!isValid(c2)) {
|
||||
return c1;
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ public final class Detector {
|
|||
int l2 = Math.abs(dimensionTop - transitionsBetween(topLeft, c2).getTransitions()) +
|
||||
Math.abs(dimensionRight - transitionsBetween(bottomRight, c2).getTransitions());
|
||||
|
||||
if (l1 <= l2){
|
||||
if (l1 <= l2) {
|
||||
return c1;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,11 +47,23 @@ final class DecodedBitStreamParser {
|
|||
private static final char RS = '\u001E';
|
||||
|
||||
private static final String[] SETS = {
|
||||
"\nABCDEFGHIJKLMNOPQRSTUVWXYZ"+ECI+FS+GS+RS+NS+' '+PAD+"\"#$%&'()*+,-./0123456789:"+SHIFTB+SHIFTC+SHIFTD+SHIFTE+LATCHB,
|
||||
"`abcdefghijklmnopqrstuvwxyz"+ECI+FS+GS+RS+NS+'{'+PAD+"}~\u007F;<=>?[\\]^_ ,./:@!|"+PAD+TWOSHIFTA+THREESHIFTA+PAD+SHIFTA+SHIFTC+SHIFTD+SHIFTE+LATCHA,
|
||||
"\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA"+ECI+FS+GS+RS+"\u00DB\u00DC\u00DD\u00DE\u00DF\u00AA\u00AC\u00B1\u00B2\u00B3\u00B5\u00B9\u00BA\u00BC\u00BD\u00BE\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089"+LATCHA+' '+LOCK+SHIFTD+SHIFTE+LATCHB,
|
||||
"\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA"+ECI+FS+GS+RS+NS+"\u00FB\u00FC\u00FD\u00FE\u00FF\u00A1\u00A8\u00AB\u00AF\u00B0\u00B4\u00B7\u00B8\u00BB\u00BF\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094"+LATCHA+' '+SHIFTC+LOCK+SHIFTE+LATCHB,
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\n\u000B\u000C\r\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A"+ECI+PAD+PAD+'\u001B'+NS+FS+GS+RS+"\u001F\u009F\u00A0\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A9\u00AD\u00AE\u00B6\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E"+LATCHA+' '+SHIFTC+SHIFTD+LOCK+LATCHB,
|
||||
"\nABCDEFGHIJKLMNOPQRSTUVWXYZ" + ECI + FS + GS + RS + NS + ' ' + PAD +
|
||||
"\"#$%&'()*+,-./0123456789:" + SHIFTB + SHIFTC + SHIFTD + SHIFTE + LATCHB,
|
||||
"`abcdefghijklmnopqrstuvwxyz" + ECI + FS + GS + RS + NS + '{' + PAD +
|
||||
"}~\u007F;<=>?[\\]^_ ,./:@!|" + PAD + TWOSHIFTA + THREESHIFTA + PAD +
|
||||
SHIFTA + SHIFTC + SHIFTD + SHIFTE + LATCHA,
|
||||
"\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA" +
|
||||
ECI + FS + GS + RS +
|
||||
"\u00DB\u00DC\u00DD\u00DE\u00DF\u00AA\u00AC\u00B1\u00B2\u00B3\u00B5\u00B9\u00BA\u00BC\u00BD\u00BE\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087\u0088\u0089" +
|
||||
LATCHA + ' ' + LOCK + SHIFTD + SHIFTE + LATCHB,
|
||||
"\u00E0\u00E1\u00E2\u00E3\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA" +
|
||||
ECI + FS + GS + RS + NS +
|
||||
"\u00FB\u00FC\u00FD\u00FE\u00FF\u00A1\u00A8\u00AB\u00AF\u00B0\u00B4\u00B7\u00B8\u00BB\u00BF\u008A\u008B\u008C\u008D\u008E\u008F\u0090\u0091\u0092\u0093\u0094" +
|
||||
LATCHA + ' ' + SHIFTC + LOCK + SHIFTE + LATCHB,
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\n\u000B\u000C\r\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A" +
|
||||
ECI + PAD + PAD + '\u001B' + NS + FS + GS + RS +
|
||||
"\u001F\u009F\u00A0\u00A2\u00A3\u00A4\u00A5\u00A6\u00A7\u00A9\u00AD\u00AE\u00B6\u0095\u0096\u0097\u0098\u0099\u009A\u009B\u009C\u009D\u009E" +
|
||||
LATCHA + ' ' + SHIFTC + SHIFTD + LOCK + LATCHB,
|
||||
"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\n\u000B\u000C\r\u000E\u000F\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F\u0020\u0021\"\u0023\u0024\u0025\u0026\u0027\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F"
|
||||
};
|
||||
|
||||
|
@ -75,7 +87,7 @@ final class DecodedBitStreamParser {
|
|||
String country = threeDigits.format(getCountry(bytes));
|
||||
String service = threeDigits.format(getServiceClass(bytes));
|
||||
result.append(getMessage(bytes, 10, 84));
|
||||
if (result.toString().startsWith("[)>"+RS+"01"+GS)) {
|
||||
if (result.toString().startsWith("[)>" + RS + "01" + GS)) {
|
||||
result.insert(9, postcode + GS + country + GS + service + GS);
|
||||
} else {
|
||||
result.insert(0, postcode + GS + country + GS + service + GS);
|
||||
|
|
|
@ -93,7 +93,7 @@ public final class CodaBarReader extends OneDReader {
|
|||
// Hack: We store the position in the alphabet table into a
|
||||
// StringBuilder, so that we can access the decoded patterns in
|
||||
// validatePattern. We'll translate to the actual characters later.
|
||||
decodeRowResult.append((char)charOffset);
|
||||
decodeRowResult.append((char) charOffset);
|
||||
nextStart += 8;
|
||||
// Stop as soon as we see the end character.
|
||||
if (decodeRowResult.length() > 1 &&
|
||||
|
@ -270,7 +270,7 @@ public final class CodaBarReader extends OneDReader {
|
|||
for (int j = i; j < i + 7; j++) {
|
||||
patternSize += counters[j];
|
||||
}
|
||||
if (i == 1 || counters[i-1] >= patternSize / 2) {
|
||||
if (i == 1 || counters[i - 1] >= patternSize / 2) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ public final class Code128Reader extends OneDReader {
|
|||
switch (code) {
|
||||
case CODE_FNC_1:
|
||||
if (convertFNC1) {
|
||||
if (result.length() == 0){
|
||||
if (result.length() == 0) {
|
||||
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
|
||||
// is FNC1 then this is GS1-128. We add the symbology identifier.
|
||||
result.append("]C1");
|
||||
|
@ -396,7 +396,7 @@ public final class Code128Reader extends OneDReader {
|
|||
switch (code) {
|
||||
case CODE_FNC_1:
|
||||
if (convertFNC1) {
|
||||
if (result.length() == 0){
|
||||
if (result.length() == 0) {
|
||||
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
|
||||
// is FNC1 then this is GS1-128. We add the symbology identifier.
|
||||
result.append("]C1");
|
||||
|
@ -450,7 +450,7 @@ public final class Code128Reader extends OneDReader {
|
|||
switch (code) {
|
||||
case CODE_FNC_1:
|
||||
if (convertFNC1) {
|
||||
if (result.length() == 0){
|
||||
if (result.length() == 0) {
|
||||
// GS1 specification 5.4.3.7. and 5.4.6.4. If the first char after the start code
|
||||
// is FNC1 then this is GS1-128. We add the symbology identifier.
|
||||
result.append("]C1");
|
||||
|
|
|
@ -60,7 +60,7 @@ public final class ITFWriter extends OneDimensionalCodeWriter {
|
|||
int pos = appendPattern(result, 0, START_PATTERN, true);
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
int one = Character.digit(contents.charAt(i), 10);
|
||||
int two = Character.digit(contents.charAt(i+1), 10);
|
||||
int two = Character.digit(contents.charAt(i + 1), 10);
|
||||
int[] encoding = new int[18];
|
||||
for (int j = 0; j < 5; j++) {
|
||||
encoding[2 * j] = ITFReader.PATTERNS[one][j];
|
||||
|
|
|
@ -70,7 +70,7 @@ public final class MultiFormatOneDReader extends OneDReader {
|
|||
if (possibleFormats.contains(BarcodeFormat.RSS_14)) {
|
||||
readers.add(new RSS14Reader());
|
||||
}
|
||||
if (possibleFormats.contains(BarcodeFormat.RSS_EXPANDED)){
|
||||
if (possibleFormats.contains(BarcodeFormat.RSS_EXPANDED)) {
|
||||
readers.add(new RSSExpandedReader());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class DataCharacter {
|
|||
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if(!(o instanceof DataCharacter)) {
|
||||
if (!(o instanceof DataCharacter)) {
|
||||
return false;
|
||||
}
|
||||
DataCharacter that = (DataCharacter) o;
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class FinderPattern {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(!(o instanceof FinderPattern)) {
|
||||
if (!(o instanceof FinderPattern)) {
|
||||
return false;
|
||||
}
|
||||
FinderPattern that = (FinderPattern) o;
|
||||
|
|
|
@ -251,7 +251,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
|||
evenChecksumPortion += evenCounts[i];
|
||||
evenSum += evenCounts[i];
|
||||
}
|
||||
int checksumPortion = oddChecksumPortion + 3*evenChecksumPortion;
|
||||
int checksumPortion = oddChecksumPortion + 3 * evenChecksumPortion;
|
||||
|
||||
if (outsideChar) {
|
||||
if ((oddSum & 0x01) != 0 || oddSum > 12 || oddSum < 4) {
|
||||
|
@ -403,7 +403,7 @@ public final class RSS14Reader extends AbstractRSSReader {
|
|||
}
|
||||
incrementOdd = true;
|
||||
incrementEven = true;
|
||||
} else */if (mismatch == 1) {
|
||||
} else */ if (mismatch == 1) {
|
||||
if (oddParityBad) {
|
||||
if (evenParityBad) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
|
|
|
@ -52,27 +52,27 @@ final class BitArrayBuilder {
|
|||
|
||||
ExpandedPair firstPair = pairs.get(0);
|
||||
int firstValue = firstPair.getRightChar().getValue();
|
||||
for(int i = 11; i >= 0; --i){
|
||||
for (int i = 11; i >= 0; --i) {
|
||||
if ((firstValue & (1 << i)) != 0) {
|
||||
binary.set(accPos);
|
||||
}
|
||||
accPos++;
|
||||
}
|
||||
|
||||
for(int i = 1; i < pairs.size(); ++i){
|
||||
for (int i = 1; i < pairs.size(); ++i) {
|
||||
ExpandedPair currentPair = pairs.get(i);
|
||||
|
||||
int leftValue = currentPair.getLeftChar().getValue();
|
||||
for(int j = 11; j >= 0; --j){
|
||||
for (int j = 11; j >= 0; --j) {
|
||||
if ((leftValue & (1 << j)) != 0) {
|
||||
binary.set(accPos);
|
||||
}
|
||||
accPos++;
|
||||
}
|
||||
|
||||
if(currentPair.getRightChar() != null){
|
||||
if (currentPair.getRightChar() != null) {
|
||||
int rightValue = currentPair.getRightChar().getValue();
|
||||
for(int j = 11; j >= 0; --j){
|
||||
for (int j = 11; j >= 0; --j) {
|
||||
if ((rightValue & (1 << j)) != 0) {
|
||||
binary.set(accPos);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ final class ExpandedPair {
|
|||
this.mayBeLast = mayBeLast;
|
||||
}
|
||||
|
||||
boolean mayBeLast(){
|
||||
boolean mayBeLast() {
|
||||
return this.mayBeLast;
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
// Not private for testing
|
||||
List<ExpandedPair> decodeRow2pairs(int rowNumber, BitArray row) throws NotFoundException {
|
||||
try {
|
||||
while (true){
|
||||
while (true) {
|
||||
ExpandedPair nextPair = retrieveNextPair(row, this.pairs, rowNumber);
|
||||
this.pairs.add(nextPair);
|
||||
// exit this loop when retrieveNextPair() fails and throws
|
||||
|
@ -388,7 +388,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
int checksum = firstCharacter.getChecksumPortion();
|
||||
int s = 2;
|
||||
|
||||
for(int i = 1; i < this.pairs.size(); ++i){
|
||||
for (int i = 1; i < this.pairs.size(); ++i) {
|
||||
ExpandedPair currentPair = this.pairs.get(i);
|
||||
checksum += currentPair.getLeftChar().getChecksumPortion();
|
||||
s++;
|
||||
|
@ -406,7 +406,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
return checkCharacterValue == checkCharacter.getValue();
|
||||
}
|
||||
|
||||
private static int getNextSecondBar(BitArray row, int initialPos){
|
||||
private static int getNextSecondBar(BitArray row, int initialPos) {
|
||||
int currentPos;
|
||||
if (row.get(initialPos)) {
|
||||
currentPos = row.getNextUnset(initialPos);
|
||||
|
@ -430,29 +430,29 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
|
||||
boolean keepFinding = true;
|
||||
int forcedOffset = -1;
|
||||
do{
|
||||
do {
|
||||
this.findNextPair(row, previousPairs, forcedOffset);
|
||||
pattern = parseFoundFinderPattern(row, rowNumber, isOddPattern);
|
||||
if (pattern == null){
|
||||
if (pattern == null) {
|
||||
forcedOffset = getNextSecondBar(row, this.startEnd[0]);
|
||||
} else {
|
||||
keepFinding = false;
|
||||
}
|
||||
}while(keepFinding);
|
||||
} while (keepFinding);
|
||||
|
||||
// When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not.
|
||||
// boolean mayBeLast = checkPairSequence(previousPairs, pattern);
|
||||
|
||||
DataCharacter leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true);
|
||||
|
||||
if (!previousPairs.isEmpty() && previousPairs.get(previousPairs.size()-1).mustBeLast()) {
|
||||
if (!previousPairs.isEmpty() && previousPairs.get(previousPairs.size() - 1).mustBeLast()) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
DataCharacter rightChar;
|
||||
try {
|
||||
rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false);
|
||||
} catch(NotFoundException ignored) {
|
||||
} catch (NotFoundException ignored) {
|
||||
rightChar = null;
|
||||
}
|
||||
boolean mayBeLast = true;
|
||||
|
@ -474,7 +474,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
rowOffset = forcedOffset;
|
||||
} else if (previousPairs.isEmpty()) {
|
||||
rowOffset = 0;
|
||||
} else{
|
||||
} else {
|
||||
ExpandedPair lastPair = previousPairs.get(previousPairs.size() - 1);
|
||||
rowOffset = lastPair.getFinderPattern().getStartEnd()[1];
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
reverseCounters(counters);
|
||||
}
|
||||
|
||||
if (isFinderPattern(counters)){
|
||||
if (isFinderPattern(counters)) {
|
||||
this.startEnd[0] = patternStart;
|
||||
this.startEnd[1] = x;
|
||||
return;
|
||||
|
@ -529,9 +529,9 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
private static void reverseCounters(int [] counters){
|
||||
private static void reverseCounters(int [] counters) {
|
||||
int length = counters.length;
|
||||
for(int i = 0; i < length / 2; ++i){
|
||||
for (int i = 0; i < length / 2; ++i) {
|
||||
int tmp = counters[i];
|
||||
counters[i] = counters[length - i - 1];
|
||||
counters[length - i - 1] = tmp;
|
||||
|
@ -544,7 +544,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
int start;
|
||||
int end;
|
||||
|
||||
if(oddPattern){
|
||||
if (oddPattern) {
|
||||
// If pattern number is odd, we need to locate element 1 *before* the current block.
|
||||
|
||||
int firstElementStart = this.startEnd[0] - 1;
|
||||
|
@ -558,7 +558,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
start = firstElementStart;
|
||||
end = this.startEnd[1];
|
||||
|
||||
}else{
|
||||
} else {
|
||||
// If pattern number is even, the pattern is reversed, so we need to locate element 1 *after* the current block.
|
||||
|
||||
start = this.startEnd[0];
|
||||
|
@ -605,7 +605,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
counters[i] = counters[j];
|
||||
counters[j] = temp;
|
||||
}
|
||||
}//counters[] has the pixels of the module
|
||||
} //counters[] has the pixels of the module
|
||||
|
||||
int numModules = 17; //left and right data characters have all the same length
|
||||
float elementWidth = (float) MathUtils.sum(counters) / (float) numModules;
|
||||
|
@ -647,12 +647,12 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
|
||||
adjustOddEvenCounts(numModules);
|
||||
|
||||
int weightRowNumber = 4 * pattern.getValue() + (isOddPattern?0:2) + (leftChar?0:1) - 1;
|
||||
int weightRowNumber = 4 * pattern.getValue() + (isOddPattern ? 0 : 2) + (leftChar ? 0 : 1) - 1;
|
||||
|
||||
int oddSum = 0;
|
||||
int oddChecksumPortion = 0;
|
||||
for (int i = oddCounts.length - 1; i >= 0; i--) {
|
||||
if(isNotA1left(pattern, isOddPattern, leftChar)){
|
||||
if (isNotA1left(pattern, isOddPattern, leftChar)) {
|
||||
int weight = WEIGHTS[weightRowNumber][2 * i];
|
||||
oddChecksumPortion += oddCounts[i] * weight;
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
|
|||
int evenChecksumPortion = 0;
|
||||
//int evenSum = 0;
|
||||
for (int i = evenCounts.length - 1; i >= 0; i--) {
|
||||
if(isNotA1left(pattern, isOddPattern, leftChar)){
|
||||
if (isNotA1left(pattern, isOddPattern, leftChar)) {
|
||||
int weight = WEIGHTS[weightRowNumber][2 * i + 1];
|
||||
evenChecksumPortion += evenCounts[i] * weight;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ final class AI01320xDecoder extends AI013x0xDecoder {
|
|||
|
||||
@Override
|
||||
protected int checkWeight(int weight) {
|
||||
if(weight < 10000) {
|
||||
if (weight < 10000) {
|
||||
return weight;
|
||||
}
|
||||
return weight - 10000;
|
||||
|
|
|
@ -44,7 +44,7 @@ final class AI01393xDecoder extends AI01decoder {
|
|||
|
||||
@Override
|
||||
public String parseInformation() throws NotFoundException, FormatException {
|
||||
if(this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
|
||||
if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
@ -61,10 +61,10 @@ final class AI01393xDecoder extends AI01decoder {
|
|||
|
||||
int firstThreeDigits =
|
||||
this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE);
|
||||
if(firstThreeDigits / 100 == 0) {
|
||||
if (firstThreeDigits / 100 == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
if(firstThreeDigits / 10 == 0) {
|
||||
if (firstThreeDigits / 10 == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(firstThreeDigits);
|
||||
|
|
|
@ -65,7 +65,7 @@ final class AI013x0x1xDecoder extends AI01weightDecoder {
|
|||
|
||||
private void encodeCompressedDate(StringBuilder buf, int currentPos) {
|
||||
int numericDate = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, DATE_SIZE);
|
||||
if(numericDate == 38400) {
|
||||
if (numericDate == 38400) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
|
|||
}
|
||||
|
||||
final void encodeCompressedGtinWithoutAI(StringBuilder buf, int currentPos, int initialBufferPosition) {
|
||||
for(int i = 0; i < 4; ++i){
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
int currentBlock = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos + 10 * i, 10);
|
||||
if (currentBlock / 100 == 0) {
|
||||
buf.append('0');
|
||||
|
@ -63,7 +63,7 @@ abstract class AI01decoder extends AbstractExpandedDecoder {
|
|||
appendCheckDigit(buf, initialBufferPosition);
|
||||
}
|
||||
|
||||
private static void appendCheckDigit(StringBuilder buf, int currentPos){
|
||||
private static void appendCheckDigit(StringBuilder buf, int currentPos) {
|
||||
int checkDigit = 0;
|
||||
for (int i = 0; i < 13; i++) {
|
||||
int digit = buf.charAt(i + currentPos) - '0';
|
||||
|
|
|
@ -44,7 +44,7 @@ abstract class AI01weightDecoder extends AI01decoder {
|
|||
int weightNumeric = checkWeight(originalWeightNumeric);
|
||||
|
||||
int currentDivisor = 100000;
|
||||
for(int i = 0; i < 5; ++i){
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (weightNumeric / currentDivisor == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public abstract class AbstractExpandedDecoder {
|
|||
private final BitArray information;
|
||||
private final GeneralAppIdDecoder generalDecoder;
|
||||
|
||||
AbstractExpandedDecoder(BitArray information){
|
||||
AbstractExpandedDecoder(BitArray information) {
|
||||
this.information = information;
|
||||
this.generalDecoder = new GeneralAppIdDecoder(information);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public abstract class AbstractExpandedDecoder {
|
|||
|
||||
public abstract String parseInformation() throws NotFoundException, FormatException;
|
||||
|
||||
public static AbstractExpandedDecoder createDecoder(BitArray information){
|
||||
public static AbstractExpandedDecoder createDecoder(BitArray information) {
|
||||
if (information.get(1)) {
|
||||
return new AI01AndOtherAIs(information);
|
||||
}
|
||||
|
@ -64,19 +64,19 @@ public abstract class AbstractExpandedDecoder {
|
|||
|
||||
int fourBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 4);
|
||||
|
||||
switch(fourBitEncodationMethod){
|
||||
switch (fourBitEncodationMethod) {
|
||||
case 4: return new AI013103decoder(information);
|
||||
case 5: return new AI01320xDecoder(information);
|
||||
}
|
||||
|
||||
int fiveBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 5);
|
||||
switch(fiveBitEncodationMethod){
|
||||
switch (fiveBitEncodationMethod) {
|
||||
case 12: return new AI01392xDecoder(information);
|
||||
case 13: return new AI01393xDecoder(information);
|
||||
}
|
||||
|
||||
int sevenBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 7);
|
||||
switch(sevenBitEncodationMethod){
|
||||
switch (sevenBitEncodationMethod) {
|
||||
case 56: return new AI013x0x1xDecoder(information, "310", "11");
|
||||
case 57: return new AI013x0x1xDecoder(information, "320", "11");
|
||||
case 58: return new AI013x0x1xDecoder(information, "310", "13");
|
||||
|
|
|
@ -57,15 +57,15 @@ final class CurrentParsingState {
|
|||
position += delta;
|
||||
}
|
||||
|
||||
boolean isAlpha(){
|
||||
boolean isAlpha() {
|
||||
return this.encoding == State.ALPHA;
|
||||
}
|
||||
|
||||
boolean isNumeric(){
|
||||
boolean isNumeric() {
|
||||
return this.encoding == State.NUMERIC;
|
||||
}
|
||||
|
||||
boolean isIsoIec646(){
|
||||
boolean isIsoIec646() {
|
||||
return this.encoding == State.ISO_IEC_646;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ final class DecodedChar extends DecodedObject {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
char getValue(){
|
||||
char getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
boolean isFNC1(){
|
||||
boolean isFNC1() {
|
||||
return this.value == FNC1;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,29 +36,29 @@ final class DecodedInformation extends DecodedObject {
|
|||
private final int remainingValue;
|
||||
private final boolean remaining;
|
||||
|
||||
DecodedInformation(int newPosition, String newString){
|
||||
DecodedInformation(int newPosition, String newString) {
|
||||
super(newPosition);
|
||||
this.newString = newString;
|
||||
this.remaining = false;
|
||||
this.remainingValue = 0;
|
||||
}
|
||||
|
||||
DecodedInformation(int newPosition, String newString, int remainingValue){
|
||||
DecodedInformation(int newPosition, String newString, int remainingValue) {
|
||||
super(newPosition);
|
||||
this.remaining = true;
|
||||
this.remainingValue = remainingValue;
|
||||
this.newString = newString;
|
||||
}
|
||||
|
||||
String getNewString(){
|
||||
String getNewString() {
|
||||
return this.newString;
|
||||
}
|
||||
|
||||
boolean isRemaining(){
|
||||
boolean isRemaining() {
|
||||
return this.remaining;
|
||||
}
|
||||
|
||||
int getRemainingValue(){
|
||||
int getRemainingValue() {
|
||||
return this.remainingValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,27 +50,27 @@ final class DecodedNumeric extends DecodedObject {
|
|||
this.secondDigit = secondDigit;
|
||||
}
|
||||
|
||||
int getFirstDigit(){
|
||||
int getFirstDigit() {
|
||||
return this.firstDigit;
|
||||
}
|
||||
|
||||
int getSecondDigit(){
|
||||
int getSecondDigit() {
|
||||
return this.secondDigit;
|
||||
}
|
||||
|
||||
int getValue(){
|
||||
int getValue() {
|
||||
return this.firstDigit * 10 + this.secondDigit;
|
||||
}
|
||||
|
||||
boolean isFirstDigitFNC1(){
|
||||
boolean isFirstDigitFNC1() {
|
||||
return this.firstDigit == FNC1;
|
||||
}
|
||||
|
||||
boolean isSecondDigitFNC1(){
|
||||
boolean isSecondDigitFNC1() {
|
||||
return this.secondDigit == FNC1;
|
||||
}
|
||||
|
||||
boolean isAnyFNC1(){
|
||||
boolean isAnyFNC1() {
|
||||
return this.firstDigit == FNC1 || this.secondDigit == FNC1;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ abstract class DecodedObject {
|
|||
|
||||
private final int newPosition;
|
||||
|
||||
DecodedObject(int newPosition){
|
||||
DecodedObject(int newPosition) {
|
||||
this.newPosition = newPosition;
|
||||
}
|
||||
|
||||
|
|
|
@ -190,14 +190,14 @@ final class FieldParser {
|
|||
private FieldParser() {
|
||||
}
|
||||
|
||||
static String parseFieldsInGeneralPurpose(String rawInformation) throws NotFoundException{
|
||||
static String parseFieldsInGeneralPurpose(String rawInformation) throws NotFoundException {
|
||||
if (rawInformation.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Processing 2-digit AIs
|
||||
|
||||
if(rawInformation.length() < 2) {
|
||||
if (rawInformation.length() < 2) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ final class FieldParser {
|
|||
}
|
||||
}
|
||||
|
||||
if(rawInformation.length() < 3) {
|
||||
if (rawInformation.length() < 3) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ final class FieldParser {
|
|||
}
|
||||
}
|
||||
|
||||
if(rawInformation.length() < 4) {
|
||||
if (rawInformation.length() < 4) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
@ -255,14 +255,14 @@ final class FieldParser {
|
|||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
private static String processFixedAI(int aiSize, int fieldSize, String rawInformation) throws NotFoundException{
|
||||
private static String processFixedAI(int aiSize, int fieldSize, String rawInformation) throws NotFoundException {
|
||||
if (rawInformation.length() < aiSize) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
String ai = rawInformation.substring(0, aiSize);
|
||||
|
||||
if(rawInformation.length() < aiSize + fieldSize) {
|
||||
if (rawInformation.length() < aiSize + fieldSize) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,30 +40,30 @@ final class GeneralAppIdDecoder {
|
|||
private final CurrentParsingState current = new CurrentParsingState();
|
||||
private final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
GeneralAppIdDecoder(BitArray information){
|
||||
GeneralAppIdDecoder(BitArray information) {
|
||||
this.information = information;
|
||||
}
|
||||
|
||||
String decodeAllCodes(StringBuilder buff, int initialPosition) throws NotFoundException, FormatException {
|
||||
int currentPosition = initialPosition;
|
||||
String remaining = null;
|
||||
do{
|
||||
do {
|
||||
DecodedInformation info = this.decodeGeneralPurposeField(currentPosition, remaining);
|
||||
String parsedFields = FieldParser.parseFieldsInGeneralPurpose(info.getNewString());
|
||||
if (parsedFields != null) {
|
||||
buff.append(parsedFields);
|
||||
}
|
||||
if(info.isRemaining()) {
|
||||
if (info.isRemaining()) {
|
||||
remaining = String.valueOf(info.getRemainingValue());
|
||||
} else {
|
||||
remaining = null;
|
||||
}
|
||||
|
||||
if(currentPosition == info.getNewPosition()) {// No step forward!
|
||||
if (currentPosition == info.getNewPosition()) { // No step forward!
|
||||
break;
|
||||
}
|
||||
currentPosition = info.getNewPosition();
|
||||
}while(true);
|
||||
} while (true);
|
||||
|
||||
return buff.toString();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ final class GeneralAppIdDecoder {
|
|||
private boolean isStillNumeric(int pos) {
|
||||
// It's numeric if it still has 7 positions
|
||||
// and one of the first 4 bits is "1".
|
||||
if(pos + 7 > this.information.getSize()){
|
||||
if (pos + 7 > this.information.getSize()) {
|
||||
return pos + 4 <= this.information.getSize();
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,9 @@ final class GeneralAppIdDecoder {
|
|||
}
|
||||
|
||||
private DecodedNumeric decodeNumeric(int pos) throws FormatException {
|
||||
if(pos + 7 > this.information.getSize()){
|
||||
if (pos + 7 > this.information.getSize()) {
|
||||
int numeric = extractNumericValueFromBitArray(pos, 4);
|
||||
if(numeric == 0) {
|
||||
if (numeric == 0) {
|
||||
return new DecodedNumeric(this.information.getSize(), DecodedNumeric.FNC1, DecodedNumeric.FNC1);
|
||||
}
|
||||
return new DecodedNumeric(this.information.getSize(), numeric - 1, DecodedNumeric.FNC1);
|
||||
|
@ -100,7 +100,7 @@ final class GeneralAppIdDecoder {
|
|||
return new DecodedNumeric(pos + 7, digit1, digit2);
|
||||
}
|
||||
|
||||
int extractNumericValueFromBitArray(int pos, int bits){
|
||||
int extractNumericValueFromBitArray(int pos, int bits) {
|
||||
return extractNumericValueFromBitArray(this.information, pos, bits);
|
||||
}
|
||||
|
||||
|
@ -118,14 +118,14 @@ final class GeneralAppIdDecoder {
|
|||
DecodedInformation decodeGeneralPurposeField(int pos, String remaining) throws FormatException {
|
||||
this.buffer.setLength(0);
|
||||
|
||||
if(remaining != null) {
|
||||
if (remaining != null) {
|
||||
this.buffer.append(remaining);
|
||||
}
|
||||
|
||||
this.current.setPosition(pos);
|
||||
|
||||
DecodedInformation lastDecoded = parseBlocks();
|
||||
if(lastDecoded != null && lastDecoded.isRemaining()) {
|
||||
if (lastDecoded != null && lastDecoded.isRemaining()) {
|
||||
return new DecodedInformation(this.current.getPosition(), this.buffer.toString(), lastDecoded.getRemainingValue());
|
||||
}
|
||||
return new DecodedInformation(this.current.getPosition(), this.buffer.toString());
|
||||
|
@ -134,22 +134,22 @@ final class GeneralAppIdDecoder {
|
|||
private DecodedInformation parseBlocks() throws FormatException {
|
||||
boolean isFinished;
|
||||
BlockParsedResult result;
|
||||
do{
|
||||
do {
|
||||
int initialPosition = current.getPosition();
|
||||
|
||||
if (current.isAlpha()){
|
||||
if (current.isAlpha()) {
|
||||
result = parseAlphaBlock();
|
||||
isFinished = result.isFinished();
|
||||
}else if (current.isIsoIec646()){
|
||||
} else if (current.isIsoIec646()) {
|
||||
result = parseIsoIec646Block();
|
||||
isFinished = result.isFinished();
|
||||
}else{ // it must be numeric
|
||||
} else { // it must be numeric
|
||||
result = parseNumericBlock();
|
||||
isFinished = result.isFinished();
|
||||
}
|
||||
|
||||
boolean positionChanged = initialPosition != current.getPosition();
|
||||
if(!positionChanged && !isFinished) {
|
||||
if (!positionChanged && !isFinished) {
|
||||
break;
|
||||
}
|
||||
} while (!isFinished);
|
||||
|
@ -162,7 +162,7 @@ final class GeneralAppIdDecoder {
|
|||
DecodedNumeric numeric = decodeNumeric(current.getPosition());
|
||||
current.setPosition(numeric.getNewPosition());
|
||||
|
||||
if(numeric.isFirstDigitFNC1()){
|
||||
if (numeric.isFirstDigitFNC1()) {
|
||||
DecodedInformation information;
|
||||
if (numeric.isSecondDigitFNC1()) {
|
||||
information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
|
@ -173,7 +173,7 @@ final class GeneralAppIdDecoder {
|
|||
}
|
||||
buffer.append(numeric.getFirstDigit());
|
||||
|
||||
if(numeric.isSecondDigitFNC1()){
|
||||
if (numeric.isSecondDigitFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ final class GeneralAppIdDecoder {
|
|||
DecodedChar alpha = decodeAlphanumeric(current.getPosition());
|
||||
current.setPosition(alpha.getNewPosition());
|
||||
|
||||
if(alpha.isFNC1()) {
|
||||
if (alpha.isFNC1()) {
|
||||
DecodedInformation information = new DecodedInformation(current.getPosition(), buffer.toString());
|
||||
return new BlockParsedResult(information, true); //end of the char block
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ final class GeneralAppIdDecoder {
|
|||
}
|
||||
|
||||
int sevenBitValue = extractNumericValueFromBitArray(pos, 7);
|
||||
if(sevenBitValue >= 64 && sevenBitValue < 116) {
|
||||
if (sevenBitValue >= 64 && sevenBitValue < 116) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ final class GeneralAppIdDecoder {
|
|||
}
|
||||
|
||||
private boolean isStillAlpha(int pos) {
|
||||
if(pos + 5 > this.information.getSize()) {
|
||||
if (pos + 5 > this.information.getSize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,7 @@ final class GeneralAppIdDecoder {
|
|||
}
|
||||
|
||||
char c;
|
||||
switch (sixBitValue){
|
||||
switch (sixBitValue) {
|
||||
case 58:
|
||||
c = '*';
|
||||
break;
|
||||
|
@ -426,7 +426,7 @@ final class GeneralAppIdDecoder {
|
|||
}
|
||||
|
||||
for (int i = 0; i < 5 && i + pos < this.information.getSize(); ++i) {
|
||||
if(i == 2){
|
||||
if (i == 2) {
|
||||
if (!this.information.get(pos + 2)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public final class ModulusGF {
|
|||
expTable[i] = x;
|
||||
x = (x * generator) % modulus;
|
||||
}
|
||||
for (int i = 0; i < modulus-1; i++) {
|
||||
for (int i = 0; i < modulus - e1; i++) {
|
||||
logTable[expTable[i]] = i;
|
||||
}
|
||||
// logTable[0] == 0 but this should never be used
|
||||
|
|
|
@ -81,7 +81,7 @@ enum DataMask {
|
|||
DATA_MASK_100() {
|
||||
@Override
|
||||
boolean isMasked(int i, int j) {
|
||||
return (((i / 2) + (j /3)) & 0x01) == 0;
|
||||
return (((i / 2) + (j / 3)) & 0x01) == 0;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -383,7 +383,7 @@ public final class Encoder {
|
|||
|
||||
int size = numDataBytesInBlock[0];
|
||||
byte[] dataBytes = new byte[size];
|
||||
bits.toBytes(8*dataBytesOffset, dataBytes, 0, size);
|
||||
bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size);
|
||||
byte[] ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]);
|
||||
blocks.add(new BlockPair(dataBytes, ecBytes));
|
||||
|
||||
|
|
|
@ -224,14 +224,14 @@ public final class BitMatrixTestCase extends Assert {
|
|||
try {
|
||||
emptyMatrix.clone().xor(badMatrix);
|
||||
fail();
|
||||
} catch(IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// good
|
||||
}
|
||||
|
||||
try {
|
||||
badMatrix.clone().xor(emptyMatrix);
|
||||
fail();
|
||||
} catch(IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
// good
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public final class BinaryUtil {
|
|||
BitArray binary = new BitArray(SPACE.matcher(dotsAndXs).replaceAll("").length());
|
||||
int counter = 0;
|
||||
|
||||
for(int i = 0; i < dotsAndXs.length(); ++i){
|
||||
for (int i = 0; i < dotsAndXs.length(); ++i) {
|
||||
if (i % 9 == 0) { // spaces
|
||||
if (dotsAndXs.charAt(i) != ' ') {
|
||||
throw new IllegalStateException("space expected");
|
||||
|
|
|
@ -41,7 +41,7 @@ public final class BinaryUtilTest extends Assert {
|
|||
private static final Pattern SPACE = Pattern.compile(" ");
|
||||
|
||||
@Test
|
||||
public void testBuildBitArrayFromString(){
|
||||
public void testBuildBitArrayFromString() {
|
||||
|
||||
CharSequence data = " ..X..X.. ..XXX... XXXXXXXX ........";
|
||||
check(data);
|
||||
|
@ -59,13 +59,13 @@ public final class BinaryUtilTest extends Assert {
|
|||
check(data);
|
||||
}
|
||||
|
||||
private static void check(CharSequence data){
|
||||
private static void check(CharSequence data) {
|
||||
BitArray binary = BinaryUtil.buildBitArrayFromString(data);
|
||||
assertEquals(data, binary.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildBitArrayFromStringWithoutSpaces(){
|
||||
public void testBuildBitArrayFromStringWithoutSpaces() {
|
||||
CharSequence data = " ..X..X.. ..XXX... XXXXXXXX ........";
|
||||
checkWithoutSpaces(data);
|
||||
|
||||
|
@ -82,7 +82,7 @@ public final class BinaryUtilTest extends Assert {
|
|||
checkWithoutSpaces(data);
|
||||
}
|
||||
|
||||
private static void checkWithoutSpaces(CharSequence data){
|
||||
private static void checkWithoutSpaces(CharSequence data) {
|
||||
CharSequence dataWithoutSpaces = SPACE.matcher(data).replaceAll("");
|
||||
BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(dataWithoutSpaces);
|
||||
assertEquals(data, binary.toString());
|
||||
|
|
|
@ -57,20 +57,20 @@ public final class BitArrayBuilderTest extends Assert {
|
|||
|
||||
private static BitArray buildBitArray(int[][] pairValues) {
|
||||
List<ExpandedPair> pairs = new ArrayList<>();
|
||||
for(int i = 0; i < pairValues.length; ++i){
|
||||
for (int i = 0; i < pairValues.length; ++i) {
|
||||
int [] pair = pairValues[i];
|
||||
|
||||
DataCharacter leftChar;
|
||||
if(i == 0) {
|
||||
if (i == 0) {
|
||||
leftChar = null;
|
||||
} else {
|
||||
leftChar = new DataCharacter(pair[0], 0);
|
||||
}
|
||||
|
||||
DataCharacter rightChar;
|
||||
if(i == 0) {
|
||||
if (i == 0) {
|
||||
rightChar = new DataCharacter(pair[0], 0);
|
||||
} else if(pair.length == 2) {
|
||||
} else if (pair.length == 2) {
|
||||
rightChar = new DataCharacter(pair[1], 0);
|
||||
} else {
|
||||
rightChar = null;
|
||||
|
|
|
@ -84,7 +84,7 @@ public final class RSSExpandedInternalTestCase extends Assert {
|
|||
rssExpandedReader.retrieveNextPair(row, previousPairs, rowNumber);
|
||||
// the previous was the last pair
|
||||
fail(NotFoundException.class.getName() + " expected");
|
||||
}catch(NotFoundException nfe){
|
||||
} catch (NotFoundException nfe) {
|
||||
// ok
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ final class DecoderConfig {
|
|||
description = "Use the TRY_HARDER hint, default is normal mode")
|
||||
boolean tryHarder;
|
||||
|
||||
@Parameter(names="--pure_barcode",
|
||||
description="Input image is a pure monochrome barcode image, not a photo")
|
||||
@Parameter(names = "--pure_barcode",
|
||||
description = "Input image is a pure monochrome barcode image, not a photo")
|
||||
boolean pureBarcode;
|
||||
|
||||
@Parameter(names = "--products_only",
|
||||
|
|
7
pom.xml
7
pom.xml
|
@ -524,6 +524,13 @@
|
|||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>6.19</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.rat</groupId>
|
||||
|
|
|
@ -119,13 +119,15 @@
|
|||
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<!-- <module name="NoWhitespaceAfter"/> -->
|
||||
<!-- <module name="NoWhitespaceBefore"/> -->
|
||||
<!-- <module name="OperatorWrap"/> -->
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<!-- <module name="WhitespaceAfter"/> -->
|
||||
<!-- <module name="WhitespaceAround"/> -->
|
||||
<module name="WhitespaceAfter">
|
||||
<property name="tokens" value="TYPECAST, SEMI"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
</module>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
|
||||
|
||||
|
@ -154,11 +156,14 @@
|
|||
<module name="EqualsHashCode"/>
|
||||
<!--<module name="HiddenField"/>-->
|
||||
<module name="IllegalInstantiation"/>
|
||||
<module name="IllegalType"/>
|
||||
<!-- <module name="InnerAssignment"/> -->
|
||||
<!-- <module name="MagicNumber"/> -->
|
||||
<!-- <module name="MissingSwitchDefault"/> -->
|
||||
<module name="MissingDeprecated"/>
|
||||
<module name="MissingOverride"/>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="DefaultComesLast"/>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
|
@ -178,7 +183,6 @@
|
|||
<!-- Miscellaneous other checks. -->
|
||||
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<!--<module name="FinalParameters"/>-->
|
||||
<!-- <module name="TodoComment"/> -->
|
||||
<module name="UpperEll"/>
|
||||
|
|
|
@ -122,10 +122,10 @@ public final class Generator implements EntryPoint {
|
|||
|
||||
void setupLeftPanel() {
|
||||
topPanel.setHTML(2, 0,
|
||||
"<span id=\"errorMessageID\" class=\""+StylesDefs.ERROR_MESSAGE+"\"></span>");
|
||||
"<span id=\"errorMessageID\" class=\"" + StylesDefs.ERROR_MESSAGE + "\"></span>");
|
||||
|
||||
// fills up the list of generators
|
||||
for(GeneratorSource generator: generators) {
|
||||
for (GeneratorSource generator: generators) {
|
||||
genList.addItem(generator.getName());
|
||||
setGridStyle(generator.getWidget());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue