Clean up whitespace (#800)

This commit is contained in:
David Sanders 2017-05-14 09:54:32 -07:00 committed by Sean Owen
parent 5a5237b4a8
commit 7df4aa6694
76 changed files with 262 additions and 264 deletions

View file

@ -114,7 +114,7 @@ public enum DecodeHintType {
DecodeHintType(Class<?> valueType) { DecodeHintType(Class<?> valueType) {
this.valueType = valueType; this.valueType = valueType;
} }
public Class<?> getValueType() { public Class<?> getValueType() {
return valueType; return valueType;
} }

View file

@ -23,7 +23,7 @@ public final class Dimension {
private final int width; private final int width;
private final int height; private final int height;
public Dimension(int width, int height) { public Dimension(int width, int height) {
if (width < 0 || height < 0) { if (width < 0 || height < 0) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -40,7 +40,7 @@ public final class Dimension {
return height; return height;
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof Dimension) { if (other instanceof Dimension) {
Dimension d = (Dimension) other; Dimension d = (Dimension) other;
@ -49,7 +49,7 @@ public final class Dimension {
return false; return false;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return width * 32713 + height; return width * 32713 + height;
} }

View file

@ -95,7 +95,7 @@ public enum EncodeHintType {
* (Type {@link Integer}, or {@link String} representation of the integer value). * (Type {@link Integer}, or {@link String} representation of the integer value).
*/ */
AZTEC_LAYERS, AZTEC_LAYERS,
/** /**
* Specifies the exact version of QR code to be encoded. * Specifies the exact version of QR code to be encoded.
* (Type {@link Integer}, or {@link String} representation of the integer value). * (Type {@link Integer}, or {@link String} representation of the integer value).

View file

@ -40,8 +40,8 @@ public final class FormatException extends ReaderException {
public static FormatException getFormatInstance() { public static FormatException getFormatInstance() {
return isStackTrace ? new FormatException() : INSTANCE; return isStackTrace ? new FormatException() : INSTANCE;
} }
public static FormatException getFormatInstance(Throwable cause) { public static FormatException getFormatInstance(Throwable cause) {
return isStackTrace ? new FormatException(cause) : INSTANCE; return isStackTrace ? new FormatException(cause) : INSTANCE;
} }
} }

View file

@ -19,7 +19,7 @@ package com.google.zxing;
/** /**
* A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes * A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes
* white and vice versa, and each value becomes (255-value). * white and vice versa, and each value becomes (255-value).
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class InvertedLuminanceSource extends LuminanceSource { public final class InvertedLuminanceSource extends LuminanceSource {
@ -51,7 +51,7 @@ public final class InvertedLuminanceSource extends LuminanceSource {
} }
return invertedMatrix; return invertedMatrix;
} }
@Override @Override
public boolean isCropSupported() { public boolean isCropSupported() {
return delegate.isCropSupported(); return delegate.isCropSupported();

View file

@ -29,7 +29,7 @@ package com.google.zxing;
public final class PlanarYUVLuminanceSource extends LuminanceSource { public final class PlanarYUVLuminanceSource extends LuminanceSource {
private static final int THUMBNAIL_SCALE_FACTOR = 2; private static final int THUMBNAIL_SCALE_FACTOR = 2;
private final byte[] yuvData; private final byte[] yuvData;
private final int dataWidth; private final int dataWidth;
private final int dataHeight; private final int dataHeight;
@ -138,17 +138,17 @@ public final class PlanarYUVLuminanceSource extends LuminanceSource {
} }
return pixels; return pixels;
} }
/** /**
* @return width of image from {@link #renderThumbnail()} * @return width of image from {@link #renderThumbnail()}
*/ */
public int getThumbnailWidth() { public int getThumbnailWidth() {
return getWidth() / THUMBNAIL_SCALE_FACTOR; return getWidth() / THUMBNAIL_SCALE_FACTOR;
} }
/** /**
* @return height of image from {@link #renderThumbnail()} * @return height of image from {@link #renderThumbnail()}
*/ */
public int getThumbnailHeight() { public int getThumbnailHeight() {
return getHeight() / THUMBNAIL_SCALE_FACTOR; return getHeight() / THUMBNAIL_SCALE_FACTOR;
} }

View file

@ -54,7 +54,7 @@ public final class RGBLuminanceSource extends LuminanceSource {
luminances[offset] = (byte) ((r + g2 + b) / 4); luminances[offset] = (byte) ((r + g2 + b) / 4);
} }
} }
private RGBLuminanceSource(byte[] pixels, private RGBLuminanceSource(byte[] pixels,
int dataWidth, int dataWidth,
int dataHeight, int dataHeight,
@ -116,7 +116,7 @@ public final class RGBLuminanceSource extends LuminanceSource {
} }
return matrix; return matrix;
} }
@Override @Override
public boolean isCropSupported() { public boolean isCropSupported() {
return true; return true;

View file

@ -66,4 +66,4 @@ public interface Reader {
*/ */
void reset(); void reset();
} }

View file

@ -64,7 +64,7 @@ public enum ResultMetadataType {
* For some products, indicates the suggested retail price in the barcode as a * For some products, indicates the suggested retail price in the barcode as a
* formatted {@link String}. * formatted {@link String}.
*/ */
SUGGESTED_PRICE , SUGGESTED_PRICE,
/** /**
* For some products, the possible country of manufacture as a {@link String} denoting the * For some products, the possible country of manufacture as a {@link String} denoting the
@ -93,5 +93,5 @@ public enum ResultMetadataType {
* parity is given with it. * parity is given with it.
*/ */
STRUCTURED_APPEND_PARITY, STRUCTURED_APPEND_PARITY,
} }

View file

@ -107,7 +107,6 @@ public class ResultPoint {
patterns[2] = pointC; patterns[2] = pointC;
} }
/** /**
* @param pattern1 first pattern * @param pattern1 first pattern
* @param pattern2 second pattern * @param pattern2 second pattern
@ -128,5 +127,4 @@ public class ResultPoint {
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX)); return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
} }
} }

View file

@ -30,7 +30,7 @@ public final class WriterException extends Exception {
public WriterException(String message) { public WriterException(String message) {
super(message); super(message);
} }
public WriterException(Throwable cause) { public WriterException(Throwable cause) {
super(cause); super(cause);
} }

View file

@ -101,7 +101,7 @@ public final class AztecReader implements Reader {
points, points,
BarcodeFormat.AZTEC, BarcodeFormat.AZTEC,
System.currentTimeMillis()); System.currentTimeMillis());
List<byte[]> byteSegments = decoderResult.getByteSegments(); List<byte[]> byteSegments = decoderResult.getByteSegments();
if (byteSegments != null) { if (byteSegments != null) {
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
@ -110,7 +110,7 @@ public final class AztecReader implements Reader {
if (ecLevel != null) { if (ecLevel != null) {
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
} }
return result; return result;
} }

View file

@ -30,7 +30,7 @@ import java.util.Map;
* Renders an Aztec code as a {@link BitMatrix}. * Renders an Aztec code as a {@link BitMatrix}.
*/ */
public final class AztecWriter implements Writer { public final class AztecWriter implements Writer {
private static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1"); private static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
@Override @Override

View file

@ -76,17 +76,17 @@ public final class Detector {
// 3. Get the size of the matrix and other parameters from the bull's eye // 3. Get the size of the matrix and other parameters from the bull's eye
extractParameters(bullsEyeCorners); extractParameters(bullsEyeCorners);
// 4. Sample the grid // 4. Sample the grid
BitMatrix bits = sampleGrid(image, BitMatrix bits = sampleGrid(image,
bullsEyeCorners[shift % 4], bullsEyeCorners[shift % 4],
bullsEyeCorners[(shift + 1) % 4], bullsEyeCorners[(shift + 1) % 4],
bullsEyeCorners[(shift + 2) % 4], bullsEyeCorners[(shift + 2) % 4],
bullsEyeCorners[(shift + 3) % 4]); bullsEyeCorners[(shift + 3) % 4]);
// 5. Get the corners of the matrix. // 5. Get the corners of the matrix.
ResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners); ResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners);
return new AztecDetectorResult(bits, corners, compact, nbDataBlocks, nbLayers); return new AztecDetectorResult(bits, corners, compact, nbDataBlocks, nbLayers);
} }
@ -105,13 +105,13 @@ public final class Detector {
// Get the bits around the bull's eye // Get the bits around the bull's eye
int[] sides = { int[] sides = {
sampleLine(bullsEyeCorners[0], bullsEyeCorners[1], length), // Right side sampleLine(bullsEyeCorners[0], bullsEyeCorners[1], length), // Right side
sampleLine(bullsEyeCorners[1], bullsEyeCorners[2], length), // Bottom sampleLine(bullsEyeCorners[1], bullsEyeCorners[2], length), // Bottom
sampleLine(bullsEyeCorners[2], bullsEyeCorners[3], length), // Left side sampleLine(bullsEyeCorners[2], bullsEyeCorners[3], length), // Left side
sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top
}; };
// bullsEyeCorners[shift] is the corner of the bulls'eye that has three // bullsEyeCorners[shift] is the corner of the bulls'eye that has three
// orientation marks. // orientation marks.
// sides[shift] is the row/column that goes from the corner with three // sides[shift] is the row/column that goes from the corner with three
// orientation marks to the corner with two. // orientation marks to the corner with two.
shift = getRotation(sides, length); shift = getRotation(sides, length);
@ -130,11 +130,11 @@ public final class Detector {
parameterData += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F); parameterData += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F);
} }
} }
// Corrects parameter data using RS. Returns just the data portion // Corrects parameter data using RS. Returns just the data portion
// without the error correction. // without the error correction.
int correctedData = getCorrectedParameterData(parameterData, compact); int correctedData = getCorrectedParameterData(parameterData, compact);
if (compact) { if (compact) {
// 8 bits: 2 bits layers and 6 bits data blocks // 8 bits: 2 bits layers and 6 bits data blocks
nbLayers = (correctedData >> 6) + 1; nbLayers = (correctedData >> 6) + 1;
@ -222,25 +222,25 @@ public final class Detector {
} }
return result; return result;
} }
/** /**
* Finds the corners of a bull-eye centered on the passed point. * Finds the corners of a bull-eye centered on the passed point.
* This returns the centers of the diagonal points just outside the bull's eye * This returns the centers of the diagonal points just outside the bull's eye
* Returns [topRight, bottomRight, bottomLeft, topLeft] * Returns [topRight, bottomRight, bottomLeft, topLeft]
* *
* @param pCenter Center point * @param pCenter Center point
* @return The corners of the bull-eye * @return The corners of the bull-eye
* @throws NotFoundException If no valid bull-eye can be found * @throws NotFoundException If no valid bull-eye can be found
*/ */
private ResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException { private ResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException {
Point pina = pCenter; Point pina = pCenter;
Point pinb = pCenter; Point pinb = pCenter;
Point pinc = pCenter; Point pinc = pCenter;
Point pind = pCenter; Point pind = pCenter;
boolean color = true; boolean color = true;
for (nbCenterLayers = 1; nbCenterLayers < 9; nbCenterLayers++) { for (nbCenterLayers = 1; nbCenterLayers < 9; nbCenterLayers++) {
Point pouta = getFirstDifferent(pina, color, 1, -1); Point pouta = getFirstDifferent(pina, color, 1, -1);
Point poutb = getFirstDifferent(pinb, color, 1, 1); Point poutb = getFirstDifferent(pinb, color, 1, 1);
@ -269,9 +269,9 @@ public final class Detector {
if (nbCenterLayers != 5 && nbCenterLayers != 7) { if (nbCenterLayers != 5 && nbCenterLayers != 7) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
compact = nbCenterLayers == 5; compact = nbCenterLayers == 5;
// Expand the square by .5 pixel in each direction so that we're on the border // Expand the square by .5 pixel in each direction so that we're on the border
// between the white square and the black square // between the white square and the black square
ResultPoint pinax = new ResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f); ResultPoint pinax = new ResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f);
@ -319,7 +319,7 @@ public final class Detector {
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
} }
//Compute the center of the rectangle //Compute the center of the rectangle
int cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f); int cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f);
int cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f); int cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f);
@ -341,7 +341,7 @@ public final class Detector {
pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint(); pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
} }
// Recompute the center of the rectangle // Recompute the center of the rectangle
cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f); cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f);
cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f); cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f);
@ -369,7 +369,7 @@ public final class Detector {
ResultPoint topRight, ResultPoint topRight,
ResultPoint bottomRight, ResultPoint bottomRight,
ResultPoint bottomLeft) throws NotFoundException { ResultPoint bottomLeft) throws NotFoundException {
GridSampler sampler = GridSampler.getInstance(); GridSampler sampler = GridSampler.getInstance();
int dimension = getDimension(); int dimension = getDimension();

View file

@ -20,7 +20,7 @@ import com.google.zxing.common.BitMatrix;
/** /**
* Aztec 2D code representation * Aztec 2D code representation
* *
* @author Rustam Abdullaev * @author Rustam Abdullaev
*/ */
public final class AztecCode { public final class AztecCode {
@ -52,14 +52,14 @@ public final class AztecCode {
public void setSize(int size) { public void setSize(int size) {
this.size = size; this.size = size;
} }
/** /**
* @return number of levels * @return number of levels
*/ */
public int getLayers() { public int getLayers() {
return layers; return layers;
} }
public void setLayers(int layers) { public void setLayers(int layers) {
this.layers = layers; this.layers = layers;
} }

View file

@ -19,10 +19,10 @@ package com.google.zxing.aztec.encoder;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
final class BinaryShiftToken extends Token { final class BinaryShiftToken extends Token {
private final short binaryShiftStart; private final short binaryShiftStart;
private final short binaryShiftByteCount; private final short binaryShiftByteCount;
BinaryShiftToken(Token previous, BinaryShiftToken(Token previous,
int binaryShiftStart, int binaryShiftStart,
int binaryShiftByteCount) { int binaryShiftByteCount) {
@ -34,7 +34,7 @@ final class BinaryShiftToken extends Token {
@Override @Override
public void appendTo(BitArray bitArray, byte[] text) { public void appendTo(BitArray bitArray, byte[] text) {
for (int i = 0; i < binaryShiftByteCount; i++) { for (int i = 0; i < binaryShiftByteCount; i++) {
if (i == 0 || (i == 31 && binaryShiftByteCount <= 62)) { if (i == 0 || (i == 31 && binaryShiftByteCount <= 62)) {
// We need a header before the first character, and before // We need a header before the first character, and before
// character 31 when the total byte code is <= 62 // character 31 when the total byte code is <= 62
bitArray.appendBits(31, 5); // BINARY_SHIFT bitArray.appendBits(31, 5); // BINARY_SHIFT

View file

@ -43,17 +43,17 @@ public final class Encoder {
/** /**
* Encodes the given binary content as an Aztec symbol * Encodes the given binary content as an Aztec symbol
* *
* @param data input data string * @param data input data string
* @return Aztec symbol matrix with metadata * @return Aztec symbol matrix with metadata
*/ */
public static AztecCode encode(byte[] data) { public static AztecCode encode(byte[] data) {
return encode(data, DEFAULT_EC_PERCENT, DEFAULT_AZTEC_LAYERS); return encode(data, DEFAULT_EC_PERCENT, DEFAULT_AZTEC_LAYERS);
} }
/** /**
* Encodes the given binary content as an Aztec symbol * Encodes the given binary content as an Aztec symbol
* *
* @param data input data string * @param data input data string
* @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008, * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008,
* a minimum of 23% + 3 words is recommended) * a minimum of 23% + 3 words is recommended)
@ -63,7 +63,7 @@ public final class Encoder {
public static AztecCode encode(byte[] data, int minECCPercent, int userSpecifiedLayers) { public static AztecCode encode(byte[] data, int minECCPercent, int userSpecifiedLayers) {
// High-level encode // High-level encode
BitArray bits = new HighLevelEncoder(data).encode(); BitArray bits = new HighLevelEncoder(data).encode();
// stuff bits and choose symbol size // stuff bits and choose symbol size
int eccBits = bits.getSize() * minECCPercent / 100 + 11; int eccBits = bits.getSize() * minECCPercent / 100 + 11;
int totalSizeBits = bits.getSize() + eccBits; int totalSizeBits = bits.getSize() + eccBits;
@ -123,7 +123,7 @@ public final class Encoder {
} }
} }
BitArray messageBits = generateCheckWords(stuffedBits, totalBitsInLayer, wordSize); BitArray messageBits = generateCheckWords(stuffedBits, totalBitsInLayer, wordSize);
// generate mode message // generate mode message
int messageSizeInWords = stuffedBits.getSize() / wordSize; int messageSizeInWords = stuffedBits.getSize() / wordSize;
BitArray modeMessage = generateModeMessage(compact, layers, messageSizeInWords); BitArray modeMessage = generateModeMessage(compact, layers, messageSizeInWords);
@ -149,7 +149,7 @@ public final class Encoder {
} }
} }
BitMatrix matrix = new BitMatrix(matrixSize); BitMatrix matrix = new BitMatrix(matrixSize);
// draw data bits // draw data bits
for (int i = 0, rowOffset = 0; i < layers; i++) { for (int i = 0, rowOffset = 0; i < layers; i++) {
int rowSize = (layers - i) * 4 + (compact ? 9 : 12); int rowSize = (layers - i) * 4 + (compact ? 9 : 12);
@ -175,7 +175,7 @@ public final class Encoder {
// draw mode message // draw mode message
drawModeMessage(matrix, compact, matrixSize, modeMessage); drawModeMessage(matrix, compact, matrixSize, modeMessage);
// draw alignment marks // draw alignment marks
if (compact) { if (compact) {
drawBullsEye(matrix, matrixSize / 2, 5); drawBullsEye(matrix, matrixSize / 2, 5);
@ -190,7 +190,7 @@ public final class Encoder {
} }
} }
} }
AztecCode aztec = new AztecCode(); AztecCode aztec = new AztecCode();
aztec.setCompact(compact); aztec.setCompact(compact);
aztec.setSize(matrixSize); aztec.setSize(matrixSize);
@ -199,7 +199,7 @@ public final class Encoder {
aztec.setMatrix(matrix); aztec.setMatrix(matrix);
return aztec; return aztec;
} }
private static void drawBullsEye(BitMatrix matrix, int center, int size) { private static void drawBullsEye(BitMatrix matrix, int center, int size) {
for (int i = 0; i < size; i += 2) { for (int i = 0; i < size; i += 2) {
for (int j = center - i; j <= center + i; j++) { for (int j = center - i; j <= center + i; j++) {
@ -216,7 +216,7 @@ public final class Encoder {
matrix.set(center + size, center - size + 1); matrix.set(center + size, center - size + 1);
matrix.set(center + size, center + size - 1); matrix.set(center + size, center + size - 1);
} }
static BitArray generateModeMessage(boolean compact, int layers, int messageSizeInWords) { static BitArray generateModeMessage(boolean compact, int layers, int messageSizeInWords) {
BitArray modeMessage = new BitArray(); BitArray modeMessage = new BitArray();
if (compact) { if (compact) {
@ -230,7 +230,7 @@ public final class Encoder {
} }
return modeMessage; return modeMessage;
} }
private static void drawModeMessage(BitMatrix matrix, boolean compact, int matrixSize, BitArray modeMessage) { private static void drawModeMessage(BitMatrix matrix, boolean compact, int matrixSize, BitArray modeMessage) {
int center = matrixSize / 2; int center = matrixSize / 2;
if (compact) { if (compact) {
@ -267,7 +267,7 @@ public final class Encoder {
} }
} }
} }
private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) { private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) {
// bitArray is guaranteed to be a multiple of the wordSize, so no padding needed // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed
int messageSizeInWords = bitArray.getSize() / wordSize; int messageSizeInWords = bitArray.getSize() / wordSize;
@ -283,7 +283,7 @@ public final class Encoder {
} }
return messageBits; return messageBits;
} }
private static int[] bitsToWords(BitArray stuffedBits, int wordSize, int totalWords) { private static int[] bitsToWords(BitArray stuffedBits, int wordSize, int totalWords) {
int[] message = new int[totalWords]; int[] message = new int[totalWords];
int i; int i;
@ -297,7 +297,7 @@ public final class Encoder {
} }
return message; return message;
} }
private static GenericGF getGF(int wordSize) { private static GenericGF getGF(int wordSize) {
switch (wordSize) { switch (wordSize) {
case 4: case 4:

View file

@ -163,19 +163,19 @@ public final class HighLevelEncoder {
int pairCode; int pairCode;
int nextChar = index + 1 < text.length ? text[index + 1] : 0; int nextChar = index + 1 < text.length ? text[index + 1] : 0;
switch (text[index]) { switch (text[index]) {
case '\r': case '\r':
pairCode = nextChar == '\n' ? 2 : 0; pairCode = nextChar == '\n' ? 2 : 0;
break; break;
case '.' : case '.' :
pairCode = nextChar == ' ' ? 3 : 0; pairCode = nextChar == ' ' ? 3 : 0;
break; break;
case ',' : case ',' :
pairCode = nextChar == ' ' ? 4 : 0; pairCode = nextChar == ' ' ? 4 : 0;
break; break;
case ':' : case ':' :
pairCode = nextChar == ' ' ? 5 : 0; pairCode = nextChar == ' ' ? 5 : 0;
break; break;
default: default:
pairCode = 0; pairCode = 0;
} }
if (pairCode > 0) { if (pairCode > 0) {

View file

@ -19,12 +19,12 @@ package com.google.zxing.aztec.encoder;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
final class SimpleToken extends Token { final class SimpleToken extends Token {
// For normal words, indicates value and bitCount // For normal words, indicates value and bitCount
private final short value; private final short value;
private final short bitCount; private final short bitCount;
SimpleToken(Token previous, int value, int bitCount) { SimpleToken(Token previous, int value, int bitCount) {
super(previous); super(previous);
this.value = (short) value; this.value = (short) value;
this.bitCount = (short) bitCount; this.bitCount = (short) bitCount;

View file

@ -26,7 +26,7 @@ import com.google.zxing.common.BitArray;
* Note that a state is immutable. * Note that a state is immutable.
*/ */
final class State { final class State {
static final State INITIAL_STATE = new State(Token.EMPTY, HighLevelEncoder.MODE_UPPER, 0, 0); static final State INITIAL_STATE = new State(Token.EMPTY, HighLevelEncoder.MODE_UPPER, 0, 0);
// The current mode of the encoding (or the mode to which we'll return if // The current mode of the encoding (or the mode to which we'll return if
@ -53,19 +53,19 @@ final class State {
// binaryShiftByteCount <= 62 ? 20 : 21); // binaryShiftByteCount <= 62 ? 20 : 21);
//assert this.bitCount == token.getTotalBitCount() + binaryShiftBitCount; //assert this.bitCount == token.getTotalBitCount() + binaryShiftBitCount;
} }
int getMode() { int getMode() {
return mode; return mode;
} }
Token getToken() { Token getToken() {
return token; return token;
} }
int getBinaryShiftByteCount() { int getBinaryShiftByteCount() {
return binaryShiftByteCount; return binaryShiftByteCount;
} }
int getBitCount() { int getBitCount() {
return bitCount; return bitCount;
} }
@ -104,7 +104,7 @@ final class State {
Token token = this.token; Token token = this.token;
int mode = this.mode; int mode = this.mode;
int bitCount = this.bitCount; int bitCount = this.bitCount;
if (this.mode == HighLevelEncoder.MODE_PUNCT || this.mode == HighLevelEncoder.MODE_DIGIT) { if (this.mode == HighLevelEncoder.MODE_PUNCT || this.mode == HighLevelEncoder.MODE_DIGIT) {
//assert binaryShiftByteCount == 0; //assert binaryShiftByteCount == 0;
int latch = HighLevelEncoder.LATCH_TABLE[mode][HighLevelEncoder.MODE_UPPER]; int latch = HighLevelEncoder.LATCH_TABLE[mode][HighLevelEncoder.MODE_UPPER];
token = token.add(latch & 0xFFFF, latch >> 16); token = token.add(latch & 0xFFFF, latch >> 16);

View file

@ -19,15 +19,15 @@ package com.google.zxing.aztec.encoder;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
abstract class Token { abstract class Token {
static final Token EMPTY = new SimpleToken(null, 0, 0); static final Token EMPTY = new SimpleToken(null, 0, 0);
private final Token previous; private final Token previous;
Token(Token previous) { Token(Token previous) {
this.previous = previous; this.previous = previous;
} }
final Token getPrevious() { final Token getPrevious() {
return previous; return previous;
} }

View file

@ -78,7 +78,7 @@ public enum CharacterSetECI {
CharacterSetECI(int value) { CharacterSetECI(int value) {
this(new int[] {value}); this(new int[] {value});
} }
CharacterSetECI(int value, String... otherEncodingNames) { CharacterSetECI(int value, String... otherEncodingNames) {
this.values = new int[] {value}; this.values = new int[] {value};
this.otherEncodingNames = otherEncodingNames; this.otherEncodingNames = otherEncodingNames;

View file

@ -136,17 +136,17 @@ public final class DecoderResult {
public void setOther(Object other) { public void setOther(Object other) {
this.other = other; this.other = other;
} }
public boolean hasStructuredAppend() { public boolean hasStructuredAppend() {
return structuredAppendParity >= 0 && structuredAppendSequenceNumber >= 0; return structuredAppendParity >= 0 && structuredAppendSequenceNumber >= 0;
} }
public int getStructuredAppendParity() { public int getStructuredAppendParity() {
return structuredAppendParity; return structuredAppendParity;
} }
public int getStructuredAppendSequenceNumber() { public int getStructuredAppendSequenceNumber() {
return structuredAppendSequenceNumber; return structuredAppendSequenceNumber;
} }
} }

View file

@ -49,7 +49,7 @@ public final class DefaultGridSampler extends GridSampler {
int dimensionY, int dimensionY,
PerspectiveTransform transform) throws NotFoundException { PerspectiveTransform transform) throws NotFoundException {
if (dimensionX <= 0 || dimensionY <= 0) { if (dimensionX <= 0 || dimensionY <= 0) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
BitMatrix bits = new BitMatrix(dimensionX, dimensionY); BitMatrix bits = new BitMatrix(dimensionX, dimensionY);
float[] points = new float[2 * dimensionX]; float[] points = new float[2 * dimensionX];

View file

@ -41,7 +41,7 @@ public abstract class GridSampler {
* ought to be appropriate for the entire platform, and all uses of this library * 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 * in the whole lifetime of the JVM. For instance, an Android activity can swap in
* an implementation that takes advantage of native platform libraries. * an implementation that takes advantage of native platform libraries.
* *
* @param newGridSampler The platform-specific object to install. * @param newGridSampler The platform-specific object to install.
*/ */
public static void setGridSampler(GridSampler newGridSampler) { public static void setGridSampler(GridSampler newGridSampler) {
@ -95,7 +95,7 @@ public abstract class GridSampler {
float p2FromX, float p2FromY, float p2FromX, float p2FromY,
float p3FromX, float p3FromY, float p3FromX, float p3FromY,
float p4FromX, float p4FromY) throws NotFoundException; float p4FromX, float p4FromY) throws NotFoundException;
public abstract BitMatrix sampleGrid(BitMatrix image, public abstract BitMatrix sampleGrid(BitMatrix image,
int dimensionX, int dimensionX,
int dimensionY, int dimensionY,

View file

@ -85,7 +85,7 @@ public final class PerspectiveTransform {
public void transformPoints(float[] xValues, float[] yValues) { public void transformPoints(float[] xValues, float[] yValues) {
int n = xValues.length; int n = xValues.length;
for (int i = 0; i < n; i ++) { for (int i = 0; i < n; i++) {
float x = xValues[i]; float x = xValues[i];
float y = yValues[i]; float y = yValues[i];
float denominator = a13 * x + a23 * y + a33; float denominator = a13 * x + a23 * y + a33;

View file

@ -39,7 +39,7 @@ public final class StringUtils {
SHIFT_JIS.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING) || SHIFT_JIS.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING) ||
EUC_JP.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING); EUC_JP.equalsIgnoreCase(PLATFORM_DEFAULT_ENCODING);
private StringUtils() {} private StringUtils() { }
/** /**
* @param bytes bytes encoding a string, whose encoding should be guessed * @param bytes bytes encoding a string, whose encoding should be guessed

View file

@ -91,7 +91,7 @@ public final class WhiteRectangleDetector {
boolean sizeExceeded = false; boolean sizeExceeded = false;
boolean aBlackPointFoundOnBorder = true; boolean aBlackPointFoundOnBorder = true;
boolean atLeastOneBlackPointFoundOnBorder = false; boolean atLeastOneBlackPointFoundOnBorder = false;
boolean atLeastOneBlackPointFoundOnRight = false; boolean atLeastOneBlackPointFoundOnRight = false;
boolean atLeastOneBlackPointFoundOnBottom = false; boolean atLeastOneBlackPointFoundOnBottom = false;
boolean atLeastOneBlackPointFoundOnLeft = false; boolean atLeastOneBlackPointFoundOnLeft = false;
@ -165,7 +165,7 @@ public final class WhiteRectangleDetector {
// . . // . .
// ..... // .....
boolean topBorderNotWhite = true; boolean topBorderNotWhite = true;
while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) { while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) {
topBorderNotWhite = containsBlackPoint(left, right, up, true); topBorderNotWhite = containsBlackPoint(left, right, up, true);
if (topBorderNotWhite) { if (topBorderNotWhite) {
up--; up--;

View file

@ -153,14 +153,14 @@ public final class GenericGF {
public int getSize() { public int getSize() {
return size; return size;
} }
public int getGeneratorBase() { public int getGeneratorBase() {
return generatorBase; return generatorBase;
} }
@Override @Override
public String toString() { public String toString() {
return "GF(0x" + Integer.toHexString(primitive) + ',' + size + ')'; return "GF(0x" + Integer.toHexString(primitive) + ',' + size + ')';
} }
} }

View file

@ -123,7 +123,7 @@ public final class ReedSolomonDecoder {
} }
t = q.multiply(tLast).addOrSubtract(tLastLast); t = q.multiply(tLast).addOrSubtract(tLastLast);
if (r.getDegree() >= rLast.getDegree()) { if (r.getDegree() >= rLast.getDegree()) {
throw new IllegalStateException("Division algorithm failed to reduce polynomial?"); throw new IllegalStateException("Division algorithm failed to reduce polynomial?");
} }

View file

@ -49,11 +49,11 @@ public final class DataMatrixWriter implements Writer {
if (contents.isEmpty()) { if (contents.isEmpty()) {
throw new IllegalArgumentException("Found empty contents"); throw new IllegalArgumentException("Found empty contents");
} }
if (format != BarcodeFormat.DATA_MATRIX) { if (format != BarcodeFormat.DATA_MATRIX) {
throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format); throw new IllegalArgumentException("Can only encode DATA_MATRIX, but got " + format);
} }
if (width < 0 || height < 0) { if (width < 0 || height < 0) {
throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height); throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' + height);
} }

View file

@ -37,7 +37,7 @@ final class BitMatrixParser {
if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) { if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }
version = readVersion(bitMatrix); version = readVersion(bitMatrix);
this.mappingBitMatrix = extractDataRegion(bitMatrix); this.mappingBitMatrix = extractDataRegion(bitMatrix);
this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight()); this.readMappingMatrix = new BitMatrix(this.mappingBitMatrix.getWidth(), this.mappingBitMatrix.getHeight());
@ -52,7 +52,7 @@ final class BitMatrixParser {
* the datamatrix code.</p> * the datamatrix code.</p>
* *
* <p>See ISO 16022:2006 Table 7 - ECC 200 symbol attributes</p> * <p>See ISO 16022:2006 Table 7 - ECC 200 symbol attributes</p>
* *
* @param bitMatrix Original {@link BitMatrix} including alignment patterns * @param bitMatrix Original {@link BitMatrix} including alignment patterns
* @return {@link Version} encapsulating the Data Matrix Code's "version" * @return {@link Version} encapsulating the Data Matrix Code's "version"
* @throws FormatException if the dimensions of the mapping matrix are not valid * @throws FormatException if the dimensions of the mapping matrix are not valid
@ -76,18 +76,18 @@ final class BitMatrixParser {
byte[] result = new byte[version.getTotalCodewords()]; byte[] result = new byte[version.getTotalCodewords()];
int resultOffset = 0; int resultOffset = 0;
int row = 4; int row = 4;
int column = 0; int column = 0;
int numRows = mappingBitMatrix.getHeight(); int numRows = mappingBitMatrix.getHeight();
int numColumns = mappingBitMatrix.getWidth(); int numColumns = mappingBitMatrix.getWidth();
boolean corner1Read = false; boolean corner1Read = false;
boolean corner2Read = false; boolean corner2Read = false;
boolean corner3Read = false; boolean corner3Read = false;
boolean corner4Read = false; boolean corner4Read = false;
// Read all of the codewords // Read all of the codewords
do { do {
// Check the four corner cases // Check the four corner cases
@ -122,7 +122,7 @@ final class BitMatrixParser {
} while ((row >= 0) && (column < numColumns)); } while ((row >= 0) && (column < numColumns));
row += 1; row += 1;
column += 3; column += 3;
// Sweep downward diagonally to the left // Sweep downward diagonally to the left
do { do {
if ((row >= 0) && (column < numColumns) && !readMappingMatrix.get(column, row)) { if ((row >= 0) && (column < numColumns) && !readMappingMatrix.get(column, row)) {
@ -141,10 +141,10 @@ final class BitMatrixParser {
} }
return result; return result;
} }
/** /**
* <p>Reads a bit of the mapping matrix accounting for boundary wrapping.</p> * <p>Reads a bit of the mapping matrix accounting for boundary wrapping.</p>
* *
* @param row Row to read in the mapping matrix * @param row Row to read in the mapping matrix
* @param column Column to read in the mapping matrix * @param column Column to read in the mapping matrix
* @param numRows Number of rows in the mapping matrix * @param numRows Number of rows in the mapping matrix
@ -164,12 +164,12 @@ final class BitMatrixParser {
readMappingMatrix.set(column, row); readMappingMatrix.set(column, row);
return mappingBitMatrix.get(column, row); return mappingBitMatrix.get(column, row);
} }
/** /**
* <p>Reads the 8 bits of the standard Utah-shaped pattern.</p> * <p>Reads the 8 bits of the standard Utah-shaped pattern.</p>
* *
* <p>See ISO 16022:2006, 5.8.1 Figure 6</p> * <p>See ISO 16022:2006, 5.8.1 Figure 6</p>
* *
* @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern * @param row Current row in the mapping matrix, anchored at the 8th bit (LSB) of the pattern
* @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern * @param column Current column in the mapping matrix, anchored at the 8th bit (LSB) of the pattern
* @param numRows Number of rows in the mapping matrix * @param numRows Number of rows in the mapping matrix
@ -211,12 +211,12 @@ final class BitMatrixParser {
} }
return currentByte; return currentByte;
} }
/** /**
* <p>Reads the 8 bits of the special corner condition 1.</p> * <p>Reads the 8 bits of the special corner condition 1.</p>
* *
* <p>See ISO 16022:2006, Figure F.3</p> * <p>See ISO 16022:2006, Figure F.3</p>
* *
* @param numRows Number of rows in the mapping matrix * @param numRows Number of rows in the mapping matrix
* @param numColumns Number of columns in the mapping matrix * @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 1 * @return byte from the Corner condition 1
@ -256,12 +256,12 @@ final class BitMatrixParser {
} }
return currentByte; return currentByte;
} }
/** /**
* <p>Reads the 8 bits of the special corner condition 2.</p> * <p>Reads the 8 bits of the special corner condition 2.</p>
* *
* <p>See ISO 16022:2006, Figure F.4</p> * <p>See ISO 16022:2006, Figure F.4</p>
* *
* @param numRows Number of rows in the mapping matrix * @param numRows Number of rows in the mapping matrix
* @param numColumns Number of columns in the mapping matrix * @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 2 * @return byte from the Corner condition 2
@ -301,12 +301,12 @@ final class BitMatrixParser {
} }
return currentByte; return currentByte;
} }
/** /**
* <p>Reads the 8 bits of the special corner condition 3.</p> * <p>Reads the 8 bits of the special corner condition 3.</p>
* *
* <p>See ISO 16022:2006, Figure F.5</p> * <p>See ISO 16022:2006, Figure F.5</p>
* *
* @param numRows Number of rows in the mapping matrix * @param numRows Number of rows in the mapping matrix
* @param numColumns Number of columns in the mapping matrix * @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 3 * @return byte from the Corner condition 3
@ -346,12 +346,12 @@ final class BitMatrixParser {
} }
return currentByte; return currentByte;
} }
/** /**
* <p>Reads the 8 bits of the special corner condition 4.</p> * <p>Reads the 8 bits of the special corner condition 4.</p>
* *
* <p>See ISO 16022:2006, Figure F.6</p> * <p>See ISO 16022:2006, Figure F.6</p>
* *
* @param numRows Number of rows in the mapping matrix * @param numRows Number of rows in the mapping matrix
* @param numColumns Number of columns in the mapping matrix * @param numColumns Number of columns in the mapping matrix
* @return byte from the Corner condition 4 * @return byte from the Corner condition 4
@ -391,31 +391,31 @@ final class BitMatrixParser {
} }
return currentByte; return currentByte;
} }
/** /**
* <p>Extracts the data region from a {@link BitMatrix} that contains * <p>Extracts the data region from a {@link BitMatrix} that contains
* alignment patterns.</p> * alignment patterns.</p>
* *
* @param bitMatrix Original {@link BitMatrix} with alignment patterns * @param bitMatrix Original {@link BitMatrix} with alignment patterns
* @return BitMatrix that has the alignment patterns removed * @return BitMatrix that has the alignment patterns removed
*/ */
private BitMatrix extractDataRegion(BitMatrix bitMatrix) { private BitMatrix extractDataRegion(BitMatrix bitMatrix) {
int symbolSizeRows = version.getSymbolSizeRows(); int symbolSizeRows = version.getSymbolSizeRows();
int symbolSizeColumns = version.getSymbolSizeColumns(); int symbolSizeColumns = version.getSymbolSizeColumns();
if (bitMatrix.getHeight() != symbolSizeRows) { if (bitMatrix.getHeight() != symbolSizeRows) {
throw new IllegalArgumentException("Dimension of bitMatrix must match the version size"); throw new IllegalArgumentException("Dimension of bitMatrix must match the version size");
} }
int dataRegionSizeRows = version.getDataRegionSizeRows(); int dataRegionSizeRows = version.getDataRegionSizeRows();
int dataRegionSizeColumns = version.getDataRegionSizeColumns(); int dataRegionSizeColumns = version.getDataRegionSizeColumns();
int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows; int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns; int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;
int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows; int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns; int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
BitMatrix bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow); BitMatrix bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow);
for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) { for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) {
int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows; int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
@ -437,4 +437,4 @@ final class BitMatrixParser {
return bitMatrixWithoutAlignment; return bitMatrixWithoutAlignment;
} }
} }

View file

@ -82,14 +82,14 @@ final class DataBlock {
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
} }
} }
// Fill out the last data block in the longer ones // Fill out the last data block in the longer ones
boolean specialVersion = version.getVersionNumber() == 24; boolean specialVersion = version.getVersionNumber() == 24;
int numLongerBlocks = specialVersion ? 8 : numResultBlocks; int numLongerBlocks = specialVersion ? 8 : numResultBlocks;
for (int j = 0; j < numLongerBlocks; j++) { for (int j = 0; j < numLongerBlocks; j++) {
result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++]; result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++];
} }
// Now add in error correction blocks // Now add in error correction blocks
int max = result[0].codewords.length; int max = result[0].codewords.length;
for (int i = longerBlocksNumDataCodewords; i < max; i++) { for (int i = longerBlocksNumDataCodewords; i < max; i++) {

View file

@ -48,7 +48,7 @@ public final class Version {
this.dataRegionSizeRows = dataRegionSizeRows; this.dataRegionSizeRows = dataRegionSizeRows;
this.dataRegionSizeColumns = dataRegionSizeColumns; this.dataRegionSizeColumns = dataRegionSizeColumns;
this.ecBlocks = ecBlocks; this.ecBlocks = ecBlocks;
// Calculate the total number of codewords // Calculate the total number of codewords
int total = 0; int total = 0;
int ecCodewords = ecBlocks.getECCodewords(); int ecCodewords = ecBlocks.getECCodewords();
@ -66,23 +66,23 @@ public final class Version {
public int getSymbolSizeRows() { public int getSymbolSizeRows() {
return symbolSizeRows; return symbolSizeRows;
} }
public int getSymbolSizeColumns() { public int getSymbolSizeColumns() {
return symbolSizeColumns; return symbolSizeColumns;
} }
public int getDataRegionSizeRows() { public int getDataRegionSizeRows() {
return dataRegionSizeRows; return dataRegionSizeRows;
} }
public int getDataRegionSizeColumns() { public int getDataRegionSizeColumns() {
return dataRegionSizeColumns; return dataRegionSizeColumns;
} }
public int getTotalCodewords() { public int getTotalCodewords() {
return totalCodewords; return totalCodewords;
} }
ECBlocks getECBlocks() { ECBlocks getECBlocks() {
return ecBlocks; return ecBlocks;
} }
@ -105,7 +105,7 @@ public final class Version {
return version; return version;
} }
} }
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }

View file

@ -137,16 +137,16 @@ public final class Detector {
// The top right point is actually the corner of a module, which is one of the two black modules // The top right point is actually the corner of a module, which is one of the two black modules
// adjacent to the white module at the top right. Tracing to that corner from either the top left // adjacent to the white module at the top right. Tracing to that corner from either the top left
// or bottom right should work here. // or bottom right should work here.
int dimensionTop = transitionsBetween(topLeft, topRight).getTransitions(); int dimensionTop = transitionsBetween(topLeft, topRight).getTransitions();
int dimensionRight = transitionsBetween(bottomRight, topRight).getTransitions(); int dimensionRight = transitionsBetween(bottomRight, topRight).getTransitions();
if ((dimensionTop & 0x01) == 1) { if ((dimensionTop & 0x01) == 1) {
// it can't be odd, so, round... up? // it can't be odd, so, round... up?
dimensionTop++; dimensionTop++;
} }
dimensionTop += 2; dimensionTop += 2;
if ((dimensionRight & 0x01) == 1) { if ((dimensionRight & 0x01) == 1) {
// it can't be odd, so, round... up? // it can't be odd, so, round... up?
dimensionRight++; dimensionRight++;
@ -182,10 +182,10 @@ public final class Detector {
} }
bits = sampleGrid(image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionTop, dimensionRight); bits = sampleGrid(image, topLeft, bottomLeft, bottomRight, correctedTopRight, dimensionTop, dimensionRight);
} else { } else {
// The matrix is square // The matrix is square
int dimension = Math.min(dimensionRight, dimensionTop); int dimension = Math.min(dimensionRight, dimensionTop);
// correct top right point to match the white module // correct top right point to match the white module
correctedTopRight = correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension); correctedTopRight = correctTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension);
@ -419,7 +419,7 @@ public final class Detector {
int getTransitions() { int getTransitions() {
return transitions; return transitions;
} }
@Override @Override
public String toString() { public String toString() {
return from + "/" + to + '/' + transitions; return from + "/" + to + '/' + transitions;

View file

@ -78,5 +78,5 @@ final class ASCIIEncoder implements Encoder {
} }
throw new IllegalArgumentException("not digits: " + digit1 + digit2); throw new IllegalArgumentException("not digits: " + digit1 + digit2);
} }
} }

View file

@ -60,7 +60,7 @@ final class Base256Encoder implements Encoder {
buffer.charAt(i), context.getCodewordCount() + 1)); buffer.charAt(i), context.getCodewordCount() + 1));
} }
} }
private static char randomize255State(char ch, int codewordPosition) { private static char randomize255State(char ch, int codewordPosition) {
int pseudoRandom = ((149 * codewordPosition) % 255) + 1; int pseudoRandom = ((149 * codewordPosition) % 255) + 1;
int tempVariable = ch + pseudoRandom; int tempVariable = ch + pseudoRandom;

View file

@ -42,7 +42,7 @@ public class DefaultPlacement {
this.bits = new byte[numcols * numrows]; this.bits = new byte[numcols * numrows];
Arrays.fill(this.bits, (byte) -1); //Initialize with "not set" value Arrays.fill(this.bits, (byte) -1); //Initialize with "not set" value
} }
final int getNumrows() { final int getNumrows() {
return numrows; return numrows;
} }
@ -96,7 +96,7 @@ public class DefaultPlacement {
} while (row >= 0 && (col < numcols)); } while (row >= 0 && (col < numcols));
row++; row++;
col += 3; col += 3;
/* and then sweep downward diagonally, inserting successive characters, ... */ /* and then sweep downward diagonally, inserting successive characters, ... */
do { do {
if ((row >= 0) && (col < numcols) && !hasBit(col, row)) { if ((row >= 0) && (col < numcols) && !hasBit(col, row)) {
@ -107,10 +107,10 @@ public class DefaultPlacement {
} while ((row < numrows) && (col >= 0)); } while ((row < numrows) && (col >= 0));
row += 3; row += 3;
col++; col++;
/* ...until the entire array is scanned */ /* ...until the entire array is scanned */
} while ((row < numrows) || (col < numcols)); } while ((row < numrows) || (col < numcols));
/* Lastly, if the lower righthand corner is untouched, fill in fixed pattern */ /* Lastly, if the lower righthand corner is untouched, fill in fixed pattern */
if (!hasBit(numcols - 1, numrows - 1)) { if (!hasBit(numcols - 1, numrows - 1)) {
setBit(numcols - 1, numrows - 1, true); setBit(numcols - 1, numrows - 1, true);

View file

@ -73,7 +73,7 @@ final class EncoderContext {
public char getCurrent() { public char getCurrent() {
return msg.charAt(pos); return msg.charAt(pos);
} }
public StringBuilder getCodewords() { public StringBuilder getCodewords() {
return codewords; return codewords;
} }
@ -89,7 +89,7 @@ final class EncoderContext {
public int getCodewordCount() { public int getCodewordCount() {
return this.codewords.length(); return this.codewords.length();
} }
public int getNewEncoding() { public int getNewEncoding() {
return newEncoding; return newEncoding;
} }
@ -113,7 +113,7 @@ final class EncoderContext {
public int getRemainingCharacters() { public int getRemainingCharacters() {
return getTotalMessageCharCount() - pos; return getTotalMessageCharCount() - pos;
} }
public SymbolInfo getSymbolInfo() { public SymbolInfo getSymbolInfo() {
return symbolInfo; return symbolInfo;
} }

View file

@ -25,7 +25,7 @@ import java.util.Arrays;
* annex S. * annex S.
*/ */
public final class HighLevelEncoder { public final class HighLevelEncoder {
/** /**
* Padding character * Padding character
*/ */
@ -154,12 +154,12 @@ public final class HighLevelEncoder {
* @return the encoded message (the char values range from 0 to 255) * @return the encoded message (the char values range from 0 to 255)
*/ */
public static String encodeHighLevel(String msg, public static String encodeHighLevel(String msg,
SymbolShapeHint shape, SymbolShapeHint shape,
Dimension minSize, Dimension minSize,
Dimension maxSize) { Dimension maxSize) {
//the codewords 0..255 are encoded as Unicode characters //the codewords 0..255 are encoded as Unicode characters
Encoder[] encoders = { Encoder[] encoders = {
new ASCIIEncoder(), new C40Encoder(), new TextEncoder(), new ASCIIEncoder(), new C40Encoder(), new TextEncoder(),
new X12Encoder(), new EdifactEncoder(), new Base256Encoder() new X12Encoder(), new EdifactEncoder(), new Base256Encoder()
}; };

View file

@ -119,9 +119,9 @@ public class SymbolInfo {
} }
public static SymbolInfo lookup(int dataCodewords, public static SymbolInfo lookup(int dataCodewords,
SymbolShapeHint shape, SymbolShapeHint shape,
Dimension minSize, Dimension minSize,
Dimension maxSize, Dimension maxSize,
boolean fail) { boolean fail) {
for (SymbolInfo symbol : symbols) { for (SymbolInfo symbol : symbols) {
if (shape == SymbolShapeHint.FORCE_SQUARE && symbol.rectangular) { if (shape == SymbolShapeHint.FORCE_SQUARE && symbol.rectangular) {
@ -207,11 +207,11 @@ public class SymbolInfo {
public int getInterleavedBlockCount() { public int getInterleavedBlockCount() {
return dataCapacity / rsBlockData; return dataCapacity / rsBlockData;
} }
public final int getDataCapacity() { public final int getDataCapacity() {
return dataCapacity; return dataCapacity;
} }
public final int getErrorCodewords() { public final int getErrorCodewords() {
return errorCodewords; return errorCodewords;
} }

View file

@ -1,12 +1,12 @@
/* /*
* Copyright 2007 Jeremias Maerki. * Copyright 2007 Jeremias Maerki.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View file

@ -97,12 +97,12 @@ public final class MaxiCodeReader implements Reader {
* @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix) * @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix)
*/ */
private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException { private static BitMatrix extractPureBits(BitMatrix image) throws NotFoundException {
int[] enclosingRectangle = image.getEnclosingRectangle(); int[] enclosingRectangle = image.getEnclosingRectangle();
if (enclosingRectangle == null) { if (enclosingRectangle == null) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
int left = enclosingRectangle[0]; int left = enclosingRectangle[0];
int top = enclosingRectangle[1]; int top = enclosingRectangle[1];
int width = enclosingRectangle[2]; int width = enclosingRectangle[2];

View file

@ -78,7 +78,7 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
if (currentDepth > MAX_DEPTH) { if (currentDepth > MAX_DEPTH) {
return; return;
} }
Result result; Result result;
try { try {
result = delegate.decode(image, hints); result = delegate.decode(image, hints);
@ -128,29 +128,29 @@ public final class GenericMultipleBarcodeReader implements MultipleBarcodeReader
// Decode left of barcode // Decode left of barcode
if (minX > MIN_DIMENSION_TO_RECUR) { if (minX > MIN_DIMENSION_TO_RECUR) {
doDecodeMultiple(image.crop(0, 0, (int) minX, height), doDecodeMultiple(image.crop(0, 0, (int) minX, height),
hints, results, hints, results,
xOffset, yOffset, xOffset, yOffset,
currentDepth + 1); currentDepth + 1);
} }
// Decode above barcode // Decode above barcode
if (minY > MIN_DIMENSION_TO_RECUR) { if (minY > MIN_DIMENSION_TO_RECUR) {
doDecodeMultiple(image.crop(0, 0, width, (int) minY), doDecodeMultiple(image.crop(0, 0, width, (int) minY),
hints, results, hints, results,
xOffset, yOffset, xOffset, yOffset,
currentDepth + 1); currentDepth + 1);
} }
// Decode right of barcode // Decode right of barcode
if (maxX < width - MIN_DIMENSION_TO_RECUR) { if (maxX < width - MIN_DIMENSION_TO_RECUR) {
doDecodeMultiple(image.crop((int) maxX, 0, width - (int) maxX, height), doDecodeMultiple(image.crop((int) maxX, 0, width - (int) maxX, height),
hints, results, hints, results,
xOffset + (int) maxX, yOffset, xOffset + (int) maxX, yOffset,
currentDepth + 1); currentDepth + 1);
} }
// Decode below barcode // Decode below barcode
if (maxY < height - MIN_DIMENSION_TO_RECUR) { if (maxY < height - MIN_DIMENSION_TO_RECUR) {
doDecodeMultiple(image.crop(0, (int) maxY, width, height - (int) maxY), doDecodeMultiple(image.crop(0, (int) maxY, width, height - (int) maxY),
hints, results, hints, results,
xOffset, yOffset + (int) maxY, xOffset, yOffset + (int) maxY,
currentDepth + 1); currentDepth + 1);
} }
} }

View file

@ -27,7 +27,7 @@ import java.util.Map;
/** /**
* This object renders a CODE128 code as a {@link BitMatrix}. * This object renders a CODE128 code as a {@link BitMatrix}.
* *
* @author erik.barbara@gmail.com (Erik Barbara) * @author erik.barbara@gmail.com (Erik Barbara)
*/ */
public final class Code128Writer extends OneDimensionalCodeWriter { public final class Code128Writer extends OneDimensionalCodeWriter {
@ -92,17 +92,17 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
} }
} }
} }
Collection<int[]> patterns = new ArrayList<>(); // temporary storage for patterns Collection<int[]> patterns = new ArrayList<>(); // temporary storage for patterns
int checkSum = 0; int checkSum = 0;
int checkWeight = 1; int checkWeight = 1;
int codeSet = 0; // selected code (CODE_CODE_B or CODE_CODE_C) int codeSet = 0; // selected code (CODE_CODE_B or CODE_CODE_C)
int position = 0; // position in contents int position = 0; // position in contents
while (position < length) { while (position < length) {
//Select code to use //Select code to use
int newCodeSet = chooseCode(contents, position, codeSet); int newCodeSet = chooseCode(contents, position, codeSet);
//Get the pattern index //Get the pattern index
int patternIndex; int patternIndex;
if (newCodeSet == codeSet) { if (newCodeSet == codeSet) {
@ -148,24 +148,24 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
} }
codeSet = newCodeSet; codeSet = newCodeSet;
} }
// Get the pattern // Get the pattern
patterns.add(Code128Reader.CODE_PATTERNS[patternIndex]); patterns.add(Code128Reader.CODE_PATTERNS[patternIndex]);
// Compute checksum // Compute checksum
checkSum += patternIndex * checkWeight; checkSum += patternIndex * checkWeight;
if (position != 0) { if (position != 0) {
checkWeight++; checkWeight++;
} }
} }
// Compute and append checksum // Compute and append checksum
checkSum %= 103; checkSum %= 103;
patterns.add(Code128Reader.CODE_PATTERNS[checkSum]); patterns.add(Code128Reader.CODE_PATTERNS[checkSum]);
// Append stop code // Append stop code
patterns.add(Code128Reader.CODE_PATTERNS[CODE_STOP]); patterns.add(Code128Reader.CODE_PATTERNS[CODE_STOP]);
// Compute code width // Compute code width
int codeWidth = 0; int codeWidth = 0;
for (int[] pattern : patterns) { for (int[] pattern : patterns) {
@ -173,14 +173,14 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
codeWidth += width; codeWidth += width;
} }
} }
// Compute result // Compute result
boolean[] result = new boolean[codeWidth]; boolean[] result = new boolean[codeWidth];
int pos = 0; int pos = 0;
for (int[] pattern : patterns) { for (int[] pattern : patterns) {
pos += appendPattern(result, pos, pattern, true); pos += appendPattern(result, pos, pattern, true);
} }
return result; return result;
} }

View file

@ -106,7 +106,7 @@ public final class Code39Reader extends OneDReader {
result.setLength(0); result.setLength(0);
int[] start = findAsteriskPattern(row, theCounters); int[] start = findAsteriskPattern(row, theCounters);
// Read off white space // Read off white space
int nextStart = row.getNextSet(start[1]); int nextStart = row.getNextSet(start[1]);
int end = row.getSize(); int end = row.getSize();

View file

@ -25,7 +25,7 @@ import java.util.Map;
/** /**
* This object renders a CODE39 code as a {@link BitMatrix}. * This object renders a CODE39 code as a {@link BitMatrix}.
* *
* @author erik.barbara@gmail.com (Erik Barbara) * @author erik.barbara@gmail.com (Erik Barbara)
*/ */
public final class Code39Writer extends OneDimensionalCodeWriter { public final class Code39Writer extends OneDimensionalCodeWriter {
@ -86,4 +86,4 @@ public final class Code39Writer extends OneDimensionalCodeWriter {
} }
} }
} }

View file

@ -67,7 +67,7 @@ public final class Code93Reader extends OneDReader {
throws NotFoundException, ChecksumException, FormatException { throws NotFoundException, ChecksumException, FormatException {
int[] start = findAsteriskPattern(row); int[] start = findAsteriskPattern(row);
// Read off white space // Read off white space
int nextStart = row.getNextSet(start[1]); int nextStart = row.getNextSet(start[1]);
int end = row.getSize(); int end = row.getSize();

View file

@ -50,12 +50,12 @@ final class EANManufacturerOrgSupport {
} }
return null; return null;
} }
private void add(int[] range, String id) { private void add(int[] range, String id) {
ranges.add(range); ranges.add(range);
countryIdentifiers.add(id); countryIdentifiers.add(id);
} }
private synchronized void initIfNeeded() { private synchronized void initIfNeeded() {
if (!ranges.isEmpty()) { if (!ranges.isEmpty()) {
return; return;
@ -86,15 +86,15 @@ final class EANManufacturerOrgSupport {
add(new int[] {486}, "GE"); add(new int[] {486}, "GE");
add(new int[] {487}, "KZ"); add(new int[] {487}, "KZ");
add(new int[] {489}, "HK"); add(new int[] {489}, "HK");
add(new int[] {490,499}, "JP"); add(new int[] {490,499}, "JP");
add(new int[] {500,509}, "GB"); add(new int[] {500,509}, "GB");
add(new int[] {520}, "GR"); add(new int[] {520}, "GR");
add(new int[] {528}, "LB"); add(new int[] {528}, "LB");
add(new int[] {529}, "CY"); add(new int[] {529}, "CY");
add(new int[] {531}, "MK"); add(new int[] {531}, "MK");
add(new int[] {535}, "MT"); add(new int[] {535}, "MT");
add(new int[] {539}, "IE"); add(new int[] {539}, "IE");
add(new int[] {540,549}, "BE/LU"); add(new int[] {540,549}, "BE/LU");
add(new int[] {560}, "PT"); add(new int[] {560}, "PT");
add(new int[] {569}, "IS"); add(new int[] {569}, "IS");
add(new int[] {570,579}, "DK"); add(new int[] {570,579}, "DK");
@ -102,13 +102,13 @@ final class EANManufacturerOrgSupport {
add(new int[] {594}, "RO"); add(new int[] {594}, "RO");
add(new int[] {599}, "HU"); add(new int[] {599}, "HU");
add(new int[] {600,601}, "ZA"); add(new int[] {600,601}, "ZA");
add(new int[] {603}, "GH"); add(new int[] {603}, "GH");
add(new int[] {608}, "BH"); add(new int[] {608}, "BH");
add(new int[] {609}, "MU"); add(new int[] {609}, "MU");
add(new int[] {611}, "MA"); add(new int[] {611}, "MA");
add(new int[] {613}, "DZ"); add(new int[] {613}, "DZ");
add(new int[] {616}, "KE"); add(new int[] {616}, "KE");
add(new int[] {618}, "CI"); add(new int[] {618}, "CI");
add(new int[] {619}, "TN"); add(new int[] {619}, "TN");
add(new int[] {621}, "SY"); add(new int[] {621}, "SY");
add(new int[] {622}, "EG"); add(new int[] {622}, "EG");
@ -141,7 +141,7 @@ final class EANManufacturerOrgSupport {
add(new int[] {779}, "AR"); add(new int[] {779}, "AR");
add(new int[] {780}, "CL"); add(new int[] {780}, "CL");
add(new int[] {784}, "PY"); add(new int[] {784}, "PY");
add(new int[] {785}, "PE"); add(new int[] {785}, "PE");
add(new int[] {786}, "EC"); add(new int[] {786}, "EC");
add(new int[] {789,790}, "BR"); add(new int[] {789,790}, "BR");
add(new int[] {800,839}, "IT"); add(new int[] {800,839}, "IT");
@ -150,7 +150,7 @@ final class EANManufacturerOrgSupport {
add(new int[] {858}, "SK"); add(new int[] {858}, "SK");
add(new int[] {859}, "CZ"); add(new int[] {859}, "CZ");
add(new int[] {860}, "YU"); add(new int[] {860}, "YU");
add(new int[] {865}, "MN"); add(new int[] {865}, "MN");
add(new int[] {867}, "KP"); add(new int[] {867}, "KP");
add(new int[] {868,869}, "TR"); add(new int[] {868,869}, "TR");
add(new int[] {870,879}, "NL"); add(new int[] {870,879}, "NL");
@ -159,7 +159,7 @@ final class EANManufacturerOrgSupport {
add(new int[] {888}, "SG"); add(new int[] {888}, "SG");
add(new int[] {890}, "IN"); add(new int[] {890}, "IN");
add(new int[] {893}, "VN"); add(new int[] {893}, "VN");
add(new int[] {896}, "PK"); add(new int[] {896}, "PK");
add(new int[] {899}, "ID"); add(new int[] {899}, "ID");
add(new int[] {900,919}, "AT"); add(new int[] {900,919}, "AT");
add(new int[] {930,939}, "AU"); add(new int[] {930,939}, "AU");

View file

@ -51,7 +51,7 @@ public final class ITFReader extends OneDReader {
private static final int N = 1; // Pixed width of a narrow line private static final int N = 1; // Pixed width of a narrow line
/** Valid ITF lengths. Anything longer than the largest value is also allowed. */ /** Valid ITF lengths. Anything longer than the largest value is also allowed. */
private static final int[] DEFAULT_ALLOWED_LENGTHS = { 6, 8, 10, 12, 14 }; private static final int[] DEFAULT_ALLOWED_LENGTHS = {6, 8, 10, 12, 14};
// Stores the actual narrow line width of the image being decoded. // Stores the actual narrow line width of the image being decoded.
private int narrowLineWidth = -1; private int narrowLineWidth = -1;
@ -126,8 +126,8 @@ public final class ITFReader extends OneDReader {
return new Result( return new Result(
resultString, resultString,
null, // no natural byte representation for these barcodes null, // no natural byte representation for these barcodes
new ResultPoint[] { new ResultPoint(startRange[1], rowNumber), new ResultPoint[] {new ResultPoint(startRange[1], rowNumber),
new ResultPoint(endRange[0], rowNumber)}, new ResultPoint(endRange[0], rowNumber)},
BarcodeFormat.ITF); BarcodeFormat.ITF);
} }

View file

@ -25,7 +25,7 @@ import java.util.Map;
/** /**
* This object renders a ITF code as a {@link BitMatrix}. * This object renders a ITF code as a {@link BitMatrix}.
* *
* @author erik.barbara@gmail.com (Erik Barbara) * @author erik.barbara@gmail.com (Erik Barbara)
*/ */
public final class ITFWriter extends OneDimensionalCodeWriter { public final class ITFWriter extends OneDimensionalCodeWriter {

View file

@ -39,7 +39,7 @@ public final class MultiFormatOneDReader extends OneDReader {
private final OneDReader[] readers; private final OneDReader[] readers;
public MultiFormatOneDReader(Map<DecodeHintType,?> hints) { public MultiFormatOneDReader(Map<DecodeHintType,?> hints) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats = hints == null ? null : Collection<BarcodeFormat> possibleFormats = hints == null ? null :
(Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS); (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
boolean useCode39CheckDigit = hints != null && boolean useCode39CheckDigit = hints != null &&

View file

@ -94,7 +94,7 @@ public final class MultiFormatUPCEANReader extends OneDReader {
boolean ean13MayBeUPCA = boolean ean13MayBeUPCA =
result.getBarcodeFormat() == BarcodeFormat.EAN_13 && result.getBarcodeFormat() == BarcodeFormat.EAN_13 &&
result.getText().charAt(0) == '0'; result.getText().charAt(0) == '0';
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats = Collection<BarcodeFormat> possibleFormats =
hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS); hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A); boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);

View file

@ -91,7 +91,7 @@ final class UPCEANExtension2Support {
if (Integer.parseInt(resultString.toString()) % 4 != checkParity) { if (Integer.parseInt(resultString.toString()) % 4 != checkParity) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
return rowOffset; return rowOffset;
} }

View file

@ -96,7 +96,7 @@ final class UPCEANExtension5Support {
if (extensionChecksum(resultString.toString()) != checkDigit) { if (extensionChecksum(resultString.toString()) != checkDigit) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
return rowOffset; return rowOffset;
} }

View file

@ -80,7 +80,7 @@ public final class UPCEWriter extends UPCEANWriter {
if (firstDigit != 0 && firstDigit != 1) { if (firstDigit != 0 && firstDigit != 1) {
throw new IllegalArgumentException("Number system must be 0 or 1"); throw new IllegalArgumentException("Number system must be 0 or 1");
} }
int checkDigit = Character.digit(contents.charAt(7), 10); int checkDigit = Character.digit(contents.charAt(7), 10);
int parities = UPCEReader.NUMSYS_AND_CHECK_DIGIT_PATTERNS[firstDigit][checkDigit]; int parities = UPCEReader.NUMSYS_AND_CHECK_DIGIT_PATTERNS[firstDigit][checkDigit];
boolean[] result = new boolean[CODE_WIDTH]; boolean[] result = new boolean[CODE_WIDTH];
@ -100,5 +100,5 @@ public final class UPCEWriter extends UPCEANWriter {
return result; return result;
} }
} }

View file

@ -41,7 +41,7 @@ public class DataCharacter {
public final String toString() { public final String toString() {
return value + "(" + checksumPortion + ')'; return value + "(" + checksumPortion + ')';
} }
@Override @Override
public final boolean equals(Object o) { public final boolean equals(Object o) {
if (!(o instanceof DataCharacter)) { if (!(o instanceof DataCharacter)) {

View file

@ -68,14 +68,14 @@ final class ExpandedPair {
public boolean mustBeLast() { public boolean mustBeLast() {
return this.rightChar == null; return this.rightChar == null;
} }
@Override @Override
public String toString() { public String toString() {
return return
"[ " + leftChar + " , " + rightChar + " : " + "[ " + leftChar + " , " + rightChar + " : " +
(finderPattern == null ? "null" : finderPattern.getValue()) + " ]"; (finderPattern == null ? "null" : finderPattern.getValue()) + " ]";
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (!(o instanceof ExpandedPair)) { if (!(o instanceof ExpandedPair)) {

View file

@ -34,30 +34,30 @@ final class ExpandedRow {
this.rowNumber = rowNumber; this.rowNumber = rowNumber;
this.wasReversed = wasReversed; this.wasReversed = wasReversed;
} }
List<ExpandedPair> getPairs() { List<ExpandedPair> getPairs() {
return this.pairs; return this.pairs;
} }
int getRowNumber() { int getRowNumber() {
return this.rowNumber; return this.rowNumber;
} }
boolean isReversed() { boolean isReversed() {
return this.wasReversed; return this.wasReversed;
} }
boolean isEquivalent(List<ExpandedPair> otherPairs) { boolean isEquivalent(List<ExpandedPair> otherPairs) {
return this.pairs.equals(otherPairs); return this.pairs.equals(otherPairs);
} }
@Override @Override
public String toString() { public String toString() {
return "{ " + pairs + " }"; return "{ " + pairs + " }";
} }
/** /**
* Two rows are equal if they contain the same pairs in the same order. * Two rows are equal if they contain the same pairs in the same order.
*/ */
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {

View file

@ -161,7 +161,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
if (checkChecksum()) { if (checkChecksum()) {
return this.pairs; return this.pairs;
} }
boolean tryStackedDecode = !this.rows.isEmpty(); boolean tryStackedDecode = !this.rows.isEmpty();
storeRow(rowNumber, false); // TODO: deal with reversed rows storeRow(rowNumber, false); // TODO: deal with reversed rows
if (tryStackedDecode) { if (tryStackedDecode) {
@ -176,7 +176,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
return ps; return ps;
} }
} }
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
@ -297,7 +297,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
removePartialRows(this.pairs, this.rows); removePartialRows(this.pairs, this.rows);
} }
// Remove all the rows that contains only specified pairs // Remove all the rows that contains only specified pairs
private static void removePartialRows(List<ExpandedPair> pairs, List<ExpandedRow> rows) { private static void removePartialRows(List<ExpandedPair> pairs, List<ExpandedRow> rows) {
for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) { for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) {
ExpandedRow r = iterator.next(); ExpandedRow r = iterator.next();
@ -441,11 +441,11 @@ public final class RSSExpandedReader extends AbstractRSSReader {
// boolean mayBeLast = checkPairSequence(previousPairs, pattern); // boolean mayBeLast = checkPairSequence(previousPairs, pattern);
DataCharacter leftChar = this.decodeDataCharacter(row, pattern, isOddPattern, true); 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(); throw NotFoundException.getNotFoundInstance();
} }
DataCharacter rightChar; DataCharacter rightChar;
try { try {
rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false); rightChar = this.decodeDataCharacter(row, pattern, isOddPattern, false);

View file

@ -160,7 +160,7 @@ final class FieldParser {
{ "391", VARIABLE_LENGTH, 18}, { "391", VARIABLE_LENGTH, 18},
{ "392", VARIABLE_LENGTH, 15}, { "392", VARIABLE_LENGTH, 15},
{ "393", VARIABLE_LENGTH, 18}, { "393", VARIABLE_LENGTH, 18},
{ "703", VARIABLE_LENGTH, 30} { "703", VARIABLE_LENGTH, 30},
}; };
private static final Object [][] FOUR_DIGIT_DATA_LENGTH = { private static final Object [][] FOUR_DIGIT_DATA_LENGTH = {

View file

@ -43,7 +43,7 @@ final class BarcodeValue {
} }
/** /**
* Determines the maximum occurrence of a set value and returns all values which were set with this occurrence. * Determines the maximum occurrence of a set value and returns all values which were set with this occurrence.
* @return an array of int, containing the values with the highest occurrence, or null, if no value was set * @return an array of int, containing the values with the highest occurrence, or null, if no value was set
*/ */
int[] getValue() { int[] getValue() {

View file

@ -62,8 +62,8 @@ final class DetectionResult {
// we should be able to estimate the row height and use it as a hint for the row number // we should be able to estimate the row height and use it as a hint for the row number
// we should also fill the rows top to bottom and bottom to top // we should also fill the rows top to bottom and bottom to top
/** /**
* @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords * @return number of codewords which don't have a valid row number. Note that the count is not accurate as codewords
* will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers * will be counted several times. It just serves as an indicator to see when we can stop adjusting row numbers
*/ */
private int adjustRowNumbers() { private int adjustRowNumbers() {
int unadjustedCount = adjustRowNumbersByRow(); int unadjustedCount = adjustRowNumbersByRow();

View file

@ -22,9 +22,9 @@ import java.util.Formatter;
* @author Guenther Grau * @author Guenther Grau
*/ */
class DetectionResultColumn { class DetectionResultColumn {
private static final int MAX_NEARBY_DISTANCE = 5; private static final int MAX_NEARBY_DISTANCE = 5;
private final BoundingBox boundingBox; private final BoundingBox boundingBox;
private final Codeword[] codewords; private final Codeword[] codewords;

View file

@ -52,7 +52,7 @@ final class DetectionResultRowIndicatorColumn extends DetectionResultColumn {
ResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight(); ResultPoint bottom = isLeft ? boundingBox.getBottomLeft() : boundingBox.getBottomRight();
int firstRow = imageRowToCodewordIndex((int) top.getY()); int firstRow = imageRowToCodewordIndex((int) top.getY());
int lastRow = imageRowToCodewordIndex((int) bottom.getY()); int lastRow = imageRowToCodewordIndex((int) bottom.getY());
// We need to be careful using the average row height. Barcode could be skewed so that we have smaller and // We need to be careful using the average row height. Barcode could be skewed so that we have smaller and
// taller rows // taller rows
//float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount(); //float averageRowHeight = (lastRow - firstRow) / (float) barcodeMetadata.getRowCount();
int barcodeRow = -1; int barcodeRow = -1;

View file

@ -25,7 +25,7 @@ import com.google.zxing.pdf417.PDF417Common;
*/ */
final class PDF417CodewordDecoder { final class PDF417CodewordDecoder {
private static final float[][] RATIOS_TABLE = private static final float[][] RATIOS_TABLE =
new float[PDF417Common.SYMBOL_TABLE.length][PDF417Common.BARS_IN_MODULE]; new float[PDF417Common.SYMBOL_TABLE.length][PDF417Common.BARS_IN_MODULE];
static { static {
@ -63,7 +63,7 @@ final class PDF417CodewordDecoder {
int sumPreviousBits = 0; int sumPreviousBits = 0;
for (int i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) { for (int i = 0; i < PDF417Common.MODULES_IN_CODEWORD; i++) {
float sampleIndex = float sampleIndex =
bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) + bitCountSum / (2 * PDF417Common.MODULES_IN_CODEWORD) +
(i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD; (i * bitCountSum) / PDF417Common.MODULES_IN_CODEWORD;
if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) { if (sumPreviousBits + moduleBitCount[bitCountIndex] <= sampleIndex) {
sumPreviousBits += moduleBitCount[bitCountIndex]; sumPreviousBits += moduleBitCount[bitCountIndex];

View file

@ -47,7 +47,7 @@ public final class PDF417ScanningDecoder {
// TODO don't pass in minCodewordWidth and maxCodewordWidth, pass in barcode columns for start and stop pattern // TODO don't pass in minCodewordWidth and maxCodewordWidth, pass in barcode columns for start and stop pattern
// columns. That way width can be deducted from the pattern column. // columns. That way width can be deducted from the pattern column.
// This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider // This approach also allows to detect more details about the barcode, e.g. if a bar type (white or black) is wider
// than it should be. This can happen if the scanner used a bad blackpoint. // than it should be. This can happen if the scanner used a bad blackpoint.
public static DecoderResult decode(BitMatrix image, public static DecoderResult decode(BitMatrix image,
ResultPoint imageTopLeft, ResultPoint imageTopLeft,
@ -285,7 +285,7 @@ public final class PDF417ScanningDecoder {
* for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of * for these ambiguous codewords instead of treating it as an erasure. The problem is that we don't know which of
* the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the * the ambiguous values to choose. We try decode using the first value, and if that fails, we use another of the
* ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes, * ambiguous values and try to decode again. This usually only happens on very hard to read and decode barcodes,
* so decoding the normal barcodes is not affected by this. * so decoding the normal barcodes is not affected by this.
* *
* @param erasureArray contains the indexes of erasures * @param erasureArray contains the indexes of erasures
* @param ambiguousIndexes array with the indexes that have more than one most likely value * @param ambiguousIndexes array with the indexes that have more than one most likely value
@ -433,7 +433,7 @@ public final class PDF417ScanningDecoder {
} }
// TODO implement check for width and correction of black and white bars // TODO implement check for width and correction of black and white bars
// use start (and maybe stop pattern) to determine if black bars are wider than white bars. If so, adjust. // use start (and maybe stop pattern) to determine if black bars are wider than white bars. If so, adjust.
// should probably done only for codewords with a lot more than 17 bits. // should probably done only for codewords with a lot more than 17 bits.
// The following fixes 10-1.png, which has wide black bars and small white bars // The following fixes 10-1.png, which has wide black bars and small white bars
// for (int i = 0; i < moduleBitCount.length; i++) { // for (int i = 0; i < moduleBitCount.length; i++) {
// if (i % 2 == 0) { // if (i % 2 == 0) {

View file

@ -108,5 +108,5 @@ public final class ModulusGF {
int getSize() { int getSize() {
return modulus; return modulus;
} }
} }

View file

@ -104,7 +104,7 @@ public final class Detector {
if (vertices[0] == null && vertices[3] == null) { if (vertices[0] == null && vertices[3] == null) {
if (!foundBarcodeInRow) { if (!foundBarcodeInRow) {
// we didn't find any barcode so that's the end of searching // we didn't find any barcode so that's the end of searching
break; break;
} }
// we didn't find a barcode starting at the given column and row. Try again from the first column and slightly // we didn't find a barcode starting at the given column and row. Try again from the first column and slightly
@ -127,7 +127,7 @@ public final class Detector {
if (!multiple) { if (!multiple) {
break; break;
} }
// if we didn't find a right row indicator column, then continue the search for the next barcode after the // if we didn't find a right row indicator column, then continue the search for the next barcode after the
// start pattern of the barcode just found. // start pattern of the barcode just found.
if (vertices[2] != null) { if (vertices[2] != null) {
column = (int) vertices[2].getX(); column = (int) vertices[2].getX();
@ -246,7 +246,7 @@ public final class Detector {
* @param width the number of pixels to search on this row * @param width the number of pixels to search on this row
* @param pattern pattern of counts of number of black and white pixels that are * @param pattern pattern of counts of number of black and white pixels that are
* being searched for as a pattern * being searched for as a pattern
* @param counters array of counters, as long as pattern, to re-use * @param counters array of counters, as long as pattern, to re-use
* @return start/end horizontal offset of guard pattern, as an array of two ints. * @return start/end horizontal offset of guard pattern, as an array of two ints.
*/ */
private static int[] findGuardPattern(BitMatrix matrix, private static int[] findGuardPattern(BitMatrix matrix,
@ -260,7 +260,7 @@ public final class Detector {
int patternStart = column; int patternStart = column;
int pixelDrift = 0; int pixelDrift = 0;
// if there are black pixels left of the current pixel shift to the left, but only for MAX_PIXEL_DRIFT pixels // if there are black pixels left of the current pixel shift to the left, but only for MAX_PIXEL_DRIFT pixels
while (matrix.get(patternStart, row) && patternStart > 0 && pixelDrift++ < MAX_PIXEL_DRIFT) { while (matrix.get(patternStart, row) && patternStart > 0 && pixelDrift++ < MAX_PIXEL_DRIFT) {
patternStart--; patternStart--;
} }

View file

@ -20,7 +20,7 @@ package com.google.zxing.pdf417.encoder;
* Represents possible PDF417 barcode compaction types. * Represents possible PDF417 barcode compaction types.
*/ */
public enum Compaction { public enum Compaction {
AUTO, AUTO,
TEXT, TEXT,
BYTE, BYTE,

View file

@ -98,13 +98,13 @@ final class PDF417HighLevelEncoder {
* identifier for a user defined Extended Channel Interpretation (ECI) * identifier for a user defined Extended Channel Interpretation (ECI)
*/ */
private static final int ECI_USER_DEFINED = 925; private static final int ECI_USER_DEFINED = 925;
/** /**
* identifier for a general purpose ECO format * identifier for a general purpose ECO format
*/ */
private static final int ECI_GENERAL_PURPOSE = 926; private static final int ECI_GENERAL_PURPOSE = 926;
/** /**
* identifier for an ECI of a character set of code page * identifier for an ECI of a character set of code page
*/ */
private static final int ECI_CHARSET = 927; private static final int ECI_CHARSET = 927;

View file

@ -129,7 +129,7 @@ public class QRCodeReader implements Reader {
int bottom = rightBottomBlack[1]; int bottom = rightBottomBlack[1];
int left = leftTopBlack[0]; int left = leftTopBlack[0];
int right = rightBottomBlack[0]; int right = rightBottomBlack[0];
// Sanity check! // Sanity check!
if (left >= right || top >= bottom) { if (left >= right || top >= bottom) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
@ -161,7 +161,7 @@ public class QRCodeReader implements Reader {
int nudge = (int) (moduleSize / 2.0f); int nudge = (int) (moduleSize / 2.0f);
top += nudge; top += nudge;
left += nudge; left += nudge;
// But careful that this does not sample off the edge // But careful that this does not sample off the edge
// "right" is the farthest-right valid pixel location -- right+1 is not necessarily // "right" is the farthest-right valid pixel location -- right+1 is not necessarily
// This is positive by how much the inner x loop below would be too large // This is positive by how much the inner x loop below would be too large

View file

@ -221,7 +221,7 @@ final class BitMatrixParser {
* This flag has effect only on the {@link #readFormatInformation()} and the * This flag has effect only on the {@link #readFormatInformation()} and the
* {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the * {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the
* {@link #mirror()} method should be called. * {@link #mirror()} method should be called.
* *
* @param mirror Whether to read version and format information mirrored. * @param mirror Whether to read version and format information mirrored.
*/ */
void setMirror(boolean mirror) { void setMirror(boolean mirror) {
@ -236,7 +236,7 @@ final class BitMatrixParser {
for (int y = x + 1; y < bitMatrix.getHeight(); y++) { for (int y = x + 1; y < bitMatrix.getHeight(); y++) {
if (bitMatrix.get(x, y) != bitMatrix.get(y, x)) { if (bitMatrix.get(x, y) != bitMatrix.get(y, x)) {
bitMatrix.flip(y, x); bitMatrix.flip(y, x);
bitMatrix.flip(x, y); bitMatrix.flip(x, y);
} }
} }
} }

View file

@ -58,7 +58,7 @@ final class DecodedBitStreamParser {
List<byte[]> byteSegments = new ArrayList<>(1); List<byte[]> byteSegments = new ArrayList<>(1);
int symbolSequence = -1; int symbolSequence = -1;
int parityData = -1; int parityData = -1;
try { try {
CharacterSetECI currentCharacterSetECI = null; CharacterSetECI currentCharacterSetECI = null;
boolean fc1InEffect = false; boolean fc1InEffect = false;

View file

@ -21,19 +21,19 @@ import com.google.zxing.ResultPoint;
/** /**
* Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the * Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the
* decoding caller. Callers are expected to process this. * decoding caller. Callers are expected to process this.
* *
* @see com.google.zxing.common.DecoderResult#getOther() * @see com.google.zxing.common.DecoderResult#getOther()
*/ */
public final class QRCodeDecoderMetaData { public final class QRCodeDecoderMetaData {
private final boolean mirrored; private final boolean mirrored;
QRCodeDecoderMetaData(boolean mirrored) { QRCodeDecoderMetaData(boolean mirrored) {
this.mirrored = mirrored; this.mirrored = mirrored;
} }
/** /**
* @return true if the QR Code was mirrored. * @return true if the QR Code was mirrored.
*/ */
public boolean isMirrored() { public boolean isMirrored() {
return mirrored; return mirrored;
@ -41,7 +41,7 @@ public final class QRCodeDecoderMetaData {
/** /**
* Apply the result points' order correction due to mirroring. * Apply the result points' order correction due to mirroring.
* *
* @param points Array of points to apply mirror correction to. * @param points Array of points to apply mirror correction to.
*/ */
public void applyMirroredCorrection(ResultPoint[] points) { public void applyMirroredCorrection(ResultPoint[] points) {

View file

@ -31,7 +31,7 @@ final class MatrixUtil {
// do nothing // do nothing
} }
private static final int[][] POSITION_DETECTION_PATTERN = { private static final int[][] POSITION_DETECTION_PATTERN = {
{1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0, 1},
{1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 0, 1},