proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
zxing_zxing | zxing/core/src/main/java/com/google/zxing/datamatrix/encoder/DefaultPlacement.java | DefaultPlacement | module | class DefaultPlacement {
private final CharSequence codewords;
private final int numrows;
private final int numcols;
private final byte[] bits;
/**
* Main constructor
*
* @param codewords the codewords to place
* @param numcols the number of columns
* @param numrows the number of rows
... |
if (row < 0) {
row += numrows;
col += 4 - ((numrows + 4) % 8);
}
if (col < 0) {
col += numcols;
row += 4 - ((numcols + 4) % 8);
}
// Note the conversion:
int v = codewords.charAt(pos);
v &= 1 << (8 - bit);
setBit(col, row, v != 0);
| 1,781 | 121 | 1,902 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/datamatrix/encoder/EdifactEncoder.java | EdifactEncoder | handleEOD | class EdifactEncoder implements Encoder {
@Override
public int getEncodingMode() {
return HighLevelEncoder.EDIFACT_ENCODATION;
}
@Override
public void encode(EncoderContext context) {
//step F
StringBuilder buffer = new StringBuilder();
while (context.hasMoreCharacters()) {
char c = co... |
try {
int count = buffer.length();
if (count == 0) {
return; //Already finished
}
if (count == 1) {
//Only an unlatch at the end
context.updateSymbolInfo();
int available = context.getSymbolInfo().getDataCapacity() - context.getCodewordCount();
int re... | 761 | 516 | 1,277 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/datamatrix/encoder/EncoderContext.java | EncoderContext | updateSymbolInfo | class EncoderContext {
private final String msg;
private SymbolShapeHint shape;
private Dimension minSize;
private Dimension maxSize;
private final StringBuilder codewords;
int pos;
private int newEncoding;
private SymbolInfo symbolInfo;
private int skipAtEnd;
EncoderContext(String msg) {
//Fr... |
if (this.symbolInfo == null || len > this.symbolInfo.getDataCapacity()) {
this.symbolInfo = SymbolInfo.lookup(len, shape, minSize, maxSize, true);
}
| 806 | 55 | 861 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/datamatrix/encoder/TextEncoder.java | TextEncoder | encodeChar | class TextEncoder extends C40Encoder {
@Override
public int getEncodingMode() {
return HighLevelEncoder.TEXT_ENCODATION;
}
@Override
int encodeChar(char c, StringBuilder sb) {<FILL_FUNCTION_BODY>}
} |
if (c == ' ') {
sb.append('\3');
return 1;
}
if (c >= '0' && c <= '9') {
sb.append((char) (c - 48 + 4));
return 1;
}
if (c >= 'a' && c <= 'z') {
sb.append((char) (c - 97 + 14));
return 1;
}
if (c < ' ') {
sb.append('\0'); //Shift 1 Set
sb.appe... | 78 | 520 | 598 | <methods>public void encode(com.google.zxing.datamatrix.encoder.EncoderContext) ,public int getEncodingMode() <variables> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/datamatrix/encoder/X12Encoder.java | X12Encoder | encodeChar | class X12Encoder extends C40Encoder {
@Override
public int getEncodingMode() {
return HighLevelEncoder.X12_ENCODATION;
}
@Override
public void encode(EncoderContext context) {
//step C
StringBuilder buffer = new StringBuilder();
while (context.hasMoreCharacters()) {
char c = context.ge... |
switch (c) {
case '\r':
sb.append('\0');
break;
case '*':
sb.append('\1');
break;
case '>':
sb.append('\2');
break;
case ' ':
sb.append('\3');
break;
default:
if (c >= '0' && c <= '9') {
sb.append((char)... | 472 | 192 | 664 | <methods>public void encode(com.google.zxing.datamatrix.encoder.EncoderContext) ,public int getEncodingMode() <variables> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/maxicode/MaxiCodeReader.java | MaxiCodeReader | extractPureBits | class MaxiCodeReader implements Reader {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
private static final int MATRIX_WIDTH = 30;
private static final int MATRIX_HEIGHT = 33;
private final Decoder decoder = new Decoder();
/**
* Locates and decodes a MaxiCode in an image.
*
* ... |
int[] enclosingRectangle = image.getEnclosingRectangle();
if (enclosingRectangle == null) {
throw NotFoundException.getNotFoundInstance();
}
int left = enclosingRectangle[0];
int top = enclosingRectangle[1];
int width = enclosingRectangle[2];
int height = enclosingRectangle[3];
... | 579 | 356 | 935 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/maxicode/decoder/Decoder.java | Decoder | correctErrors | class Decoder {
private static final int ALL = 0;
private static final int EVEN = 1;
private static final int ODD = 2;
private final ReedSolomonDecoder rsDecoder;
public Decoder() {
rsDecoder = new ReedSolomonDecoder(GenericGF.MAXICODE_FIELD_64);
}
public DecoderResult decode(BitMatrix bits) throw... |
int codewords = dataCodewords + ecCodewords;
// in EVEN or ODD mode only half the codewords
int divisor = mode == ALL ? 1 : 2;
// First read into an array of ints
int[] codewordsInts = new int[codewords / divisor];
for (int i = 0; i < codewords; i++) {
if ((mode == ALL) || (i % 2 == (mo... | 592 | 343 | 935 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/multi/ByQuadrantReader.java | ByQuadrantReader | decode | class ByQuadrantReader implements Reader {
private final Reader delegate;
public ByQuadrantReader(Reader delegate) {
this.delegate = delegate;
}
@Override
public Result decode(BinaryBitmap image)
throws NotFoundException, ChecksumException, FormatException {
return decode(image, null);
}
... |
int width = image.getWidth();
int height = image.getHeight();
int halfWidth = width / 2;
int halfHeight = height / 2;
try {
// No need to call makeAbsolute as results will be relative to original top left here
return delegate.decode(image.crop(0, 0, halfWidth, halfHeight), hints);
... | 285 | 418 | 703 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/multi/GenericMultipleBarcodeReader.java | GenericMultipleBarcodeReader | doDecodeMultiple | class GenericMultipleBarcodeReader implements MultipleBarcodeReader {
private static final int MIN_DIMENSION_TO_RECUR = 100;
private static final int MAX_DEPTH = 4;
static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
private final Reader delegate;
public GenericMultipleBarcodeReader(Reader delegate)... |
if (currentDepth > MAX_DEPTH) {
return;
}
Result result;
try {
result = delegate.decode(image, hints);
} catch (ReaderException ignored) {
return;
}
boolean alreadyFound = false;
for (Result existingResult : results) {
if (existingResult.getText().equals(result.... | 579 | 717 | 1,296 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/multi/qrcode/QRCodeMultiReader.java | QRCodeMultiReader | processStructuredAppend | class QRCodeMultiReader extends QRCodeReader implements MultipleBarcodeReader {
private static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
@Override
public Result[] decodeMultiple(BinaryBitmap image) throws NotFoundException {
retur... |
List<Result> newResults = new ArrayList<>();
List<Result> saResults = new ArrayList<>();
for (Result result : results) {
if (result.getResultMetadata().containsKey(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE)) {
saResults.add(result);
} else {
newResults.add(result);
}
... | 796 | 455 | 1,251 | <methods>public non-sealed void <init>() ,public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap) throws com.google.zxing.NotFoundException, com.google.zxing.ChecksumException, com.google.zxing.FormatException,public final com.google.zxing.Result decode(com.google.zxing.BinaryBitmap, Map<com.google.zxing.D... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/multi/qrcode/detector/MultiDetector.java | MultiDetector | detectMulti | class MultiDetector extends Detector {
private static final DetectorResult[] EMPTY_DETECTOR_RESULTS = new DetectorResult[0];
public MultiDetector(BitMatrix image) {
super(image);
}
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException {<FILL_FUNCTION_BODY>}
} |
BitMatrix image = getImage();
ResultPointCallback resultPointCallback =
hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
FinderPatternInfo[] infos = find... | 104 | 246 | 350 | <methods>public void <init>(com.google.zxing.common.BitMatrix) ,public com.google.zxing.common.DetectorResult detect() throws com.google.zxing.NotFoundException, com.google.zxing.FormatException,public final com.google.zxing.common.DetectorResult detect(Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.No... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/multi/qrcode/detector/MultiFinderPatternFinder.java | ModuleSizeComparator | selectMultipleBestPatterns | class ModuleSizeComparator implements Comparator<FinderPattern>, Serializable {
@Override
public int compare(FinderPattern center1, FinderPattern center2) {
float value = center2.getEstimatedModuleSize() - center1.getEstimatedModuleSize();
return value < 0.0 ? -1 : value > 0.0 ? 1 : 0;
}
}
... |
List<FinderPattern> possibleCenters = new ArrayList<>();
for (FinderPattern fp : getPossibleCenters()) {
if (fp.getCount() >= 2) {
possibleCenters.add(fp);
}
}
int size = possibleCenters.size();
if (size < 3) {
// Couldn't find enough finder patterns
throw NotFoundE... | 245 | 1,468 | 1,713 | <methods>public void <init>(com.google.zxing.common.BitMatrix) ,public void <init>(com.google.zxing.common.BitMatrix, com.google.zxing.ResultPointCallback) <variables>private static final int CENTER_QUORUM,protected static final int MAX_MODULES,protected static final int MIN_SKIP,private final non-sealed int[] crossChe... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/CodaBarWriter.java | CodaBarWriter | encode | class CodaBarWriter extends OneDimensionalCodeWriter {
private static final char[] START_END_CHARS = {'A', 'B', 'C', 'D'};
private static final char[] ALT_START_END_CHARS = {'T', 'N', '*', 'E'};
private static final char[] CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED = {'/', ':', '+', '.'};
private static fin... |
if (contents.length() < 2) {
// Can't have a start/end guard, so tentatively add default guards
contents = DEFAULT_GUARD + contents + DEFAULT_GUARD;
} else {
// Verify input and calculate decoded length.
char firstChar = Character.toUpperCase(contents.charAt(0));
char lastChar = ... | 210 | 1,047 | 1,257 | <methods>public non-sealed void <init>() ,public abstract boolean[] encode(java.lang.String) ,public boolean[] encode(java.lang.String, Map<com.google.zxing.EncodeHintType,?>) ,public final com.google.zxing.common.BitMatrix encode(java.lang.String, com.google.zxing.BarcodeFormat, int, int) ,public com.google.zxing.comm... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/Code39Writer.java | Code39Writer | encode | class Code39Writer extends OneDimensionalCodeWriter {
@Override
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
return Collections.singleton(BarcodeFormat.CODE_39);
}
@Override
public boolean[] encode(String contents) {<FILL_FUNCTION_BODY>}
private static void toIntArray(int a, int[]... |
int length = contents.length();
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
for (int i = 0; i < length; i++) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
... | 752 | 465 | 1,217 | <methods>public non-sealed void <init>() ,public abstract boolean[] encode(java.lang.String) ,public boolean[] encode(java.lang.String, Map<com.google.zxing.EncodeHintType,?>) ,public final com.google.zxing.common.BitMatrix encode(java.lang.String, com.google.zxing.BarcodeFormat, int, int) ,public com.google.zxing.comm... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/Code93Writer.java | Code93Writer | encode | class Code93Writer extends OneDimensionalCodeWriter {
@Override
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
return Collections.singleton(BarcodeFormat.CODE_93);
}
/**
* @param contents barcode contents to encode. It should not be encoded for extended characters.
* @return a {@co... |
contents = convertToExtended(contents);
int length = contents.length();
if (length > 80) {
throw new IllegalArgumentException("Requested contents should be less than 80 digits long after " +
"converting to extended encoding, but got " + length);
}
//length of code + 2 start/stop ch... | 1,223 | 449 | 1,672 | <methods>public non-sealed void <init>() ,public abstract boolean[] encode(java.lang.String) ,public boolean[] encode(java.lang.String, Map<com.google.zxing.EncodeHintType,?>) ,public final com.google.zxing.common.BitMatrix encode(java.lang.String, com.google.zxing.BarcodeFormat, int, int) ,public com.google.zxing.comm... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/EAN13Reader.java | EAN13Reader | decodeMiddle | class EAN13Reader extends UPCEANReader {
// For an EAN-13 barcode, the first digit is represented by the parities used
// to encode the next six digits, according to the table below. For example,
// if the barcode is 5 123456 789012 then the value of the first digit is
// signified by using odd for '1', even f... |
int[] counters = decodeMiddleCounters;
counters[0] = 0;
counters[1] = 0;
counters[2] = 0;
counters[3] = 0;
int end = row.getSize();
int rowOffset = startRange[1];
int lgPatternFound = 0;
for (int x = 0; x < 6 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counte... | 978 | 366 | 1,344 | <methods>public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray, Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.NotFoundException, com.google.zxing.ChecksumException, com.google.zxing.FormatException,public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray,... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/EAN13Writer.java | EAN13Writer | encode | class EAN13Writer extends UPCEANWriter {
private static final int CODE_WIDTH = 3 + // start guard
(7 * 6) + // left bars
5 + // middle guard
(7 * 6) + // right bars
3; // end guard
@Override
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
return Collections.singleton... |
int length = contents.length();
switch (length) {
case 12:
// No check digit present, calculate it and add it
int check;
try {
check = UPCEANReader.getStandardUPCEANChecksum(contents);
} catch (FormatException fe) {
throw new IllegalArgumentException(fe... | 146 | 580 | 726 | <methods>public non-sealed void <init>() ,public int getDefaultMargin() <variables> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/EAN8Reader.java | EAN8Reader | decodeMiddle | class EAN8Reader extends UPCEANReader {
private final int[] decodeMiddleCounters;
public EAN8Reader() {
decodeMiddleCounters = new int[4];
}
@Override
protected int decodeMiddle(BitArray row,
int[] startRange,
StringBuilder result) throws NotFou... |
int[] counters = decodeMiddleCounters;
counters[0] = 0;
counters[1] = 0;
counters[2] = 0;
counters[3] = 0;
int end = row.getSize();
int rowOffset = startRange[1];
for (int x = 0; x < 4 && rowOffset < end; x++) {
int bestMatch = decodeDigit(row, counters, rowOffset, L_PATTERNS);
... | 138 | 300 | 438 | <methods>public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray, Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.NotFoundException, com.google.zxing.ChecksumException, com.google.zxing.FormatException,public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray,... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/EAN8Writer.java | EAN8Writer | encode | class EAN8Writer extends UPCEANWriter {
private static final int CODE_WIDTH = 3 + // start guard
(7 * 4) + // left bars
5 + // middle guard
(7 * 4) + // right bars
3; // end guard
@Override
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
return Collections.singleton(... |
int length = contents.length();
switch (length) {
case 7:
// No check digit present, calculate it and add it
int check;
try {
check = UPCEANReader.getStandardUPCEANChecksum(contents);
} catch (FormatException fe) {
throw new IllegalArgumentException(fe)... | 170 | 468 | 638 | <methods>public non-sealed void <init>() ,public int getDefaultMargin() <variables> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/ITFWriter.java | ITFWriter | encode | class ITFWriter extends OneDimensionalCodeWriter {
private static final int[] START_PATTERN = {1, 1, 1, 1};
private static final int[] END_PATTERN = {3, 1, 1};
private static final int W = 3; // Pixel width of a 3x wide line
private static final int N = 1; // Pixed width of a narrow line
// See ITFReader.P... |
int length = contents.length();
if (length % 2 != 0) {
throw new IllegalArgumentException("The length of the input should be even");
}
if (length > 80) {
throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length);
}
che... | 366 | 306 | 672 | <methods>public non-sealed void <init>() ,public abstract boolean[] encode(java.lang.String) ,public boolean[] encode(java.lang.String, Map<com.google.zxing.EncodeHintType,?>) ,public final com.google.zxing.common.BitMatrix encode(java.lang.String, com.google.zxing.BarcodeFormat, int, int) ,public com.google.zxing.comm... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/MultiFormatOneDReader.java | MultiFormatOneDReader | decodeRow | class MultiFormatOneDReader extends OneDReader {
private static final OneDReader[] EMPTY_ONED_ARRAY = new OneDReader[0];
private final OneDReader[] readers;
public MultiFormatOneDReader(Map<DecodeHintType,?> hints) {
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats = hints == nu... |
for (OneDReader reader : readers) {
try {
return reader.decodeRow(rowNumber, row, hints);
} catch (ReaderException re) {
// continue
}
}
throw NotFoundException.getNotFoundInstance();
| 805 | 66 | 871 | <methods>public non-sealed void <init>() ,public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap) throws com.google.zxing.NotFoundException, com.google.zxing.FormatException,public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap, Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/MultiFormatUPCEANReader.java | MultiFormatUPCEANReader | decodeRow | class MultiFormatUPCEANReader extends OneDReader {
private static final UPCEANReader[] EMPTY_READER_ARRAY = new UPCEANReader[0];
private final UPCEANReader[] readers;
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) {
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats =... |
// Compute this location once and reuse it on multiple implementations
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
for (UPCEANReader reader : readers) {
try {
Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
// Special case: a 12-digit... | 497 | 603 | 1,100 | <methods>public non-sealed void <init>() ,public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap) throws com.google.zxing.NotFoundException, com.google.zxing.FormatException,public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap, Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/OneDimensionalCodeWriter.java | OneDimensionalCodeWriter | getDefaultMargin | class OneDimensionalCodeWriter implements Writer {
private static final Pattern NUMERIC = Pattern.compile("[0-9]+");
/**
* Encode the contents to boolean array expression of one-dimensional barcode.
* Start code and end code should be included in result, and side margins should not be included.
*
* @pa... |
// CodaBar spec requires a side margin to be more than ten times wider than narrow space.
// This seems like a decent idea for a default for all formats.
return 10;
| 1,260 | 48 | 1,308 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/UPCAReader.java | UPCAReader | maybeReturnResult | class UPCAReader extends UPCEANReader {
private final UPCEANReader ean13Reader = new EAN13Reader();
@Override
public Result decodeRow(int rowNumber,
BitArray row,
int[] startGuardRange,
Map<DecodeHintType,?> hints)
throws NotFou... |
String text = result.getText();
if (text.charAt(0) == '0') {
Result upcaResult = new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
if (result.getResultMetadata() != null) {
upcaResult.putAllMetadata(result.getResultMetadata());
}
return upcaResu... | 428 | 122 | 550 | <methods>public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray, Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.NotFoundException, com.google.zxing.ChecksumException, com.google.zxing.FormatException,public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray,... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/UPCAWriter.java | UPCAWriter | encode | class UPCAWriter implements Writer {
private final EAN13Writer subWriter = new EAN13Writer();
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) {
return encode(contents, format, width, height, null);
}
@Override
public BitMatrix encode(String contents,
... |
if (format != BarcodeFormat.UPC_A) {
throw new IllegalArgumentException("Can only encode UPC-A, but got " + format);
}
// Transform a UPC-A code into the equivalent EAN-13 code and write it that way
return subWriter.encode('0' + contents, BarcodeFormat.EAN_13, width, height, hints);
| 139 | 100 | 239 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/UPCEANExtension2Support.java | UPCEANExtension2Support | decodeRow | class UPCEANExtension2Support {
private final int[] decodeMiddleCounters = new int[4];
private final StringBuilder decodeRowStringBuffer = new StringBuilder();
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {<FILL_FUNCTION_BODY>}
private int decodeMiddle(Bit... |
StringBuilder result = decodeRowStringBuffer;
result.setLength(0);
int end = decodeMiddle(row, extensionStartRange, result);
String resultString = result.toString();
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
Result extensionResult =
new Result... | 618 | 192 | 810 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/UPCEANExtension5Support.java | UPCEANExtension5Support | parseExtension5String | class UPCEANExtension5Support {
private static final int[] CHECK_DIGIT_ENCODINGS = {
0x18, 0x14, 0x12, 0x11, 0x0C, 0x06, 0x03, 0x0A, 0x09, 0x05
};
private final int[] decodeMiddleCounters = new int[4];
private final StringBuilder decodeRowStringBuffer = new StringBuilder();
Result decodeRow(int rowNu... |
String currency;
switch (raw.charAt(0)) {
case '0':
currency = "£";
break;
case '5':
currency = "$";
break;
case '9':
// Reference: http://www.jollytech.com
switch (raw) {
case "90000":
// No suggested retail price
... | 1,176 | 274 | 1,450 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/UPCEANExtensionSupport.java | UPCEANExtensionSupport | decodeRow | class UPCEANExtensionSupport {
private static final int[] EXTENSION_START_PATTERN = {1,1,2};
private final UPCEANExtension2Support twoSupport = new UPCEANExtension2Support();
private final UPCEANExtension5Support fiveSupport = new UPCEANExtension5Support();
Result decodeRow(int rowNumber, BitArray row, int r... |
int[] extensionStartRange = UPCEANReader.findGuardPattern(row, rowOffset, false, EXTENSION_START_PATTERN);
try {
return fiveSupport.decodeRow(rowNumber, row, extensionStartRange);
} catch (ReaderException ignored) {
return twoSupport.decodeRow(rowNumber, row, extensionStartRange);
}
| 117 | 92 | 209 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/UPCEReader.java | UPCEReader | convertUPCEtoUPCA | class UPCEReader extends UPCEANReader {
/**
* The pattern that marks the middle, and end, of a UPC-E pattern.
* There is no "second half" to a UPC-E barcode.
*/
private static final int[] MIDDLE_END_PATTERN = {1, 1, 1, 1, 1, 1};
// For an UPC-E barcode, the final digit is represented by the parities us... |
char[] upceChars = new char[6];
upce.getChars(1, 7, upceChars, 0);
StringBuilder result = new StringBuilder(12);
result.append(upce.charAt(0));
char lastChar = upceChars[5];
switch (lastChar) {
case '0':
case '1':
case '2':
result.append(upceChars, 0, 2);
resul... | 1,390 | 367 | 1,757 | <methods>public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray, Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.NotFoundException, com.google.zxing.ChecksumException, com.google.zxing.FormatException,public com.google.zxing.Result decodeRow(int, com.google.zxing.common.BitArray,... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/UPCEWriter.java | UPCEWriter | encode | class UPCEWriter extends UPCEANWriter {
private static final int CODE_WIDTH = 3 + // start guard
(7 * 6) + // bars
6; // end guard
@Override
protected Collection<BarcodeFormat> getSupportedWriteFormats() {
return Collections.singleton(BarcodeFormat.UPC_E);
}
@Override
public boolean[] enc... |
int length = contents.length();
switch (length) {
case 7:
// No check digit present, calculate it and add it
int check;
try {
check = UPCEANReader.getStandardUPCEANChecksum(UPCEReader.convertUPCEtoUPCA(contents));
} catch (FormatException fe) {
throw ne... | 123 | 548 | 671 | <methods>public non-sealed void <init>() ,public int getDefaultMargin() <variables> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/AbstractRSSReader.java | AbstractRSSReader | isFinderPattern | class AbstractRSSReader extends OneDReader {
private static final float MAX_AVG_VARIANCE = 0.2f;
private static final float MAX_INDIVIDUAL_VARIANCE = 0.45f;
/** Minimum ratio 10:12 (minus 0.5 for variance), from section 7.2.7 of ISO/IEC 24724:2006. */
private static final float MIN_FINDER_PATTERN_RATIO = 9.5f... |
int firstTwoSum = counters[0] + counters[1];
int sum = firstTwoSum + counters[2] + counters[3];
float ratio = firstTwoSum / (float) sum;
if (ratio >= MIN_FINDER_PATTERN_RATIO && ratio <= MAX_FINDER_PATTERN_RATIO) {
// passes ratio test in spec, but see if the counts are unreasonable
int min... | 956 | 208 | 1,164 | <methods>public non-sealed void <init>() ,public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap) throws com.google.zxing.NotFoundException, com.google.zxing.FormatException,public com.google.zxing.Result decode(com.google.zxing.BinaryBitmap, Map<com.google.zxing.DecodeHintType,?>) throws com.google.zxing.... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/DataCharacter.java | DataCharacter | equals | class DataCharacter {
private final int value;
private final int checksumPortion;
public DataCharacter(int value, int checksumPortion) {
this.value = value;
this.checksumPortion = checksumPortion;
}
public final int getValue() {
return value;
}
public final int getChecksumPortion() {
r... |
if (!(o instanceof DataCharacter)) {
return false;
}
DataCharacter that = (DataCharacter) o;
return value == that.value && checksumPortion == that.checksumPortion;
| 200 | 56 | 256 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/FinderPattern.java | FinderPattern | equals | class FinderPattern {
private final int value;
private final int[] startEnd;
private final ResultPoint[] resultPoints;
public FinderPattern(int value, int[] startEnd, int start, int end, int rowNumber) {
this.value = value;
this.startEnd = startEnd;
this.resultPoints = new ResultPoint[] {
... |
if (!(o instanceof FinderPattern)) {
return false;
}
FinderPattern that = (FinderPattern) o;
return value == that.value;
| 225 | 44 | 269 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/RSSUtils.java | RSSUtils | getRSSvalue | class RSSUtils {
private RSSUtils() {}
public static int getRSSvalue(int[] widths, int maxWidth, boolean noNarrow) {<FILL_FUNCTION_BODY>}
private static int combins(int n, int r) {
int maxDenom;
int minDenom;
if (n - r > r) {
minDenom = r;
maxDenom = n - r;
} else {
minDenom =... |
int n = 0;
for (int width : widths) {
n += width;
}
int val = 0;
int narrowMask = 0;
int elements = widths.length;
for (int bar = 0; bar < elements - 1; bar++) {
int elmWidth;
for (elmWidth = 1, narrowMask |= 1 << bar;
elmWidth < widths[bar];
elmWidth... | 244 | 394 | 638 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/BitArrayBuilder.java | BitArrayBuilder | buildBitArray | class BitArrayBuilder {
private BitArrayBuilder() {
}
static BitArray buildBitArray(List<ExpandedPair> pairs) {<FILL_FUNCTION_BODY>}
} |
int charNumber = (pairs.size() * 2) - 1;
if (pairs.get(pairs.size() - 1).getRightChar() == null) {
charNumber -= 1;
}
int size = 12 * charNumber;
BitArray binary = new BitArray(size);
int accPos = 0;
ExpandedPair firstPair = pairs.get(0);
int firstValue = firstPair.getRightChar... | 51 | 384 | 435 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/ExpandedPair.java | ExpandedPair | toString | class ExpandedPair {
private final DataCharacter leftChar;
private final DataCharacter rightChar;
private final FinderPattern finderPattern;
ExpandedPair(DataCharacter leftChar,
DataCharacter rightChar,
FinderPattern finderPattern) {
this.leftChar = leftChar;
this.rightCh... |
return
"[ " + leftChar + " , " + rightChar + " : " +
(finderPattern == null ? "null" : finderPattern.getValue()) + " ]";
| 364 | 48 | 412 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/ExpandedRow.java | ExpandedRow | equals | class ExpandedRow {
private final List<ExpandedPair> pairs;
private final int rowNumber;
ExpandedRow(List<ExpandedPair> pairs, int rowNumber) {
this.pairs = new ArrayList<>(pairs);
this.rowNumber = rowNumber;
}
List<ExpandedPair> getPairs() {
return this.pairs;
}
int getRowNumber() {
r... |
if (!(o instanceof ExpandedRow)) {
return false;
}
ExpandedRow that = (ExpandedRow) o;
return this.pairs.equals(that.pairs);
| 261 | 52 | 313 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01320xDecoder.java | AI01320xDecoder | checkWeight | class AI01320xDecoder extends AI013x0xDecoder {
AI01320xDecoder(BitArray information) {
super(information);
}
@Override
protected void addWeightCode(StringBuilder buf, int weight) {
if (weight < 10000) {
buf.append("(3202)");
} else {
buf.append("(3203)");
}
}
@Override
prot... |
if (weight < 10000) {
return weight;
}
return weight - 10000;
| 151 | 36 | 187 | <methods>public java.lang.String parseInformation() throws com.google.zxing.NotFoundException<variables>private static final int HEADER_SIZE,private static final int WEIGHT_SIZE |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01392xDecoder.java | AI01392xDecoder | parseInformation | class AI01392xDecoder extends AI01decoder {
private static final int HEADER_SIZE = 5 + 1 + 2;
private static final int LAST_DIGIT_SIZE = 2;
AI01392xDecoder(BitArray information) {
super(information);
}
@Override
public String parseInformation() throws NotFoundException, FormatException {<FILL_FUNCTIO... |
if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
throw NotFoundException.getNotFoundInstance();
}
StringBuilder buf = new StringBuilder();
encodeCompressedGtin(buf, HEADER_SIZE);
int lastAIdigit =
this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE ... | 116 | 218 | 334 | <methods><variables>static final int GTIN_SIZE |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01393xDecoder.java | AI01393xDecoder | parseInformation | class AI01393xDecoder extends AI01decoder {
private static final int HEADER_SIZE = 5 + 1 + 2;
private static final int LAST_DIGIT_SIZE = 2;
private static final int FIRST_THREE_DIGITS_SIZE = 10;
AI01393xDecoder(BitArray information) {
super(information);
}
@Override
public String parseInformation()... |
if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
throw NotFoundException.getNotFoundInstance();
}
StringBuilder buf = new StringBuilder();
encodeCompressedGtin(buf, HEADER_SIZE);
int lastAIdigit =
this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE ... | 137 | 357 | 494 | <methods><variables>static final int GTIN_SIZE |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI013x0x1xDecoder.java | AI013x0x1xDecoder | parseInformation | class AI013x0x1xDecoder extends AI01weightDecoder {
private static final int HEADER_SIZE = 7 + 1;
private static final int WEIGHT_SIZE = 20;
private static final int DATE_SIZE = 16;
private final String dateCode;
private final String firstAIdigits;
AI013x0x1xDecoder(BitArray information, String firstAIdi... |
if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) {
throw NotFoundException.getNotFoundInstance();
}
StringBuilder buf = new StringBuilder();
encodeCompressedGtin(buf, HEADER_SIZE);
encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE);
... | 543 | 140 | 683 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI013x0xDecoder.java | AI013x0xDecoder | parseInformation | class AI013x0xDecoder extends AI01weightDecoder {
private static final int HEADER_SIZE = 4 + 1;
private static final int WEIGHT_SIZE = 15;
AI013x0xDecoder(BitArray information) {
super(information);
}
@Override
public String parseInformation() throws NotFoundException {<FILL_FUNCTION_BODY>}
} |
if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) {
throw NotFoundException.getNotFoundInstance();
}
StringBuilder buf = new StringBuilder();
encodeCompressedGtin(buf, HEADER_SIZE);
encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE);
return bu... | 108 | 110 | 218 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01AndOtherAIs.java | AI01AndOtherAIs | parseInformation | class AI01AndOtherAIs extends AI01decoder {
private static final int HEADER_SIZE = 1 + 1 + 2; //first bit encodes the linkage flag,
//the second one is the encodation method, and the other two are for the variable length
AI01AndOtherAIs(BitArray information) {
super(information);
}
... |
StringBuilder buff = new StringBuilder();
buff.append("(01)");
int initialGtinPosition = buff.length();
int firstGtinDigit = this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE, 4);
buff.append(firstGtinDigit);
this.encodeCompressedGtinWithoutAI(buff, HEADER_SIZE + 4, initial... | 125 | 142 | 267 | <methods><variables>static final int GTIN_SIZE |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01decoder.java | AI01decoder | appendCheckDigit | class AI01decoder extends AbstractExpandedDecoder {
static final int GTIN_SIZE = 40;
AI01decoder(BitArray information) {
super(information);
}
final void encodeCompressedGtin(StringBuilder buf, int currentPos) {
buf.append("(01)");
int initialPosition = buf.length();
buf.append('9');
enc... |
int checkDigit = 0;
for (int i = 0; i < 13; i++) {
int digit = buf.charAt(i + currentPos) - '0';
checkDigit += (i & 0x01) == 0 ? 3 * digit : digit;
}
checkDigit = 10 - (checkDigit % 10);
if (checkDigit == 10) {
checkDigit = 0;
}
buf.append(checkDigit);
| 318 | 130 | 448 | <methods>public static com.google.zxing.oned.rss.expanded.decoders.AbstractExpandedDecoder createDecoder(com.google.zxing.common.BitArray) ,public abstract java.lang.String parseInformation() throws com.google.zxing.NotFoundException, com.google.zxing.FormatException<variables>private final non-sealed com.google.zxing.... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AI01weightDecoder.java | AI01weightDecoder | encodeCompressedWeight | class AI01weightDecoder extends AI01decoder {
AI01weightDecoder(BitArray information) {
super(information);
}
final void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) {<FILL_FUNCTION_BODY>}
protected abstract void addWeightCode(StringBuilder buf, int weight);
protected abst... |
int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize);
addWeightCode(buf, originalWeightNumeric);
int weightNumeric = checkWeight(originalWeightNumeric);
int currentDivisor = 100000;
for (int i = 0; i < 5; ++i) {
if (weightNumeric / cur... | 106 | 143 | 249 | <methods><variables>static final int GTIN_SIZE |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/oned/rss/expanded/decoders/AbstractExpandedDecoder.java | AbstractExpandedDecoder | createDecoder | class AbstractExpandedDecoder {
private final BitArray information;
private final GeneralAppIdDecoder generalDecoder;
AbstractExpandedDecoder(BitArray information) {
this.information = information;
this.generalDecoder = new GeneralAppIdDecoder(information);
}
protected final BitArray getInformation... |
if (information.get(1)) {
return new AI01AndOtherAIs(information);
}
if (!information.get(2)) {
return new AnyAIDecoder(information);
}
int fourBitEncodationMethod = GeneralAppIdDecoder.extractNumericValueFromBitArray(information, 1, 4);
switch (fourBitEncodationMethod) {
ca... | 168 | 561 | 729 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/PDF417Reader.java | PDF417Reader | getMaxWidth | class PDF417Reader implements Reader, MultipleBarcodeReader {
private static final Result[] EMPTY_RESULT_ARRAY = new Result[0];
/**
* Locates and decodes a PDF417 code in an image.
*
* @return a String representing the content encoded by the PDF417 code
* @throws NotFoundException if a PDF417 code can... |
if (p1 == null || p2 == null) {
return 0;
}
return (int) Math.abs(p1.getX() - p2.getX());
| 1,302 | 50 | 1,352 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/PDF417Writer.java | PDF417Writer | encode | class PDF417Writer implements Writer {
/**
* default white space (margin) around the code
*/
private static final int WHITE_SPACE = 30;
/**
* default error correction level
*/
private static final int DEFAULT_ERROR_CORRECTION_LEVEL = 2;
@Override
public BitMatrix encode(String contents,
... |
if (format != BarcodeFormat.PDF_417) {
throw new IllegalArgumentException("Can only encode PDF_417, but got " + format);
}
PDF417 encoder = new PDF417();
int margin = WHITE_SPACE;
int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;
boolean autoECI = false;
if (hints != null) ... | 976 | 610 | 1,586 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/BarcodeValue.java | BarcodeValue | setValue | class BarcodeValue {
private final Map<Integer,Integer> values = new HashMap<>();
/**
* Add an occurrence of a value
*/
void setValue(int value) {<FILL_FUNCTION_BODY>}
/**
* Determines the maximum occurrence of a set value and returns all values which were set with this occurrence.
* @return an ar... |
Integer confidence = values.get(value);
if (confidence == null) {
confidence = 0;
}
confidence++;
values.put(value, confidence);
| 285 | 48 | 333 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/BoundingBox.java | BoundingBox | addMissingRows | class BoundingBox {
private final BitMatrix image;
private final ResultPoint topLeft;
private final ResultPoint bottomLeft;
private final ResultPoint topRight;
private final ResultPoint bottomRight;
private final int minX;
private final int maxX;
private final int minY;
private final int maxY;
Bou... |
ResultPoint newTopLeft = topLeft;
ResultPoint newBottomLeft = bottomLeft;
ResultPoint newTopRight = topRight;
ResultPoint newBottomRight = bottomRight;
if (missingStartRows > 0) {
ResultPoint top = isLeft ? topLeft : topRight;
int newMinY = (int) top.getY() - missingStartRows;
if... | 892 | 338 | 1,230 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/Codeword.java | Codeword | isValidRowNumber | class Codeword {
private static final int BARCODE_ROW_UNKNOWN = -1;
private final int startX;
private final int endX;
private final int bucket;
private final int value;
private int rowNumber = BARCODE_ROW_UNKNOWN;
Codeword(int startX, int endX, int bucket, int value) {
this.startX = startX;
thi... |
return rowNumber != BARCODE_ROW_UNKNOWN && bucket == (rowNumber % 3) * 3;
| 389 | 34 | 423 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/DetectionResultColumn.java | DetectionResultColumn | getCodewordNearby | class DetectionResultColumn {
private static final int MAX_NEARBY_DISTANCE = 5;
private final BoundingBox boundingBox;
private final Codeword[] codewords;
DetectionResultColumn(BoundingBox boundingBox) {
this.boundingBox = new BoundingBox(boundingBox);
codewords = new Codeword[boundingBox.getMaxY() -... |
Codeword codeword = getCodeword(imageRow);
if (codeword != null) {
return codeword;
}
for (int i = 1; i < MAX_NEARBY_DISTANCE; i++) {
int nearImageRow = imageRowToCodewordIndex(imageRow) - i;
if (nearImageRow >= 0) {
codeword = codewords[nearImageRow];
if (codeword != ... | 434 | 204 | 638 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/PDF417CodewordDecoder.java | PDF417CodewordDecoder | getClosestDecodedValue | class PDF417CodewordDecoder {
private static final float[][] RATIOS_TABLE =
new float[PDF417Common.SYMBOL_TABLE.length][PDF417Common.BARS_IN_MODULE];
static {
// Pre-computes the symbol ratio table.
for (int i = 0; i < PDF417Common.SYMBOL_TABLE.length; i++) {
int currentSymbol = PDF417Common.S... |
int bitCountSum = MathUtils.sum(moduleBitCount);
float[] bitCountRatios = new float[PDF417Common.BARS_IN_MODULE];
if (bitCountSum > 1) {
for (int i = 0; i < bitCountRatios.length; i++) {
bitCountRatios[i] = moduleBitCount[i] / (float) bitCountSum;
}
}
float bestMatchError = Floa... | 818 | 309 | 1,127 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/ec/ErrorCorrection.java | ErrorCorrection | decode | class ErrorCorrection {
private final ModulusGF field;
public ErrorCorrection() {
this.field = ModulusGF.PDF417_GF;
}
/**
* @param received received codewords
* @param numECCodewords number of those codewords used for EC
* @param erasures location of erasures
* @return number of errors
* @... |
ModulusPoly poly = new ModulusPoly(field, received);
int[] S = new int[numECCodewords];
boolean error = false;
for (int i = numECCodewords; i > 0; i--) {
int eval = poly.evaluateAt(field.exp(i));
S[numECCodewords - i] = eval;
if (eval != 0) {
error = true;
}
}
... | 1,324 | 532 | 1,856 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/ec/ModulusGF.java | ModulusGF | log | class ModulusGF {
public static final ModulusGF PDF417_GF = new ModulusGF(PDF417Common.NUMBER_OF_CODEWORDS, 3);
private final int[] expTable;
private final int[] logTable;
private final ModulusPoly zero;
private final ModulusPoly one;
private final int modulus;
private ModulusGF(int modulus, int genera... |
if (a == 0) {
throw new IllegalArgumentException();
}
return logTable[a];
| 653 | 30 | 683 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/decoder/ec/ModulusPoly.java | ModulusPoly | negative | class ModulusPoly {
private final ModulusGF field;
private final int[] coefficients;
ModulusPoly(ModulusGF field, int[] coefficients) {
if (coefficients.length == 0) {
throw new IllegalArgumentException();
}
this.field = field;
int coefficientsLength = coefficients.length;
if (coeffici... |
int size = coefficients.length;
int[] negativeCoefficients = new int[size];
for (int i = 0; i < size; i++) {
negativeCoefficients[i] = field.subtract(0, coefficients[i]);
}
return new ModulusPoly(field, negativeCoefficients);
| 1,813 | 84 | 1,897 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/encoder/BarcodeMatrix.java | BarcodeMatrix | getScaledMatrix | class BarcodeMatrix {
private final BarcodeRow[] matrix;
private int currentRow;
private final int height;
private final int width;
/**
* @param height the height of the matrix (Rows)
* @param width the width of the matrix (Cols)
*/
BarcodeMatrix(int height, int width) {
matrix = new Barcode... |
byte[][] matrixOut = new byte[height * yScale][width * xScale];
int yMax = height * yScale;
for (int i = 0; i < yMax; i++) {
matrixOut[yMax - i - 1] = matrix[i / yScale].getScaledRow(xScale);
}
return matrixOut;
| 332 | 91 | 423 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/pdf417/encoder/BarcodeRow.java | BarcodeRow | getScaledRow | class BarcodeRow {
private final byte[] row;
//A tacker for position in the bar
private int currentLocation;
/**
* Creates a Barcode row of the width
*/
BarcodeRow(int width) {
this.row = new byte[width];
currentLocation = 0;
}
/**
* Sets a specific location in the bar
*
* @param... |
byte[] output = new byte[row.length * scale];
for (int i = 0; i < output.length; i++) {
output[i] = row[i / scale];
}
return output;
| 401 | 58 | 459 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/QRCodeReader.java | QRCodeReader | extractPureBits | class QRCodeReader implements Reader {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0];
private final Decoder decoder = new Decoder();
protected final Decoder getDecoder() {
return decoder;
}
/**
* Locates and decodes a QR code in an image.
*
* @return a String representing ... |
int[] leftTopBlack = image.getTopLeftOnBit();
int[] rightBottomBlack = image.getBottomRightOnBit();
if (leftTopBlack == null || rightBottomBlack == null) {
throw NotFoundException.getNotFoundInstance();
}
float moduleSize = moduleSize(leftTopBlack, image);
int top = leftTopBlack[1];
... | 1,112 | 853 | 1,965 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/QRCodeWriter.java | QRCodeWriter | renderResult | class QRCodeWriter implements Writer {
private static final int QUIET_ZONE_SIZE = 4;
@Override
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height)
throws WriterException {
return encode(contents, format, width, height, null);
}
@Override
public BitMatrix encod... |
ByteMatrix input = code.getMatrix();
if (input == null) {
throw new IllegalStateException();
}
int inputWidth = input.getWidth();
int inputHeight = input.getHeight();
int qrWidth = inputWidth + (quietZone * 2);
int qrHeight = inputHeight + (quietZone * 2);
int outputWidth = Math.m... | 535 | 461 | 996 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/decoder/DataBlock.java | DataBlock | getDataBlocks | class DataBlock {
private final int numDataCodewords;
private final byte[] codewords;
private DataBlock(int numDataCodewords, byte[] codewords) {
this.numDataCodewords = numDataCodewords;
this.codewords = codewords;
}
/**
* <p>When QR Codes use multiple data blocks, they are actually interleaved... |
if (rawCodewords.length != version.getTotalCodewords()) {
throw new IllegalArgumentException();
}
// Figure out the number and size of data blocks used by this version and
// error correction level
Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel);
// First count the tot... | 313 | 795 | 1,108 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/decoder/Decoder.java | Decoder | decode | class Decoder {
private final ReedSolomonDecoder rsDecoder;
public Decoder() {
rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256);
}
public DecoderResult decode(boolean[][] image) throws ChecksumException, FormatException {
return decode(image, null);
}
/**
* <p>Convenience metho... |
Version version = parser.readVersion();
ErrorCorrectionLevel ecLevel = parser.readFormatInformation().getErrorCorrectionLevel();
// Read codewords
byte[] codewords = parser.readCodewords();
// Separate into data blocks
DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLeve... | 1,334 | 350 | 1,684 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/decoder/FormatInformation.java | FormatInformation | doDecodeFormatInformation | class FormatInformation {
private static final int FORMAT_INFO_MASK_QR = 0x5412;
/**
* See ISO 18004:2006, Annex C, Table C.1
*/
private static final int[][] FORMAT_INFO_DECODE_LOOKUP = {
{0x5412, 0x00},
{0x5125, 0x01},
{0x5E7C, 0x02},
{0x5B4B, 0x03},
{0x45F9, 0x04},
{0... |
// Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing
int bestDifference = Integer.MAX_VALUE;
int bestFormatInfo = 0;
for (int[] decodeInfo : FORMAT_INFO_DECODE_LOOKUP) {
int targetInfo = decodeInfo[0];
if (targetInfo == maskedFormatInfo1 || targetInfo == maskedFormatInfo2... | 1,168 | 347 | 1,515 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/decoder/QRCodeDecoderMetaData.java | QRCodeDecoderMetaData | applyMirroredCorrection | class QRCodeDecoderMetaData {
private final boolean mirrored;
QRCodeDecoderMetaData(boolean mirrored) {
this.mirrored = mirrored;
}
/**
* @return true if the QR Code was mirrored.
*/
public boolean isMirrored() {
return mirrored;
}
/**
* Apply the result points' order correction due t... |
if (!mirrored || points == null || points.length < 3) {
return;
}
ResultPoint bottomLeft = points[0];
points[0] = points[2];
points[2] = bottomLeft;
// No need to 'fix' top-left and alignment pattern.
| 170 | 77 | 247 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/detector/AlignmentPattern.java | AlignmentPattern | aboutEquals | class AlignmentPattern extends ResultPoint {
private final float estimatedModuleSize;
AlignmentPattern(float posX, float posY, float estimatedModuleSize) {
super(posX, posY);
this.estimatedModuleSize = estimatedModuleSize;
}
/**
* <p>Determines if this alignment pattern "about equals" an alignment... |
if (Math.abs(i - getY()) <= moduleSize && Math.abs(j - getX()) <= moduleSize) {
float moduleSizeDiff = Math.abs(moduleSize - estimatedModuleSize);
return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize;
}
return false;
| 312 | 80 | 392 | <methods>public void <init>(float, float) ,public static float distance(com.google.zxing.ResultPoint, com.google.zxing.ResultPoint) ,public final boolean equals(java.lang.Object) ,public final float getX() ,public final float getY() ,public final int hashCode() ,public static void orderBestPatterns(com.google.zxing.Res... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/detector/FinderPattern.java | FinderPattern | combineEstimate | class FinderPattern extends ResultPoint {
private final float estimatedModuleSize;
private final int count;
FinderPattern(float posX, float posY, float estimatedModuleSize) {
this(posX, posY, estimatedModuleSize, 1);
}
private FinderPattern(float posX, float posY, float estimatedModuleSize, int count) ... |
int combinedCount = count + 1;
float combinedX = (count * getX() + j) / combinedCount;
float combinedY = (count * getY() + i) / combinedCount;
float combinedModuleSize = (count * estimatedModuleSize + newModuleSize) / combinedCount;
return new FinderPattern(combinedX, combinedY, combinedModuleSize,... | 407 | 94 | 501 | <methods>public void <init>(float, float) ,public static float distance(com.google.zxing.ResultPoint, com.google.zxing.ResultPoint) ,public final boolean equals(java.lang.Object) ,public final float getX() ,public final float getY() ,public final int hashCode() ,public static void orderBestPatterns(com.google.zxing.Res... |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/encoder/ByteMatrix.java | ByteMatrix | toString | class ByteMatrix {
private final byte[][] bytes;
private final int width;
private final int height;
public ByteMatrix(int width, int height) {
bytes = new byte[height][width];
this.width = width;
this.height = height;
}
public int getHeight() {
return height;
}
public int getWidth() ... |
StringBuilder result = new StringBuilder(2 * width * height + 2);
for (int y = 0; y < height; ++y) {
byte[] bytesY = bytes[y];
for (int x = 0; x < width; ++x) {
switch (bytesY[x]) {
case 0:
result.append(" 0");
break;
case 1:
result.ap... | 363 | 155 | 518 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/encoder/MinimalEncoder.java | ResultNode | makePrintable | class ResultNode {
private final Mode mode;
private final int fromPosition;
private final int charsetEncoderIndex;
private final int characterLength;
ResultNode(Mode mode, int fromPosition, int charsetEncoderIndex, int characterLength) {
this.mode = mode;
this.fromPositio... |
StringBuilder result = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) < 32 || s.charAt(i) > 126) {
result.append('.');
} else {
result.append(s.charAt(i));
}
}
return result.toString();
| 817 | 98 | 915 | <no_super_class> |
zxing_zxing | zxing/core/src/main/java/com/google/zxing/qrcode/encoder/QRCode.java | QRCode | toString | class QRCode {
public static final int NUM_MASK_PATTERNS = 8;
private Mode mode;
private ErrorCorrectionLevel ecLevel;
private Version version;
private int maskPattern;
private ByteMatrix matrix;
public QRCode() {
maskPattern = -1;
}
/**
* @return the mode. Not relevant if {@link com.google... |
StringBuilder result = new StringBuilder(200);
result.append("<<\n");
result.append(" mode: ");
result.append(mode);
result.append("\n ecLevel: ");
result.append(ecLevel);
result.append("\n version: ");
result.append(version);
result.append("\n maskPattern: ");
result.append(mas... | 415 | 168 | 583 | <no_super_class> |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/BufferedImageLuminanceSource.java | BufferedImageLuminanceSource | crop | class BufferedImageLuminanceSource extends LuminanceSource {
private static final double MINUS_45_IN_RADIANS = -0.7853981633974483; // Math.toRadians(-45.0)
private final BufferedImage image;
private final int left;
private final int top;
public BufferedImageLuminanceSource(BufferedImage image) {
this(... |
return new BufferedImageLuminanceSource(image, this.left + left, this.top + top, width, height);
| 1,727 | 33 | 1,760 | <methods>public com.google.zxing.LuminanceSource crop(int, int, int, int) ,public final int getHeight() ,public abstract byte[] getMatrix() ,public abstract byte[] getRow(int, byte[]) ,public final int getWidth() ,public com.google.zxing.LuminanceSource invert() ,public boolean isCropSupported() ,public boolean isRotat... |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/CommandLineEncoder.java | CommandLineEncoder | main | class CommandLineEncoder {
private CommandLineEncoder() {
}
public static void main(String[] args) throws Exception {<FILL_FUNCTION_BODY>}
} |
EncoderConfig config = new EncoderConfig();
JCommander jCommander = new JCommander(config);
jCommander.parse(args);
jCommander.setProgramName(CommandLineEncoder.class.getSimpleName());
if (config.help) {
jCommander.usage();
return;
}
String outFileString = config.outputFileBase... | 50 | 294 | 344 | <no_super_class> |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/CommandLineRunner.java | CommandLineRunner | main | class CommandLineRunner {
private CommandLineRunner() {
}
public static void main(String[] args) throws Exception {<FILL_FUNCTION_BODY>}
private static List<URI> expand(Iterable<URI> inputs) throws IOException {
List<URI> expanded = new ArrayList<>();
for (URI input : inputs) {
if (isFileOrDir(... |
DecoderConfig config = new DecoderConfig();
JCommander jCommander = new JCommander(config);
jCommander.parse(args);
jCommander.setProgramName(CommandLineRunner.class.getSimpleName());
if (config.help) {
jCommander.usage();
return;
}
List<URI> inputs = new ArrayList<>(config.inp... | 560 | 572 | 1,132 | <no_super_class> |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/DecoderConfig.java | DecoderConfig | buildHints | class DecoderConfig {
@Parameter(names = "--try_harder",
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")
boolean pureBarcode;
@Parameter(names = ... |
List<BarcodeFormat> finalPossibleFormats = possibleFormats;
if (finalPossibleFormats == null || finalPossibleFormats.isEmpty()) {
finalPossibleFormats = new ArrayList<>(Arrays.asList(
BarcodeFormat.UPC_A,
BarcodeFormat.UPC_E,
BarcodeFormat.EAN_13,
BarcodeFormat.EAN... | 556 | 435 | 991 | <no_super_class> |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/GUIRunner.java | GUIRunner | getDecodeText | class GUIRunner extends JFrame {
private final JLabel imageLabel;
private final JTextComponent textArea;
private GUIRunner() {
imageLabel = new JLabel();
textArea = new JTextArea();
textArea.setEditable(false);
textArea.setMaximumSize(new Dimension(400, 200));
Container panel = new JPanel();... |
BufferedImage image;
try {
image = ImageReader.readImage(file.toUri());
} catch (IOException ioe) {
return ioe.toString();
}
LuminanceSource source = new BufferedImageLuminanceSource(image);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result;
... | 487 | 148 | 635 | <methods>public void <init>() throws java.awt.HeadlessException,public void <init>(java.awt.GraphicsConfiguration) ,public void <init>(java.lang.String) throws java.awt.HeadlessException,public void <init>(java.lang.String, java.awt.GraphicsConfiguration) ,public javax.accessibility.AccessibleContext getAccessibleConte... |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/HtmlAssetTranslator.java | HtmlAssetTranslator | translateOneLanguage | class HtmlAssetTranslator {
private static final Pattern COMMA = Pattern.compile(",");
private HtmlAssetTranslator() {}
public static void main(String[] args) throws IOException {
if (args.length < 3) {
System.err.println("Usage: HtmlAssetTranslator android/assets/ " +
"(all|... |
Path targetHtmlDir = assetsDir.resolve("html-" + language);
Files.createDirectories(targetHtmlDir);
Path englishHtmlDir = assetsDir.resolve("html-en");
String translationTextTranslated =
StringsResourceTranslator.translateString("Translated by Google Translate.", language);
DirectoryStrea... | 1,588 | 201 | 1,789 | <no_super_class> |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/ImageReader.java | ImageReader | readImage | class ImageReader {
private static final String BASE64TOKEN = "base64,";
private ImageReader() {
}
public static BufferedImage readImage(URI uri) throws IOException {<FILL_FUNCTION_BODY>}
public static BufferedImage readDataURIImage(URI uri) throws IOException {
String uriString = uri.getSchemeSpe... |
if ("data".equals(uri.getScheme())) {
return readDataURIImage(uri);
}
BufferedImage result;
try {
result = ImageIO.read(uri.toURL());
} catch (IllegalArgumentException iae) {
throw new IOException("Resource not found: " + uri, iae);
}
if (result == null) {
throw new ... | 256 | 120 | 376 | <no_super_class> |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/MatrixToImageConfig.java | MatrixToImageConfig | getBufferedImageColorModel | class MatrixToImageConfig {
public static final int BLACK = 0xFF000000;
public static final int WHITE = 0xFFFFFFFF;
private final int onColor;
private final int offColor;
/**
* Creates a default config with on color {@link #BLACK} and off color {@link #WHITE}, generating normal
* black-on-white bar... |
if (onColor == BLACK && offColor == WHITE) {
// Use faster BINARY if colors match default
return BufferedImage.TYPE_BYTE_BINARY;
}
if (hasTransparency(onColor) || hasTransparency(offColor)) {
// Use ARGB representation if colors specify non-opaque alpha
return BufferedImage.TYPE_INT... | 332 | 129 | 461 | <no_super_class> |
zxing_zxing | zxing/javase/src/main/java/com/google/zxing/client/j2se/MatrixToImageWriter.java | MatrixToImageWriter | writeToStream | class MatrixToImageWriter {
private static final MatrixToImageConfig DEFAULT_CONFIG = new MatrixToImageConfig();
private MatrixToImageWriter() {}
/**
* Renders a {@link BitMatrix} as an image, where "false" bits are rendered
* as white, and "true" bits are rendered as black. Uses default configuration.
... |
BufferedImage image = toBufferedImage(matrix, config);
if (!ImageIO.write(image, format, stream)) {
throw new IOException("Could not write an image of format " + format);
}
| 1,307 | 56 | 1,363 | <no_super_class> |
zxing_zxing | zxing/zxingorg/src/main/java/com/google/zxing/web/ChartServlet.java | ChartServlet | doParseParameters | class ChartServlet extends HttpServlet {
private static final int MAX_DIMENSION = 4096;
private static final Collection<Charset> SUPPORTED_OUTPUT_ENCODINGS = ImmutableSet.<Charset>builder()
.add(StandardCharsets.UTF_8).add(StandardCharsets.ISO_8859_1).add(Charset.forName("Shift_JIS")).build();
@Override
... |
String chartType = request.getParameter("cht");
Preconditions.checkArgument(chartType == null || "qr".equals(chartType), "Bad type");
String widthXHeight = request.getParameter("chs");
Preconditions.checkNotNull(widthXHeight, "No size");
int xIndex = widthXHeight.indexOf('x');
Preconditions.c... | 932 | 565 | 1,497 | <no_super_class> |
zxing_zxing | zxing/zxingorg/src/main/java/com/google/zxing/web/DoSFilter.java | DoSFilter | init | class DoSFilter implements Filter {
private Timer timer;
private DoSTracker sourceAddrTracker;
@Override
public void init(FilterConfig filterConfig) {<FILL_FUNCTION_BODY>}
@Override
public void doFilter(ServletRequest request,
ServletResponse response,
Filter... |
int maxAccessPerTime = Integer.parseInt(filterConfig.getInitParameter("maxAccessPerTime"));
Preconditions.checkArgument(maxAccessPerTime > 0);
int accessTimeSec = Integer.parseInt(filterConfig.getInitParameter("accessTimeSec"));
Preconditions.checkArgument(accessTimeSec > 0);
long accessTimeMS = T... | 400 | 315 | 715 | <no_super_class> |
zxing_zxing | zxing/zxingorg/src/main/java/com/google/zxing/web/DoSTracker.java | TrackerTask | run | class TrackerTask extends TimerTask {
private final String name;
private final Double maxLoad;
private TrackerTask(String name, Double maxLoad) {
this.name = name;
this.maxLoad = maxLoad;
}
@Override
public void run() {<FILL_FUNCTION_BODY>}
} |
// largest count <= maxAccessesPerTime
int maxAllowedCount = 1;
// smallest count > maxAccessesPerTime
int minDisallowedCount = Integer.MAX_VALUE;
int localMAPT = maxAccessesPerTime;
int totalEntries;
int clearedEntries = 0;
synchronized (numRecentAccesses) {
tot... | 91 | 598 | 689 | <no_super_class> |
zxing_zxing | zxing/zxingorg/src/main/java/com/google/zxing/web/HTTPSFilter.java | HTTPSFilter | doFilter | class HTTPSFilter extends AbstractFilter {
private static final Pattern HTTP_REGEX = Pattern.compile("http://");
@Override
public void doFilter(ServletRequest servletRequest,
ServletResponse servletResponse,
FilterChain chain) throws IOException, ServletException {<... |
if (servletRequest.isSecure()) {
chain.doFilter(servletRequest, servletResponse);
} else {
HttpServletRequest request = (HttpServletRequest) servletRequest;
String url = request.getRequestURL().toString();
String target = HTTP_REGEX.matcher(url).replaceFirst("https://");
redirect(... | 86 | 99 | 185 | <methods>public final void destroy() ,public final void init(FilterConfig) <variables> |
zxing_zxing | zxing/zxingorg/src/main/java/com/google/zxing/web/OutputUtils.java | OutputUtils | arrayToString | class OutputUtils {
private static final int BYTES_PER_LINE = 16;
private static final int HALF_BYTES_PER_LINE = BYTES_PER_LINE / 2;
private OutputUtils() {
}
public static String arrayToString(byte[] bytes) {<FILL_FUNCTION_BODY>}
private static char hexChar(int value) {
return (char) (value < 10 ? ... |
StringBuilder result = new StringBuilder(bytes.length * 4);
int i = 0;
while (i < bytes.length) {
int value = bytes[i] & 0xFF;
result.append(hexChar(value / 16));
result.append(hexChar(value % 16));
i++;
if (i % BYTES_PER_LINE == 0) {
result.append('\n');
} else ... | 137 | 170 | 307 | <no_super_class> |
zxing_zxing | zxing/zxingorg/src/main/java/com/google/zxing/web/ServletContextLogHandler.java | ServletContextLogHandler | publish | class ServletContextLogHandler extends Handler {
private final ServletContext context;
ServletContextLogHandler(ServletContext context) {
this.context = context;
}
@Override
public void publish(LogRecord record) {<FILL_FUNCTION_BODY>}
@Override
public void flush() {
// do nothing
}
@Overr... |
Formatter formatter = getFormatter();
String message;
if (formatter == null) {
message = record.getMessage();
} else {
message = formatter.format(record);
}
Throwable throwable = record.getThrown();
if (throwable == null) {
context.log(message);
} else {
context.... | 117 | 107 | 224 | <methods>public abstract void close() throws java.lang.SecurityException,public abstract void flush() ,public java.lang.String getEncoding() ,public java.util.logging.ErrorManager getErrorManager() ,public java.util.logging.Filter getFilter() ,public java.util.logging.Formatter getFormatter() ,public java.util.logging.... |
zxing_zxing | zxing/zxingorg/src/main/java/com/google/zxing/web/TimeoutFilter.java | TimeoutFilter | doFilter | class TimeoutFilter implements Filter {
private ExecutorService executorService;
private TimeLimiter timeLimiter;
private int timeoutSec;
@Override
public void init(FilterConfig filterConfig) {
executorService = Executors.newCachedThreadPool();
timeLimiter = SimpleTimeLimiter.create(executorService)... |
try {
timeLimiter.callWithTimeout(new Callable<Void>() {
@Override
public Void call() throws Exception {
chain.doFilter(request, response);
return null;
}
}, timeoutSec, TimeUnit.SECONDS);
} catch (TimeoutException | InterruptedException e) {
HttpSe... | 203 | 227 | 430 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.