Replace tabs with spaces ( part of accepting another big patch); fix one failing test due to typo

git-svn-id: https://zxing.googlecode.com/svn/trunk@1326 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2010-05-02 06:49:18 +00:00
parent 1109e2aecf
commit 816d6b81e0
21 changed files with 303 additions and 325 deletions

View file

@ -137,7 +137,7 @@ public final class IntentIntegrator {
CharSequence stringButtonYes, CharSequence stringButtonYes,
CharSequence stringButtonNo) { CharSequence stringButtonNo) {
return initiateScan(activity, return initiateScan(activity,
stringTitle, stringTitle,
stringMessage, stringMessage,
stringButtonYes, stringButtonYes,
@ -171,8 +171,8 @@ public final class IntentIntegrator {
// check which types of codes to scan for // check which types of codes to scan for
if (stringDesiredBarcodeFormats != null) { if (stringDesiredBarcodeFormats != null) {
// set the desired barcode types // set the desired barcode types
intentScan.putExtra("SCAN_FORMATS", stringDesiredBarcodeFormats); intentScan.putExtra("SCAN_FORMATS", stringDesiredBarcodeFormats);
} }
try { try {

View file

@ -588,8 +588,8 @@ public final class CaptureActivity extends Activity implements SurfaceHolder.Cal
resultHandler.getDisplayContents().toString() + "&source=zxing"; resultHandler.getDisplayContents().toString() + "&source=zxing";
handler.sendMessageDelayed(message, INTENT_RESULT_DURATION); handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
} else if (source == Source.ZXING_LINK) { } else if (source == Source.ZXING_LINK) {
// Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate // Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
// with the scanned code. This allows both queries and REST-style URLs to work. // with the scanned code. This allows both queries and REST-style URLs to work.
Message message = Message.obtain(handler, R.id.launch_product_query); Message message = Message.obtain(handler, R.id.launch_product_query);
message.obj = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER, resultHandler.getDisplayContents().toString()); message.obj = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER, resultHandler.getDisplayContents().toString());
handler.sendMessageDelayed(message, INTENT_RESULT_DURATION); handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);

View file

@ -199,7 +199,7 @@ public final class SearchBookContentsActivity extends Activity {
for (int x = 0; x < count; x++) { for (int x = 0; x < count; x++) {
items.add(parseResult(results.getJSONObject(x))); items.add(parseResult(results.getJSONObject(x)));
} }
resultListView.setOnItemClickListener(new BrowseBookListener(this, items)); resultListView.setOnItemClickListener(new BrowseBookListener(this, items));
resultListView.setAdapter(new SearchBookContentsAdapter(this, items)); resultListView.setAdapter(new SearchBookContentsAdapter(this, items));
} else { } else {
String searchable = json.optString("searchable"); String searchable = json.optString("searchable");
@ -243,7 +243,7 @@ public final class SearchBookContentsActivity extends Activity {
return new SearchBookContentsResult(pageId, pageNumber, snippet, valid); return new SearchBookContentsResult(pageId, pageNumber, snippet, valid);
} catch (JSONException e) { } catch (JSONException e) {
// Never seen in the wild, just being complete. // Never seen in the wild, just being complete.
return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false); return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false);
} }
} }
@ -267,7 +267,7 @@ public final class SearchBookContentsActivity extends Activity {
// website, we don't use LocaleManager to change the TLD. // website, we don't use LocaleManager to change the TLD.
URI uri; URI uri;
if (isbn.startsWith("http://google.com/books?id=")) { if (isbn.startsWith("http://google.com/books?id=")) {
int equals = isbn.indexOf('='); int equals = isbn.indexOf('=');
String volumeId = isbn.substring(equals + 1); String volumeId = isbn.substring(equals + 1);
uri = new URI("http", null, "www.google.com", -1, "/books", "id=" + volumeId + uri = new URI("http", null, "www.google.com", -1, "/books", "id=" + volumeId +
"&jscmd=SearchWithinVolume2&q=" + query, null); "&jscmd=SearchWithinVolume2&q=" + query, null);

View file

@ -30,8 +30,10 @@ final class SearchBookContentsResult {
private final String snippet; private final String snippet;
private final boolean validSnippet; private final boolean validSnippet;
SearchBookContentsResult(String pageId, String pageNumber, String snippet, SearchBookContentsResult(String pageId,
boolean validSnippet) { String pageNumber,
String snippet,
boolean validSnippet) {
this.pageId = pageId; this.pageId = pageId;
this.pageNumber = pageNumber; this.pageNumber = pageNumber;
this.snippet = snippet; this.snippet = snippet;

View file

@ -65,7 +65,7 @@ public final class URIResultHandler extends ResultHandler {
shareBySMS(uri); shareBySMS(uri);
break; break;
case 3: case 3:
searchBookContents(uri); searchBookContents(uri);
break; break;
} }
} }

View file

@ -47,7 +47,7 @@ final class DecodedBitStreamParser {
private static final char[] C40_SHIFT2_SET_CHARS = { private static final char[] C40_SHIFT2_SET_CHARS = {
'!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.',
'/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_' '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '_'
}; };
/** /**
* See ISO 16022:2006, Annex C Table C.2 * See ISO 16022:2006, Annex C Table C.2
@ -122,54 +122,54 @@ final class DecodedBitStreamParser {
do { do {
int oneByte = bits.readBits(8); int oneByte = bits.readBits(8);
if (oneByte == 0) { if (oneByte == 0) {
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} else if (oneByte <= 128) { // ASCII data (ASCII value + 1) } else if (oneByte <= 128) { // ASCII data (ASCII value + 1)
oneByte = upperShift ? (oneByte + 128) : oneByte; oneByte = upperShift ? (oneByte + 128) : oneByte;
upperShift = false; upperShift = false;
result.append((char) (oneByte - 1)); result.append((char) (oneByte - 1));
return ASCII_ENCODE; return ASCII_ENCODE;
} else if (oneByte == 129) { // Pad } else if (oneByte == 129) { // Pad
return PAD_ENCODE; return PAD_ENCODE;
} else if (oneByte <= 229) { // 2-digit data 00-99 (Numeric Value + 130) } else if (oneByte <= 229) { // 2-digit data 00-99 (Numeric Value + 130)
int value = oneByte - 130; int value = oneByte - 130;
if (value < 10) { // padd with '0' for single digit values if (value < 10) { // padd with '0' for single digit values
result.append('0'); result.append('0');
} }
result.append(value); result.append(value);
} else if (oneByte == 230) { // Latch to C40 encodation } else if (oneByte == 230) { // Latch to C40 encodation
return C40_ENCODE; return C40_ENCODE;
} else if (oneByte == 231) { // Latch to Base 256 encodation } else if (oneByte == 231) { // Latch to Base 256 encodation
return BASE256_ENCODE; return BASE256_ENCODE;
} else if (oneByte == 232) { // FNC1 } else if (oneByte == 232) { // FNC1
//throw ReaderException.getInstance(); //throw ReaderException.getInstance();
// Ignore this symbol for now // Ignore this symbol for now
} else if (oneByte == 233) { // Structured Append } else if (oneByte == 233) { // Structured Append
//throw ReaderException.getInstance(); //throw ReaderException.getInstance();
// Ignore this symbol for now // Ignore this symbol for now
} else if (oneByte == 234) { // Reader Programming } else if (oneByte == 234) { // Reader Programming
//throw ReaderException.getInstance(); //throw ReaderException.getInstance();
// Ignore this symbol for now // Ignore this symbol for now
} else if (oneByte == 235) { // Upper Shift (shift to Extended ASCII) } else if (oneByte == 235) { // Upper Shift (shift to Extended ASCII)
upperShift = true; upperShift = true;
} else if (oneByte == 236) { // 05 Macro } else if (oneByte == 236) { // 05 Macro
result.append("[)>\u001E05\u001D"); result.append("[)>\u001E05\u001D");
resultTrailer.insert(0, "\u001E\u0004"); resultTrailer.insert(0, "\u001E\u0004");
} else if (oneByte == 237) { // 06 Macro } else if (oneByte == 237) { // 06 Macro
result.append("[)>\u001E06\u001D"); result.append("[)>\u001E06\u001D");
resultTrailer.insert(0, "\u001E\u0004"); resultTrailer.insert(0, "\u001E\u0004");
} else if (oneByte == 238) { // Latch to ANSI X12 encodation } else if (oneByte == 238) { // Latch to ANSI X12 encodation
return ANSIX12_ENCODE; return ANSIX12_ENCODE;
} else if (oneByte == 239) { // Latch to Text encodation } else if (oneByte == 239) { // Latch to Text encodation
return TEXT_ENCODE; return TEXT_ENCODE;
} else if (oneByte == 240) { // Latch to EDIFACT encodation } else if (oneByte == 240) { // Latch to EDIFACT encodation
return EDIFACT_ENCODE; return EDIFACT_ENCODE;
} else if (oneByte == 241) { // ECI Character } else if (oneByte == 241) { // ECI Character
// TODO(bbrown): I think we need to support ECI // TODO(bbrown): I think we need to support ECI
//throw ReaderException.getInstance(); //throw ReaderException.getInstance();
// Ignore this symbol for now // Ignore this symbol for now
} else if (oneByte >= 242) { // Not to be used in ASCII encodation } else if (oneByte >= 242) { // Not to be used in ASCII encodation
throw FormatException.getFormatInstance(); throw FormatException.getFormatInstance();
} }
} while (bits.available() > 0); } while (bits.available() > 0);
return ASCII_ENCODE; return ASCII_ENCODE;
} }

View file

@ -28,46 +28,46 @@ import com.google.zxing.common.BitMatrix;
*/ */
public final class Code128Writer extends UPCEANWriter { public final class Code128Writer extends UPCEANWriter {
public BitMatrix encode(String contents, public BitMatrix encode(String contents,
BarcodeFormat format, BarcodeFormat format,
int width, int width,
int height, int height,
Hashtable hints) throws WriterException { Hashtable hints) throws WriterException {
if (format != BarcodeFormat.CODE_128) { if (format != BarcodeFormat.CODE_128) {
throw new IllegalArgumentException("Can only encode CODE_128, but got " + format); throw new IllegalArgumentException("Can only encode CODE_128, but got " + format);
} }
return super.encode(contents, format, width, height, hints); return super.encode(contents, format, width, height, hints);
} }
public byte[] encode(String contents) { public byte[] encode(String contents) {
int length = contents.length(); int length = contents.length();
if (length > 80) { if (length > 80) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length); "Requested contents should be less than 80 digits long, but got " + length);
} }
int codeWidth = 11 + 11 + 13; //start plus check plus stop character int codeWidth = 11 + 11 + 13; //start plus check plus stop character
//get total code width for this barcode //get total code width for this barcode
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
int[] patterns = Code128Reader.CODE_PATTERNS[contents.charAt(i) - ' ']; int[] patterns = Code128Reader.CODE_PATTERNS[contents.charAt(i) - ' '];
for (int j = 0; j < patterns.length; j++) { for (int j = 0; j < patterns.length; j++) {
codeWidth += patterns[j]; codeWidth += patterns[j];
} }
} }
byte[] result = new byte[codeWidth]; byte[] result = new byte[codeWidth];
int pos = appendPattern(result, 0, Code128Reader.CODE_PATTERNS[104], 1); int pos = appendPattern(result, 0, Code128Reader.CODE_PATTERNS[104], 1);
int check = 104; int check = 104;
//append next character to bytematrix //append next character to bytematrix
for(int i = 0; i < length; i++) { for(int i = 0; i < length; i++) {
check += (contents.charAt(i) - ' ') * (i + 1); check += (contents.charAt(i) - ' ') * (i + 1);
pos += appendPattern(result, pos, Code128Reader.CODE_PATTERNS[contents.charAt(i) - ' '],1); pos += appendPattern(result, pos, Code128Reader.CODE_PATTERNS[contents.charAt(i) - ' '],1);
} }
//compute checksum and append it along with end character and quiet space //compute checksum and append it along with end character and quiet space
check %= 103; check %= 103;
pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[check],1); pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[check],1);
pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[106],1); pos += appendPattern(result,pos,Code128Reader.CODE_PATTERNS[106],1);
return result; return result;
} }
} }

View file

@ -28,52 +28,55 @@ import com.google.zxing.common.BitMatrix;
*/ */
public final class Code39Writer extends UPCEANWriter { public final class Code39Writer extends UPCEANWriter {
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, public BitMatrix encode(String contents,
Hashtable hints) throws WriterException { BarcodeFormat format,
if (format != BarcodeFormat.CODE_39) { int width,
throw new IllegalArgumentException("Can only encode CODE_39, but got " + format); int height,
} Hashtable hints) throws WriterException {
return super.encode(contents, format, width, height, hints); if (format != BarcodeFormat.CODE_39) {
} throw new IllegalArgumentException("Can only encode CODE_39, but got " + format);
}
return super.encode(contents, format, width, height, hints);
}
public byte[] encode(String contents) { public byte[] encode(String contents) {
int length = contents.length(); int length = contents.length();
if (length > 80) { if (length > 80) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length); "Requested contents should be less than 80 digits long, but got " + length);
} }
int[] widths = new int[9]; int[] widths = new int[9];
int codeWidth = 24 + 1 + length; int codeWidth = 24 + 1 + length;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i)); int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths); toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
for(int j = 0; j < widths.length; j++) { for(int j = 0; j < widths.length; j++) {
codeWidth += widths[j]; codeWidth += widths[j];
} }
} }
byte[] result = new byte[codeWidth]; byte[] result = new byte[codeWidth];
toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths); toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths);
int pos = appendPattern(result, 0, widths, 1); int pos = appendPattern(result, 0, widths, 1);
int[] narrowWhite = {1}; int[] narrowWhite = {1};
pos += appendPattern(result, pos, narrowWhite, 0);
//append next character to bytematrix
for(int i = length-1; i >= 0; i--) {
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i));
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths);
pos += appendPattern(result, pos, widths, 1);
pos += appendPattern(result, pos, narrowWhite, 0); pos += appendPattern(result, pos, narrowWhite, 0);
//append next character to bytematrix }
for(int i = length-1; i >= 0; i--) { toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths);
int indexInString = Code39Reader.ALPHABET_STRING.indexOf(contents.charAt(i)); pos += appendPattern(result, pos, widths, 1);
toIntArray(Code39Reader.CHARACTER_ENCODINGS[indexInString], widths); return result;
pos += appendPattern(result, pos, widths, 1); }
pos += appendPattern(result, pos, narrowWhite, 0);
}
toIntArray(Code39Reader.CHARACTER_ENCODINGS[39], widths);
pos += appendPattern(result, pos, widths, 1);
return result;
}
private static void toIntArray(int a, int[] toReturn) { private static void toIntArray(int a, int[] toReturn) {
for (int i = 0; i < 9; i++) { for (int i = 0; i < 9; i++) {
int temp = a & (1 << i); int temp = a & (1 << i);
toReturn[i] = (temp == 0) ? 1 : 2; toReturn[i] = (temp == 0) ? 1 : 2;
} }
} }
} }

View file

@ -340,9 +340,9 @@ public final class ITFReader extends OneDReader {
} }
if (bestMatch >= 0) { if (bestMatch >= 0) {
return bestMatch; return bestMatch;
} else { } else {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
} }
} }

View file

@ -28,37 +28,41 @@ import com.google.zxing.common.BitMatrix;
*/ */
public final class ITFWriter extends UPCEANWriter { public final class ITFWriter extends UPCEANWriter {
public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, public BitMatrix encode(String contents,
Hashtable hints) throws WriterException { BarcodeFormat format,
if (format != BarcodeFormat.ITF) { int width,
throw new IllegalArgumentException("Can only encode ITF, but got " + format); int height,
} Hashtable hints) throws WriterException {
if (format != BarcodeFormat.ITF) {
throw new IllegalArgumentException("Can only encode ITF, but got " + format);
}
return super.encode(contents, format, width, height, hints); return super.encode(contents, format, width, height, hints);
} }
public byte[] encode(String contents) { public byte[] encode(String contents) {
int length = contents.length(); int length = contents.length();
if (length > 80) { if (length > 80) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Requested contents should be less than 80 digits long, but got " + length); "Requested contents should be less than 80 digits long, but got " + length);
} }
byte[] result = new byte[9 + 9 * length]; byte[] result = new byte[9 + 9 * length];
int[] start = {1, 1, 1, 1}; int[] start = {1, 1, 1, 1};
int pos = appendPattern(result, 0, start, 1); int pos = appendPattern(result, 0, start, 1);
for (int i = 0; i < length; i += 2) { for (int i = 0; i < length; i += 2) {
int one = Character.digit(contents.charAt(i), 10); int one = Character.digit(contents.charAt(i), 10);
int two = Character.digit(contents.charAt(i+1), 10); int two = Character.digit(contents.charAt(i+1), 10);
int[] encoding = new int[18]; int[] encoding = new int[18];
for (int j = 0; j < 10; j += 2) { for (int j = 0; j < 10; j += 2) {
encoding[j] = ITFReader.PATTERNS[one][j]; encoding[j] = ITFReader.PATTERNS[one][j];
encoding[j + 1] = ITFReader.PATTERNS[two][j]; encoding[j + 1] = ITFReader.PATTERNS[two][j];
} }
pos += appendPattern(result, pos, encoding, 1); pos += appendPattern(result, pos, encoding, 1);
} }
int[] end = {3, 1, 1}; int[] end = {3, 1, 1};
pos += appendPattern(result, pos, end, 1); pos += appendPattern(result, pos, end, 1);
return result;
}
return result;
}
} }

View file

@ -446,7 +446,7 @@ final class DecodedBitStreamParser {
code == BEGIN_MACRO_PDF417_CONTROL_BLOCK || code == BEGIN_MACRO_PDF417_CONTROL_BLOCK ||
code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD || code == BEGIN_MACRO_PDF417_OPTIONAL_FIELD ||
code == MACRO_PDF417_TERMINATOR) { code == MACRO_PDF417_TERMINATOR) {
codeIndex--; codeIndex--;
end = true; end = true;
} }
} }

View file

@ -145,5 +145,6 @@ public final class Decoder {
} }
} }
return result; return result;
} }
} }

View file

@ -202,11 +202,11 @@ public final class ParsedReaderResultTestCase extends TestCase {
"DTEND:20080505\r\nEND:VEVENT", "foo\n20080504\n20080505", ParsedResultType.CALENDAR); "DTEND:20080505\r\nEND:VEVENT", "foo\n20080504\n20080505", ParsedResultType.CALENDAR);
// Start time only // Start time only
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT", doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT",
"foo\n20080504T123456Z", ParsedResultType.CALENDAR); "foo\n20080504T123456Z\n20080504T123456Z", ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT", doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT",
"foo\n20080504T123456", ParsedResultType.CALENDAR); "foo\n20080504T123456\n20080504T123456", ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT", doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT",
"foo\n20080504", ParsedResultType.CALENDAR); "foo\n20080504\n20080504", ParsedResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT",
"BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT); "BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", ParsedResultType.TEXT);
// Make sure illegal entries without newlines don't crash // Make sure illegal entries without newlines don't crash

View file

@ -136,33 +136,33 @@ public final class EncoderTestCase extends TestCase {
{ {
BitArray bits = new BitArray(); BitArray bits = new BitArray();
Encoder.appendLengthInfo(1, // 1 letter (1/1). Encoder.appendLengthInfo(1, // 1 letter (1/1).
1, // version 1. 1, // version 1.
Mode.NUMERIC, Mode.NUMERIC,
bits); bits);
assertEquals(" ........ .X", bits.toString()); // 10 bits. assertEquals(" ........ .X", bits.toString()); // 10 bits.
} }
{ {
BitArray bits = new BitArray(); BitArray bits = new BitArray();
Encoder.appendLengthInfo(2, // 2 letters (2/1). Encoder.appendLengthInfo(2, // 2 letters (2/1).
10, // version 10. 10, // version 10.
Mode.ALPHANUMERIC, Mode.ALPHANUMERIC,
bits); bits);
assertEquals(" ........ .X.", bits.toString()); // 11 bits. assertEquals(" ........ .X.", bits.toString()); // 11 bits.
} }
{ {
BitArray bits = new BitArray(); BitArray bits = new BitArray();
Encoder.appendLengthInfo(255, // 255 letter (255/1). Encoder.appendLengthInfo(255, // 255 letter (255/1).
27, // version 27. 27, // version 27.
Mode.BYTE, Mode.BYTE,
bits); bits);
assertEquals(" ........ XXXXXXXX", bits.toString()); // 16 bits. assertEquals(" ........ XXXXXXXX", bits.toString()); // 16 bits.
} }
{ {
BitArray bits = new BitArray(); BitArray bits = new BitArray();
Encoder.appendLengthInfo(512, // 512 letters (1024/2). Encoder.appendLengthInfo(512, // 512 letters (1024/2).
40, // version 40. 40, // version 40.
Mode.KANJI, Mode.KANJI,
bits); bits);
assertEquals(" ..X..... ....", bits.toString()); // 12 bits. assertEquals(" ..X..... ....", bits.toString()); // 12 bits.
} }
} }

View file

@ -54,27 +54,27 @@ public final class MatrixUtilTestCase extends TestCase {
{ {
// Version 1. // Version 1.
String expected = String expected =
" 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" +
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
" 1 \n" + " 1 \n" +
" 0 \n" + " 0 \n" +
" 1 \n" + " 1 \n" +
" 0 \n" + " 0 \n" +
" 1 \n" + " 1 \n" +
" 0 0 0 0 0 0 0 0 1 \n" + " 0 0 0 0 0 0 0 0 1 \n" +
" 1 1 1 1 1 1 1 0 \n" + " 1 1 1 1 1 1 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" + " 1 0 0 0 0 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" + " 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" + " 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" + " 1 0 1 1 1 0 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" + " 1 0 0 0 0 0 1 0 \n" +
" 1 1 1 1 1 1 1 0 \n"; " 1 1 1 1 1 1 1 0 \n";
ByteMatrix matrix = new ByteMatrix(21, 21); ByteMatrix matrix = new ByteMatrix(21, 21);
MatrixUtil.clearMatrix(matrix); MatrixUtil.clearMatrix(matrix);
MatrixUtil.embedBasicPatterns(1, matrix); MatrixUtil.embedBasicPatterns(1, matrix);
@ -84,31 +84,31 @@ public final class MatrixUtilTestCase extends TestCase {
// Version 2. Position adjustment pattern should apppear at right // Version 2. Position adjustment pattern should apppear at right
// bottom corner. // bottom corner.
String expected = String expected =
" 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" + " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" + " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" +
" 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" + " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" + " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" +
" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" + " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
" 1 \n" + " 1 \n" +
" 0 \n" + " 0 \n" +
" 1 \n" + " 1 \n" +
" 0 \n" + " 0 \n" +
" 1 \n" + " 1 \n" +
" 0 \n" + " 0 \n" +
" 1 \n" + " 1 \n" +
" 0 \n" + " 0 \n" +
" 1 1 1 1 1 1 \n" + " 1 1 1 1 1 1 \n" +
" 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" + " 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" +
" 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" + " 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" +
" 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" + " 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" +
" 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" + " 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" +
" 1 0 1 1 1 0 1 0 \n" + " 1 0 1 1 1 0 1 0 \n" +
" 1 0 1 1 1 0 1 0 \n" + " 1 0 1 1 1 0 1 0 \n" +
" 1 0 0 0 0 0 1 0 \n" + " 1 0 0 0 0 0 1 0 \n" +
" 1 1 1 1 1 1 1 0 \n"; " 1 1 1 1 1 1 1 0 \n";
ByteMatrix matrix = new ByteMatrix(25, 25); ByteMatrix matrix = new ByteMatrix(25, 25);
MatrixUtil.clearMatrix(matrix); MatrixUtil.clearMatrix(matrix);
MatrixUtil.embedBasicPatterns(2, matrix); MatrixUtil.embedBasicPatterns(2, matrix);
@ -235,18 +235,18 @@ public final class MatrixUtilTestCase extends TestCase {
" 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" + " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" +
" 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n"; " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n";
char[] bytes = {32, 65, 205, 69, 41, 220, 46, 128, 236, char[] bytes = {32, 65, 205, 69, 41, 220, 46, 128, 236,
42, 159, 74, 221, 244, 169, 239, 150, 138, 42, 159, 74, 221, 244, 169, 239, 150, 138,
70, 237, 85, 224, 96, 74, 219 , 61}; 70, 237, 85, 224, 96, 74, 219 , 61};
BitArray bits = new BitArray(); BitArray bits = new BitArray();
for (char c: bytes) { for (char c: bytes) {
bits.appendBits(c, 8); bits.appendBits(c, 8);
} }
ByteMatrix matrix = new ByteMatrix(21, 21); ByteMatrix matrix = new ByteMatrix(21, 21);
MatrixUtil.buildMatrix(bits, MatrixUtil.buildMatrix(bits,
ErrorCorrectionLevel.H, ErrorCorrectionLevel.H,
1, // Version 1 1, // Version 1
3, // Mask pattern 3 3, // Mask pattern 3
matrix); matrix);
} }
public void testFindMSBSet() { public void testFindMSBSet() {
@ -290,8 +290,7 @@ public final class MatrixUtilTestCase extends TestCase {
public void testMakeTypeInfoInfoBits() throws WriterException { public void testMakeTypeInfoInfoBits() throws WriterException {
// From Appendix C in JISX0510:2004 (p 65) // From Appendix C in JISX0510:2004 (p 65)
BitArray bits = new BitArray(); BitArray bits = new BitArray();
MatrixUtil.makeTypeInfoBits(ErrorCorrectionLevel.M, MatrixUtil.makeTypeInfoBits(ErrorCorrectionLevel.M, 5, bits);
5, bits);
assertEquals(" X......X X..XXX.", bits.toString()); assertEquals(" X......X X..XXX.", bits.toString());
} }
} }

View file

@ -83,55 +83,55 @@ public final class QRCodeTestCase extends TestCase {
{ {
QRCode qrCode = new QRCode(); QRCode qrCode = new QRCode();
String expected = String expected =
"<<\n" + "<<\n" +
" mode: null\n" + " mode: null\n" +
" ecLevel: null\n" + " ecLevel: null\n" +
" version: -1\n" + " version: -1\n" +
" matrixWidth: -1\n" + " matrixWidth: -1\n" +
" maskPattern: -1\n" + " maskPattern: -1\n" +
" numTotalBytes: -1\n" + " numTotalBytes: -1\n" +
" numDataBytes: -1\n" + " numDataBytes: -1\n" +
" numECBytes: -1\n" + " numECBytes: -1\n" +
" numRSBlocks: -1\n" + " numRSBlocks: -1\n" +
" matrix: null\n" + " matrix: null\n" +
">>\n"; ">>\n";
assertEquals(expected, qrCode.toString()); assertEquals(expected, qrCode.toString());
} }
{ {
String expected = String expected =
"<<\n" + "<<\n" +
" mode: BYTE\n" + " mode: BYTE\n" +
" ecLevel: H\n" + " ecLevel: H\n" +
" version: 1\n" + " version: 1\n" +
" matrixWidth: 21\n" + " matrixWidth: 21\n" +
" maskPattern: 3\n" + " maskPattern: 3\n" +
" numTotalBytes: 26\n" + " numTotalBytes: 26\n" +
" numDataBytes: 9\n" + " numDataBytes: 9\n" +
" numECBytes: 17\n" + " numECBytes: 17\n" +
" numRSBlocks: 1\n" + " numRSBlocks: 1\n" +
" matrix:\n" + " matrix:\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
" 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" + " 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n" +
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" + " 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n" +
">>\n"; ">>\n";
QRCode qrCode = new QRCode(); QRCode qrCode = new QRCode();
qrCode.setMode(Mode.BYTE); qrCode.setMode(Mode.BYTE);
qrCode.setECLevel(ErrorCorrectionLevel.H); qrCode.setECLevel(ErrorCorrectionLevel.H);

View file

@ -1,7 +1,7 @@
raise "ZXing requires JRuby" unless defined?(JRuby) raise "ZXing requires JRuby" unless defined?(JRuby)
require File.expand_path( File.dirname(__FILE__) + '/core.jar' ) # ZXing core classes require File.expand_path( File.dirname(__FILE__) + '/core.jar' ) # ZXing core classes
require File.expand_path( File.dirname(__FILE__) + '/javase.jar' ) # ZXing JavaSE classes require File.expand_path( File.dirname(__FILE__) + '/javase.jar' ) # ZXing JavaSE classes
require 'uri' require 'uri'

View file

@ -1,21 +1,16 @@
<module> <module>
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.user.User'/>
<!-- Inherit the default GWT style sheet. --> <!-- Inherit the default GWT style sheet. -->
<inherits name='com.google.gwt.user.theme.standard.Standard'/> <inherits name='com.google.gwt.user.theme.standard.Standard'/>
<!-- Other module inherits --> <!-- Other module inherits -->
<inherits name='com.google.gwt.widgetideas.WidgetIdeas' /> <inherits name='com.google.gwt.widgetideas.WidgetIdeas' />
<inherits name='com.google.gwt.libideas.LibIdeas' /> <inherits name='com.google.gwt.libideas.LibIdeas' />
<inherits name='com.google.gwt.maps.GoogleMaps' /> <inherits name='com.google.gwt.maps.GoogleMaps' />
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point class='com.google.zxing.web.generator.client.Generator'/> <entry-point class='com.google.zxing.web.generator.client.Generator'/>
<!-- Specify the application specific style sheet. --> <!-- Specify the application specific style sheet. -->
<stylesheet src='Generator.css' /> <stylesheet src='Generator.css' />
<stylesheet src='DatePickerDemo.css' /> <stylesheet src='DatePickerDemo.css' />
<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjEOGGB_IEuss4QYUzB6Z0BRlY4xXjGBjgubjQXCS8Djm2jdpYBQn9f8dHtxpg30ararqd3GCyq_T4A' /> <script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjEOGGB_IEuss4QYUzB6Z0BRlY4xXjGBjgubjQXCS8Djm2jdpYBQn9f8dHtxpg30ararqd3GCyq_T4A' />
</module> </module>

View file

@ -24,9 +24,7 @@ package com.google.zxing.web.generator.client;
* @author Yohann Coppel * @author Yohann Coppel
*/ */
public class GeneratorException extends Exception { public class GeneratorException extends Exception {
private static final long serialVersionUID = 1L; public GeneratorException(String message) {
super(message);
public GeneratorException(String message) { }
super(message);
}
} }

View file

@ -6,12 +6,10 @@ body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
font-size: 11px; font-size: 11px;
} }
#header { #header {
background-color: #dde3e9; background-color: #dde3e9;
border-bottom: 1px solid #f2f7fc; border-bottom: 1px solid #f2f7fc;
} }
#header h1 { #header h1 {
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
@ -19,23 +17,19 @@ body {
padding: 12px; padding: 12px;
border-bottom: 1px solid #c8d0d9; border-bottom: 1px solid #c8d0d9;
} }
#header span { #header span {
font-weight: normal; font-weight: normal;
color: #5e6b75; color: #5e6b75;
} }
#footer { #footer {
width: 100%; width: 100%;
text-align:center; text-align:center;
padding-top: 12px; padding-top: 12px;
} }
#footer a { #footer a {
text-decoration:none; text-decoration:none;
color: #5e6b75; color: #5e6b75;
} }
/****************************************/ /****************************************/
#mainpanel { #mainpanel {
width: 800px; width: 800px;
@ -43,7 +37,6 @@ body {
padding: 12px; padding: 12px;
font-size: 11px; font-size: 11px;
} }
#imageresult { #imageresult {
background-color: #dde3e9; background-color: #dde3e9;
height: 350px; height: 350px;
@ -56,7 +49,6 @@ body {
display: table; display: table;
#position: relative; #position: relative;
} }
#innerresult { #innerresult {
display: table-cell; display: table-cell;
vertical-align: middle; vertical-align: middle;
@ -64,20 +56,16 @@ body {
#position: absolute; #position: absolute;
#top: 50%; #top: 50%;
} }
#innerresult img { #innerresult img {
#position: relative; #position: relative;
#top: -50%; #top: -50%;
} }
#downloadText { #downloadText {
font-size: 11px; font-size: 11px;
} }
#urlresult { #urlresult {
width: 350px; width: 350px;
} }
.firstColumn { .firstColumn {
width: 100px; width: 100px;
text-align: right; text-align: right;
@ -87,14 +75,12 @@ body {
font-weight: bold; font-weight: bold;
font-size: 11px; font-size: 11px;
} }
.secondColumn { .secondColumn {
width: 270px; width: 270px;
font-size: 11px; font-size: 11px;
color: #5e6b75; color: #5e6b75;
font-weight: bold; font-weight: bold;
} }
/*.inputfield,*/ /*.inputfield,*/
.gwt-TextBox, .gwt-TextBox,
.gwt-TextArea { .gwt-TextArea {
@ -106,19 +92,15 @@ body {
color: #000; color: #000;
font-weight: normal; font-weight: normal;
} }
/*.inputfield:focus,*/ /*.inputfield:focus,*/
.gwt-TextBox:focus { .gwt-TextBox:focus {
background-color: #fffbcc; background-color: #fffbcc;
} }
.required { .required {
background: #ffffff url(required-field-bg.png) repeat-y; background: #ffffff url(required-field-bg.png) repeat-y;
} }
.errorMessage { .errorMessage {
padding-left: 110px; padding-left: 110px;
font-size: 11px; font-size: 11px;
color: red; color: red;
} }

View file

@ -1,40 +1,34 @@
/** CSS by Wain. */ /** CSS by Wain. */
body { body {
background-color: #e9eef3; background-color: #e9eef3;
margin: 0; margin: 0;
padding: 0; padding: 0;
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
font-size: 12px; font-size: 12px;
} }
td { td {
font-size: 14px; font-size: 14px;
} }
#header { #header {
background-color: #dde3e9; background-color: #dde3e9;
border-bottom: 1px solid #f2f7fc; border-bottom: 1px solid #f2f7fc;
} }
#header h1 { #header h1 {
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
margin: 0; margin: 0;
padding: 12px; padding: 12px;
border-bottom: 1px solid #c8d0d9; border-bottom: 1px solid #c8d0d9;
} }
#header span { #header span {
font-weight: normal; font-weight: normal;
color: #5e6b75; color: #5e6b75;
} }
#footer { #footer {
width: 100%; width: 100%;
text-align:center; text-align:center;
padding-top: 12px; padding-top: 12px;
} }
#footer a { #footer a {
text-decoration:none; text-decoration:none;
color: #5e6b75; color: #5e6b75;