move all Result to RXingResult

This commit is contained in:
Henry Schimke
2022-08-20 12:12:30 -05:00
parent 9f72478dc8
commit 90ace738b7
149 changed files with 1658 additions and 1658 deletions

View File

@@ -18,11 +18,11 @@ package com.google.zxing.aztec.decoder;
import com.google.zxing.aztec.encoder.EncoderTest; import com.google.zxing.aztec.encoder.EncoderTest;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.aztec.AztecDetectorResult; import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import org.junit.Test; import org.junit.Test;
import org.junit.Assert; import org.junit.Assert;
@@ -31,7 +31,7 @@ import org.junit.Assert;
*/ */
public final class DecoderTest extends Assert { public final class DecoderTest extends Assert {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
@Test @Test
public void testHighLevelDecode() throws FormatException { public void testHighLevelDecode() throws FormatException {
@@ -64,7 +64,7 @@ public final class DecoderTest extends Assert {
} }
@Test @Test
public void testAztecResult() throws FormatException { public void testAztecRXingResult() throws FormatException {
BitMatrix matrix = BitMatrix.parse( BitMatrix matrix = BitMatrix.parse(
"X X X X X X X X X X X X X X \n" + "X X X X X X X X X X X X X X \n" +
"X X X X X X X X X X X X X X X \n" + "X X X X X X X X X X X X X X X \n" +
@@ -90,8 +90,8 @@ public final class DecoderTest extends Assert {
"X X X X X X X X X X X X X X \n" + "X X X X X X X X X X X X X X \n" +
" X X X X X X X X X X X X X \n", " X X X X X X X X X X X X X \n",
"X ", " "); "X ", " ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, false, 30, 2); AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, false, 30, 2);
DecoderResult result = new Decoder().decode(r); DecoderRXingResult result = new Decoder().decode(r);
assertEquals("88888TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", result.getText()); assertEquals("88888TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT", result.getText());
assertArrayEquals( assertArrayEquals(
new byte[] {-11, 85, 85, 117, 107, 90, -42, -75, -83, 107, new byte[] {-11, 85, 85, 117, 107, 90, -42, -75, -83, 107,
@@ -102,7 +102,7 @@ public final class DecoderTest extends Assert {
} }
@Test @Test
public void testAztecResultECI() throws FormatException { public void testAztecRXingResultECI() throws FormatException {
BitMatrix matrix = BitMatrix.parse( BitMatrix matrix = BitMatrix.parse(
" X X X X X X \n" + " X X X X X X \n" +
" X X X X X X X X X X X X \n" + " X X X X X X X X X X X X \n" +
@@ -124,8 +124,8 @@ public final class DecoderTest extends Assert {
" X X X X X X X X X X X \n" + " X X X X X X X X X X X \n" +
"X X X X X X X X \n", "X X X X X X X X \n",
"X ", " "); "X ", " ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, false, 15, 1); AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, false, 15, 1);
DecoderResult result = new Decoder().decode(r); DecoderRXingResult result = new Decoder().decode(r);
assertEquals("Français", result.getText()); assertEquals("Français", result.getText());
} }
@@ -160,7 +160,7 @@ public final class DecoderTest extends Assert {
+ "X X X X . . . X . . X X X . X X . . X . . . . X X X . \n" + "X X X X . . . X . . X X X . X X . . X . . . . X X X . \n"
+ "X X . X . X . . . X . X . . . . X X . X . . X X . . . \n", + "X X . X . X . . . X . X . . . . X X . X . . X X . . . \n",
"X ", ". "); "X ", ". ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, true, 16, 4); AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, true, 16, 4);
new Decoder().decode(r); new Decoder().decode(r);
} }
@@ -195,7 +195,7 @@ public final class DecoderTest extends Assert {
+ ". X X X X . . X . . X X X . X X . . X . . . . X X X . \n" + ". X X X X . . X . . X X X . X X . . X . . . . X X X . \n"
+ "X X . . . X X . . X . X . . . . X X . X . . X . X . X \n", + "X X . . . X X . . X . X . . . . X X . X . . X . X . X \n",
"X ", ". "); "X ", ". ");
AztecDetectorResult r = new AztecDetectorResult(matrix, NO_POINTS, true, 16, 4); AztecDetectorRXingResult r = new AztecDetectorRXingResult(matrix, NO_POINTS, true, 16, 4);
new Decoder().decode(r); new Decoder().decode(r);
} }

View File

@@ -17,13 +17,13 @@
package com.google.zxing.aztec.detector; package com.google.zxing.aztec.detector;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.aztec.AztecDetectorResult; import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.aztec.decoder.Decoder; import com.google.zxing.aztec.decoder.Decoder;
import com.google.zxing.aztec.detector.Detector.Point; import com.google.zxing.aztec.detector.Detector.Point;
import com.google.zxing.aztec.encoder.AztecCode; import com.google.zxing.aztec.encoder.AztecCode;
import com.google.zxing.aztec.encoder.Encoder; import com.google.zxing.aztec.encoder.Encoder;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@@ -78,11 +78,11 @@ public final class DetectorTest extends Assert {
copy.flip(orientationPoints.get(error2).getX(), orientationPoints.get(error2).getY()); copy.flip(orientationPoints.get(error2).getX(), orientationPoints.get(error2).getY());
} }
// The detector doesn't seem to work when matrix bits are only 1x1. So magnify. // The detector doesn't seem to work when matrix bits are only 1x1. So magnify.
AztecDetectorResult r = new Detector(makeLarger(copy, 3)).detect(isMirror); AztecDetectorRXingResult r = new Detector(makeLarger(copy, 3)).detect(isMirror);
assertNotNull(r); assertNotNull(r);
assertEquals(r.getNbLayers(), layers); assertEquals(r.getNbLayers(), layers);
assertEquals(r.isCompact(), compact); assertEquals(r.isCompact(), compact);
DecoderResult res = new Decoder().decode(r); DecoderRXingResult res = new Decoder().decode(r);
assertEquals(data, res.getText()); assertEquals(data, res.getText());
} }
} }

View File

@@ -19,13 +19,13 @@ package com.google.zxing.aztec.encoder;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.aztec.AztecDetectorResult; import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.aztec.AztecWriter; import com.google.zxing.aztec.AztecWriter;
import com.google.zxing.aztec.decoder.Decoder; import com.google.zxing.aztec.decoder.Decoder;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@@ -52,7 +52,7 @@ public final class EncoderTest extends Assert {
private static final Pattern DOTX = Pattern.compile("[^.X]"); private static final Pattern DOTX = Pattern.compile("[^.X]");
private static final Pattern SPACES = Pattern.compile("\\s+"); private static final Pattern SPACES = Pattern.compile("\\s+");
private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
// real life tests // real life tests
@@ -492,9 +492,9 @@ public final class EncoderTest extends Assert {
assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact()); assertEquals("Unexpected symbol format (compact)", compact, aztec.isCompact());
assertEquals("Unexpected nr. of layers", layers, aztec.getLayers()); assertEquals("Unexpected nr. of layers", layers, aztec.getLayers());
BitMatrix matrix = aztec.getMatrix(); BitMatrix matrix = aztec.getMatrix();
AztecDetectorResult r = AztecDetectorRXingResult r =
new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
DecoderResult res = new Decoder().decode(r); DecoderRXingResult res = new Decoder().decode(r);
assertEquals(data, res.getText()); assertEquals(data, res.getText());
// Check error correction by introducing a few minor errors // Check error correction by introducing a few minor errors
Random random = getPseudoRandom(); Random random = getPseudoRandom();
@@ -502,7 +502,7 @@ public final class EncoderTest extends Assert {
matrix.flip(random.nextInt(matrix.getWidth()), matrix.getHeight() - 2 + random.nextInt(2)); matrix.flip(random.nextInt(matrix.getWidth()), matrix.getHeight() - 2 + random.nextInt(2));
matrix.flip(random.nextInt(2), random.nextInt(matrix.getHeight())); matrix.flip(random.nextInt(2), random.nextInt(matrix.getHeight()));
matrix.flip(matrix.getWidth() - 2 + random.nextInt(2), random.nextInt(matrix.getHeight())); matrix.flip(matrix.getWidth() - 2 + random.nextInt(2), random.nextInt(matrix.getHeight()));
r = new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); r = new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
res = new Decoder().decode(r); res = new Decoder().decode(r);
assertEquals(data, res.getText()); assertEquals(data, res.getText());
} }
@@ -526,9 +526,9 @@ public final class EncoderTest extends Assert {
assertEquals("Unexpected nr. of layers", layers, aztec.getLayers()); assertEquals("Unexpected nr. of layers", layers, aztec.getLayers());
BitMatrix matrix2 = aztec.getMatrix(); BitMatrix matrix2 = aztec.getMatrix();
assertEquals(matrix, matrix2); assertEquals(matrix, matrix2);
AztecDetectorResult r = AztecDetectorRXingResult r =
new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
DecoderResult res = new Decoder().decode(r); DecoderRXingResult res = new Decoder().decode(r);
assertEquals(data, res.getText()); assertEquals(data, res.getText());
// Check error correction by introducing up to eccPercent/2 errors // Check error correction by introducing up to eccPercent/2 errors
int ecWords = aztec.getCodeWords() * eccPercent / 100 / 2; int ecWords = aztec.getCodeWords() * eccPercent / 100 / 2;
@@ -543,7 +543,7 @@ public final class EncoderTest extends Assert {
: matrix.getHeight() - 1 - random.nextInt(aztec.getLayers() * 2); : matrix.getHeight() - 1 - random.nextInt(aztec.getLayers() * 2);
matrix.flip(x, y); matrix.flip(x, y);
} }
r = new AztecDetectorResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers()); r = new AztecDetectorRXingResult(matrix, NO_POINTS, aztec.isCompact(), aztec.getCodeWords(), aztec.getLayers());
res = new Decoder().decode(r); res = new Decoder().decode(r);
assertEquals(data, res.getText()); assertEquals(data, res.getText());
} }

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link AddressBookParsedResult}. * Tests {@link AddressBookParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class AddressBookParsedResultTestCase extends Assert { public final class AddressBookParsedRXingResultTestCase extends Assert {
@Test @Test
public void testAddressBookDocomo() { public void testAddressBookDocomo() {
@@ -149,21 +149,21 @@ public final class AddressBookParsedResultTestCase extends Assert {
String[] urls, String[] urls,
String birthday, String birthday,
String note) { String note) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.ADDRESSBOOK, result.getType()); assertSame(ParsedRXingResultType.ADDRESSBOOK, result.getType());
AddressBookParsedResult addressResult = (AddressBookParsedResult) result; AddressBookParsedRXingResult addressRXingResult = (AddressBookParsedRXingResult) result;
assertEquals(title, addressResult.getTitle()); assertEquals(title, addressRXingResult.getTitle());
assertArrayEquals(names, addressResult.getNames()); assertArrayEquals(names, addressRXingResult.getNames());
assertEquals(pronunciation, addressResult.getPronunciation()); assertEquals(pronunciation, addressRXingResult.getPronunciation());
assertArrayEquals(addresses, addressResult.getAddresses()); assertArrayEquals(addresses, addressRXingResult.getAddresses());
assertArrayEquals(emails, addressResult.getEmails()); assertArrayEquals(emails, addressRXingResult.getEmails());
assertArrayEquals(phoneNumbers, addressResult.getPhoneNumbers()); assertArrayEquals(phoneNumbers, addressRXingResult.getPhoneNumbers());
assertArrayEquals(phoneTypes, addressResult.getPhoneTypes()); assertArrayEquals(phoneTypes, addressRXingResult.getPhoneTypes());
assertEquals(org, addressResult.getOrg()); assertEquals(org, addressRXingResult.getOrg());
assertArrayEquals(urls, addressResult.getURLs()); assertArrayEquals(urls, addressRXingResult.getURLs());
assertEquals(birthday, addressResult.getBirthday()); assertEquals(birthday, addressRXingResult.getBirthday());
assertEquals(note, addressResult.getNote()); assertEquals(note, addressRXingResult.getNote());
} }
} }

View File

@@ -17,7 +17,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -28,11 +28,11 @@ import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
/** /**
* Tests {@link CalendarParsedResult}. * Tests {@link CalendarParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class CalendarParsedResultTestCase extends Assert { public final class CalendarParsedRXingResultTestCase extends Assert {
private static final double EPSILON = 1.0E-10; private static final double EPSILON = 1.0E-10;
@@ -142,11 +142,11 @@ public final class CalendarParsedResultTestCase extends Assert {
@Test @Test
public void testBadGeo() { public void testBadGeo() {
// Not parsed as VEVENT // Not parsed as VEVENT
Result fakeResult = new Result("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" + RXingResult fakeRXingResult = new RXingResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\n" +
"GEO:-12.345\r\n" + "GEO:-12.345\r\n" +
"END:VEVENT\r\nEND:VCALENDAR", null, null, BarcodeFormat.QR_CODE); "END:VEVENT\r\nEND:VCALENDAR", null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.TEXT, result.getType()); assertSame(ParsedRXingResultType.TEXT, result.getType());
} }
@Test @Test
@@ -223,20 +223,20 @@ public final class CalendarParsedResultTestCase extends Assert {
String[] attendees, String[] attendees,
double latitude, double latitude,
double longitude) { double longitude) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.CALENDAR, result.getType()); assertSame(ParsedRXingResultType.CALENDAR, result.getType());
CalendarParsedResult calResult = (CalendarParsedResult) result; CalendarParsedRXingResult calRXingResult = (CalendarParsedRXingResult) result;
assertEquals(description, calResult.getDescription()); assertEquals(description, calRXingResult.getDescription());
assertEquals(summary, calResult.getSummary()); assertEquals(summary, calRXingResult.getSummary());
assertEquals(location, calResult.getLocation()); assertEquals(location, calRXingResult.getLocation());
DateFormat dateFormat = makeGMTFormat(); DateFormat dateFormat = makeGMTFormat();
assertEquals(startString, dateFormat.format(calResult.getStartTimestamp())); assertEquals(startString, dateFormat.format(calRXingResult.getStartTimestamp()));
assertEquals(endString, calResult.getEndTimestamp() < 0L ? null : dateFormat.format(calResult.getEndTimestamp())); assertEquals(endString, calRXingResult.getEndTimestamp() < 0L ? null : dateFormat.format(calRXingResult.getEndTimestamp()));
assertEquals(organizer, calResult.getOrganizer()); assertEquals(organizer, calRXingResult.getOrganizer());
assertArrayEquals(attendees, calResult.getAttendees()); assertArrayEquals(attendees, calRXingResult.getAttendees());
assertEqualOrNaN(latitude, calResult.getLatitude()); assertEqualOrNaN(latitude, calRXingResult.getLatitude());
assertEqualOrNaN(longitude, calResult.getLongitude()); assertEqualOrNaN(longitude, calRXingResult.getLongitude());
} }
private static void assertEqualOrNaN(double expected, double actual) { private static void assertEqualOrNaN(double expected, double actual) {

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link EmailAddressParsedResult}. * Tests {@link EmailAddressParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class EmailAddressParsedResultTestCase extends Assert { public final class EmailAddressParsedRXingResultTestCase extends Assert {
@Test @Test
public void testEmailAddress() { public void testEmailAddress() {
@@ -107,15 +107,15 @@ public final class EmailAddressParsedResultTestCase extends Assert {
String[] bccs, String[] bccs,
String subject, String subject,
String body) { String body) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.EMAIL_ADDRESS, result.getType()); assertSame(ParsedRXingResultType.EMAIL_ADDRESS, result.getType());
EmailAddressParsedResult emailResult = (EmailAddressParsedResult) result; EmailAddressParsedRXingResult emailRXingResult = (EmailAddressParsedRXingResult) result;
assertArrayEquals(tos, emailResult.getTos()); assertArrayEquals(tos, emailRXingResult.getTos());
assertArrayEquals(ccs, emailResult.getCCs()); assertArrayEquals(ccs, emailRXingResult.getCCs());
assertArrayEquals(bccs, emailResult.getBCCs()); assertArrayEquals(bccs, emailRXingResult.getBCCs());
assertEquals(subject, emailResult.getSubject()); assertEquals(subject, emailRXingResult.getSubject());
assertEquals(body, emailResult.getBody()); assertEquals(body, emailRXingResult.getBody());
} }
} }

View File

@@ -27,7 +27,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@@ -38,15 +38,15 @@ import java.util.Map;
* @author Antonio Manuel Benjumea Conde, Servinform, S.A. * @author Antonio Manuel Benjumea Conde, Servinform, S.A.
* @author Agustín Delgado, Servinform, S.A. * @author Agustín Delgado, Servinform, S.A.
*/ */
public final class ExpandedProductParsedResultTestCase extends Assert { public final class ExpandedProductParsedRXingResultTestCase extends Assert {
@Test @Test
public void testRSSExpanded() { public void testRSSExpanded() {
Map<String,String> uncommonAIs = new HashMap<>(); Map<String,String> uncommonAIs = new HashMap<>();
uncommonAIs.put("123", "544654"); uncommonAIs.put("123", "544654");
Result result = RXingResult result =
new Result("(01)66546(13)001205(3932)4455(3102)6544(123)544654", null, null, BarcodeFormat.RSS_EXPANDED); new RXingResult("(01)66546(13)001205(3932)4455(3102)6544(123)544654", null, null, BarcodeFormat.RSS_EXPANDED);
ExpandedProductParsedResult o = new ExpandedProductResultParser().parse(result); ExpandedProductParsedRXingResult o = new ExpandedProductRXingResultParser().parse(result);
assertNotNull(o); assertNotNull(o);
assertEquals("66546", o.getProductID()); assertEquals("66546", o.getProductID());
assertNull(o.getSscc()); assertNull(o.getSscc());

View File

@@ -19,16 +19,16 @@ package com.google.zxing.client.result;
import java.util.Locale; import java.util.Locale;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link GeoParsedResult}. * Tests {@link GeoParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class GeoParsedResultTestCase extends Assert { public final class GeoParsedRXingResultTestCase extends Assert {
private static final double EPSILON = 1.0E-10; private static final double EPSILON = 1.0E-10;
@@ -47,15 +47,15 @@ public final class GeoParsedResultTestCase extends Assert {
double altitude, double altitude,
String query, String query,
String uri) { String uri) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.GEO, result.getType()); assertSame(ParsedRXingResultType.GEO, result.getType());
GeoParsedResult geoResult = (GeoParsedResult) result; GeoParsedRXingResult geoRXingResult = (GeoParsedRXingResult) result;
assertEquals(latitude, geoResult.getLatitude(), EPSILON); assertEquals(latitude, geoRXingResult.getLatitude(), EPSILON);
assertEquals(longitude, geoResult.getLongitude(), EPSILON); assertEquals(longitude, geoRXingResult.getLongitude(), EPSILON);
assertEquals(altitude, geoResult.getAltitude(), EPSILON); assertEquals(altitude, geoRXingResult.getAltitude(), EPSILON);
assertEquals(query, geoResult.getQuery()); assertEquals(query, geoRXingResult.getQuery());
assertEquals(uri == null ? contents.toLowerCase(Locale.ENGLISH) : uri, geoResult.getGeoURI()); assertEquals(uri == null ? contents.toLowerCase(Locale.ENGLISH) : uri, geoRXingResult.getGeoURI());
} }
} }

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link ISBNParsedResult}. * Tests {@link ISBNParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class ISBNParsedResultTestCase extends Assert { public final class ISBNParsedRXingResultTestCase extends Assert {
@Test @Test
public void testISBN() { public void testISBN() {
@@ -34,11 +34,11 @@ public final class ISBNParsedResultTestCase extends Assert {
} }
private static void doTest(String contents) { private static void doTest(String contents) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.EAN_13); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.EAN_13);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.ISBN, result.getType()); assertSame(ParsedRXingResultType.ISBN, result.getType());
ISBNParsedResult isbnResult = (ISBNParsedResult) result; ISBNParsedRXingResult isbnRXingResult = (ISBNParsedRXingResult) result;
assertEquals(contents, isbnResult.getISBN()); assertEquals(contents, isbnRXingResult.getISBN());
} }
} }

View File

@@ -17,7 +17,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -28,12 +28,12 @@ import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
/** /**
* Tests {@link ParsedResult}. * Tests {@link ParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin) * @author dswitkin@google.com (Daniel Switkin)
*/ */
public final class ParsedReaderResultTestCase extends Assert { public final class ParsedReaderRXingResultTestCase extends Assert {
@Before @Before
public void setUp() { public void setUp() {
@@ -43,208 +43,208 @@ public final class ParsedReaderResultTestCase extends Assert {
@Test @Test
public void testTextType() { public void testTextType() {
doTestResult("", "", ParsedResultType.TEXT); doTestRXingResult("", "", ParsedRXingResultType.TEXT);
doTestResult("foo", "foo", ParsedResultType.TEXT); doTestRXingResult("foo", "foo", ParsedRXingResultType.TEXT);
doTestResult("Hi.", "Hi.", ParsedResultType.TEXT); doTestRXingResult("Hi.", "Hi.", ParsedRXingResultType.TEXT);
doTestResult("This is a test", "This is a test", ParsedResultType.TEXT); doTestRXingResult("This is a test", "This is a test", ParsedRXingResultType.TEXT);
doTestResult("This is a test\nwith newlines", "This is a test\nwith newlines", doTestRXingResult("This is a test\nwith newlines", "This is a test\nwith newlines",
ParsedResultType.TEXT); ParsedRXingResultType.TEXT);
doTestResult("This: a test with lots of @ nearly-random punctuation! No? OK then.", doTestRXingResult("This: a test with lots of @ nearly-random punctuation! No? OK then.",
"This: a test with lots of @ nearly-random punctuation! No? OK then.", "This: a test with lots of @ nearly-random punctuation! No? OK then.",
ParsedResultType.TEXT); ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testBookmarkType() { public void testBookmarkType() {
doTestResult("MEBKM:URL:google.com;;", "http://google.com", ParsedResultType.URI); doTestRXingResult("MEBKM:URL:google.com;;", "http://google.com", ParsedRXingResultType.URI);
doTestResult("MEBKM:URL:google.com;TITLE:Google;;", "Google\nhttp://google.com", doTestRXingResult("MEBKM:URL:google.com;TITLE:Google;;", "Google\nhttp://google.com",
ParsedResultType.URI); ParsedRXingResultType.URI);
doTestResult("MEBKM:TITLE:Google;URL:google.com;;", "Google\nhttp://google.com", doTestRXingResult("MEBKM:TITLE:Google;URL:google.com;;", "Google\nhttp://google.com",
ParsedResultType.URI); ParsedRXingResultType.URI);
doTestResult("MEBKM:URL:http://google.com;;", "http://google.com", ParsedResultType.URI); doTestRXingResult("MEBKM:URL:http://google.com;;", "http://google.com", ParsedRXingResultType.URI);
doTestResult("MEBKM:URL:HTTPS://google.com;;", "HTTPS://google.com", ParsedResultType.URI); doTestRXingResult("MEBKM:URL:HTTPS://google.com;;", "HTTPS://google.com", ParsedRXingResultType.URI);
} }
@Test @Test
public void testURLTOType() { public void testURLTOType() {
doTestResult("urlto:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI); doTestRXingResult("urlto:foo:bar.com", "foo\nhttp://bar.com", ParsedRXingResultType.URI);
doTestResult("URLTO:foo:bar.com", "foo\nhttp://bar.com", ParsedResultType.URI); doTestRXingResult("URLTO:foo:bar.com", "foo\nhttp://bar.com", ParsedRXingResultType.URI);
doTestResult("URLTO::bar.com", "http://bar.com", ParsedResultType.URI); doTestRXingResult("URLTO::bar.com", "http://bar.com", ParsedRXingResultType.URI);
doTestResult("URLTO::http://bar.com", "http://bar.com", ParsedResultType.URI); doTestRXingResult("URLTO::http://bar.com", "http://bar.com", ParsedRXingResultType.URI);
} }
@Test @Test
public void testEmailType() { public void testEmailType() {
doTestResult("MATMSG:TO:srowen@example.org;;", doTestRXingResult("MATMSG:TO:srowen@example.org;;",
"srowen@example.org", ParsedResultType.EMAIL_ADDRESS); "srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("MATMSG:TO:srowen@example.org;SUB:Stuff;;", "srowen@example.org\nStuff", doTestRXingResult("MATMSG:TO:srowen@example.org;SUB:Stuff;;", "srowen@example.org\nStuff",
ParsedResultType.EMAIL_ADDRESS); ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", doTestRXingResult("MATMSG:TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;",
"srowen@example.org\nStuff\nThis is some text", ParsedResultType.EMAIL_ADDRESS); "srowen@example.org\nStuff\nThis is some text", ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("MATMSG:SUB:Stuff;BODY:This is some text;TO:srowen@example.org;;", doTestRXingResult("MATMSG:SUB:Stuff;BODY:This is some text;TO:srowen@example.org;;",
"srowen@example.org\nStuff\nThis is some text", ParsedResultType.EMAIL_ADDRESS); "srowen@example.org\nStuff\nThis is some text", ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", doTestRXingResult("TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;",
"TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", ParsedResultType.TEXT); "TO:srowen@example.org;SUB:Stuff;BODY:This is some text;;", ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testEmailAddressType() { public void testEmailAddressType() {
doTestResult("srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS); doTestRXingResult("srowen@example.org", "srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("mailto:srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS); doTestRXingResult("mailto:srowen@example.org", "srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("MAILTO:srowen@example.org", "srowen@example.org", ParsedResultType.EMAIL_ADDRESS); doTestRXingResult("MAILTO:srowen@example.org", "srowen@example.org", ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("srowen@example", "srowen@example", ParsedResultType.EMAIL_ADDRESS); doTestRXingResult("srowen@example", "srowen@example", ParsedRXingResultType.EMAIL_ADDRESS);
doTestResult("srowen", "srowen", ParsedResultType.TEXT); doTestRXingResult("srowen", "srowen", ParsedRXingResultType.TEXT);
doTestResult("Let's meet @ 2", "Let's meet @ 2", ParsedResultType.TEXT); doTestRXingResult("Let's meet @ 2", "Let's meet @ 2", ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testAddressBookType() { public void testAddressBookType() {
doTestResult("MECARD:N:Sean Owen;;", "Sean Owen", ParsedResultType.ADDRESSBOOK); doTestRXingResult("MECARD:N:Sean Owen;;", "Sean Owen", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;;", "Sean Owen\n+12125551212", doTestRXingResult("MECARD:TEL:+12125551212;N:Sean Owen;;", "Sean Owen\n+12125551212",
ParsedResultType.ADDRESSBOOK); ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;;", doTestRXingResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;;",
"Sean Owen\n+12125551212\ngoogle.com", ParsedResultType.ADDRESSBOOK); "Sean Owen\n+12125551212\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", doTestRXingResult("MECARD:TEL:+12125551212;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\n+12125551212\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK); "Sean Owen\n+12125551212\nsrowen@example.org\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MECARD:ADR:76 9th Ave;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", doTestRXingResult("MECARD:ADR:76 9th Ave;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\n76 9th Ave\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK); "Sean Owen\n76 9th Ave\nsrowen@example.org\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MECARD:BDAY:19760520;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", doTestRXingResult("MECARD:BDAY:19760520;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nsrowen@example.org\ngoogle.com\n19760520", ParsedResultType.ADDRESSBOOK); "Sean Owen\nsrowen@example.org\ngoogle.com\n19760520", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MECARD:ORG:Google;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", doTestRXingResult("MECARD:ORG:Google;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nGoogle\nsrowen@example.org\ngoogle.com", ParsedResultType.ADDRESSBOOK); "Sean Owen\nGoogle\nsrowen@example.org\ngoogle.com", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;", doTestRXingResult("MECARD:NOTE:ZXing Team;N:Sean Owen;URL:google.com;EMAIL:srowen@example.org;",
"Sean Owen\nsrowen@example.org\ngoogle.com\nZXing Team", ParsedResultType.ADDRESSBOOK); "Sean Owen\nsrowen@example.org\ngoogle.com\nZXing Team", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("N:Sean Owen;TEL:+12125551212;;", "N:Sean Owen;TEL:+12125551212;;", doTestRXingResult("N:Sean Owen;TEL:+12125551212;;", "N:Sean Owen;TEL:+12125551212;;",
ParsedResultType.TEXT); ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testAddressBookAUType() { public void testAddressBookAUType() {
doTestResult("MEMORY:\r\n", "", ParsedResultType.ADDRESSBOOK); doTestRXingResult("MEMORY:\r\n", "", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("MEMORY:foo\r\nNAME1:Sean\r\n", "Sean\nfoo", ParsedResultType.ADDRESSBOOK); doTestRXingResult("MEMORY:foo\r\nNAME1:Sean\r\n", "Sean\nfoo", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("TEL1:+12125551212\r\nMEMORY:\r\n", "+12125551212", ParsedResultType.ADDRESSBOOK); doTestRXingResult("TEL1:+12125551212\r\nMEMORY:\r\n", "+12125551212", ParsedRXingResultType.ADDRESSBOOK);
} }
@Test @Test
public void testBizcard() { public void testBizcard() {
doTestResult("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12225551212;E:srowen@example.org;", doTestRXingResult("BIZCARD:N:Sean;X:Owen;C:Google;A:123 Main St;M:+12225551212;E:srowen@example.org;",
"Sean Owen\nGoogle\n123 Main St\n+12225551212\nsrowen@example.org", ParsedResultType.ADDRESSBOOK); "Sean Owen\nGoogle\n123 Main St\n+12225551212\nsrowen@example.org", ParsedRXingResultType.ADDRESSBOOK);
} }
@Test @Test
public void testUPCA() { public void testUPCA() {
doTestResult("123456789012", "123456789012", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A); doTestRXingResult("123456789012", "123456789012", ParsedRXingResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestResult("1234567890123", "1234567890123", ParsedResultType.PRODUCT, BarcodeFormat.UPC_A); doTestRXingResult("1234567890123", "1234567890123", ParsedRXingResultType.PRODUCT, BarcodeFormat.UPC_A);
doTestResult("12345678901", "12345678901", ParsedResultType.TEXT); doTestRXingResult("12345678901", "12345678901", ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testUPCE() { public void testUPCE() {
doTestResult("01234565", "01234565", ParsedResultType.PRODUCT, BarcodeFormat.UPC_E); doTestRXingResult("01234565", "01234565", ParsedRXingResultType.PRODUCT, BarcodeFormat.UPC_E);
} }
@Test @Test
public void testEAN() { public void testEAN() {
doTestResult("00393157", "00393157", ParsedResultType.PRODUCT, BarcodeFormat.EAN_8); doTestRXingResult("00393157", "00393157", ParsedRXingResultType.PRODUCT, BarcodeFormat.EAN_8);
doTestResult("00393158", "00393158", ParsedResultType.TEXT); doTestRXingResult("00393158", "00393158", ParsedRXingResultType.TEXT);
doTestResult("5051140178499", "5051140178499", ParsedResultType.PRODUCT, BarcodeFormat.EAN_13); doTestRXingResult("5051140178499", "5051140178499", ParsedRXingResultType.PRODUCT, BarcodeFormat.EAN_13);
doTestResult("5051140178490", "5051140178490", ParsedResultType.TEXT); doTestRXingResult("5051140178490", "5051140178490", ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testISBN() { public void testISBN() {
doTestResult("9784567890123", "9784567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13); doTestRXingResult("9784567890123", "9784567890123", ParsedRXingResultType.ISBN, BarcodeFormat.EAN_13);
doTestResult("9794567890123", "9794567890123", ParsedResultType.ISBN, BarcodeFormat.EAN_13); doTestRXingResult("9794567890123", "9794567890123", ParsedRXingResultType.ISBN, BarcodeFormat.EAN_13);
doTestResult("97845678901", "97845678901", ParsedResultType.TEXT); doTestRXingResult("97845678901", "97845678901", ParsedRXingResultType.TEXT);
doTestResult("97945678901", "97945678901", ParsedResultType.TEXT); doTestRXingResult("97945678901", "97945678901", ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testURI() { public void testURI() {
doTestResult("http://google.com", "http://google.com", ParsedResultType.URI); doTestRXingResult("http://google.com", "http://google.com", ParsedRXingResultType.URI);
doTestResult("google.com", "http://google.com", ParsedResultType.URI); doTestRXingResult("google.com", "http://google.com", ParsedRXingResultType.URI);
doTestResult("https://google.com", "https://google.com", ParsedResultType.URI); doTestRXingResult("https://google.com", "https://google.com", ParsedRXingResultType.URI);
doTestResult("HTTP://google.com", "HTTP://google.com", ParsedResultType.URI); doTestRXingResult("HTTP://google.com", "HTTP://google.com", ParsedRXingResultType.URI);
doTestResult("http://google.com/foobar", "http://google.com/foobar", ParsedResultType.URI); doTestRXingResult("http://google.com/foobar", "http://google.com/foobar", ParsedRXingResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI); doTestRXingResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedRXingResultType.URI);
doTestResult("google.com:443", "http://google.com:443", ParsedResultType.URI); doTestRXingResult("google.com:443", "http://google.com:443", ParsedRXingResultType.URI);
doTestResult("google.com:443/", "http://google.com:443/", ParsedResultType.URI); doTestRXingResult("google.com:443/", "http://google.com:443/", ParsedRXingResultType.URI);
doTestResult("google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI); doTestRXingResult("google.com:443/foobar", "http://google.com:443/foobar", ParsedRXingResultType.URI);
doTestResult("http://google.com:443/foobar", "http://google.com:443/foobar", ParsedResultType.URI); doTestRXingResult("http://google.com:443/foobar", "http://google.com:443/foobar", ParsedRXingResultType.URI);
doTestResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedResultType.URI); doTestRXingResult("https://google.com:443/foobar", "https://google.com:443/foobar", ParsedRXingResultType.URI);
doTestResult("ftp://google.com/fake", "ftp://google.com/fake", ParsedResultType.URI); doTestRXingResult("ftp://google.com/fake", "ftp://google.com/fake", ParsedRXingResultType.URI);
doTestResult("gopher://google.com/obsolete", "gopher://google.com/obsolete", ParsedResultType.URI); doTestRXingResult("gopher://google.com/obsolete", "gopher://google.com/obsolete", ParsedRXingResultType.URI);
} }
@Test @Test
public void testGeo() { public void testGeo() {
doTestResult("geo:1,2", "1.0, 2.0", ParsedResultType.GEO); doTestRXingResult("geo:1,2", "1.0, 2.0", ParsedRXingResultType.GEO);
doTestResult("GEO:1,2", "1.0, 2.0", ParsedResultType.GEO); doTestRXingResult("GEO:1,2", "1.0, 2.0", ParsedRXingResultType.GEO);
doTestResult("geo:1,2,3", "1.0, 2.0, 3.0m", ParsedResultType.GEO); doTestRXingResult("geo:1,2,3", "1.0, 2.0, 3.0m", ParsedRXingResultType.GEO);
doTestResult("geo:80.33,-32.3344,3.35", "80.33, -32.3344, 3.35m", ParsedResultType.GEO); doTestRXingResult("geo:80.33,-32.3344,3.35", "80.33, -32.3344, 3.35m", ParsedRXingResultType.GEO);
doTestResult("geo", "geo", ParsedResultType.TEXT); doTestRXingResult("geo", "geo", ParsedRXingResultType.TEXT);
doTestResult("geography", "geography", ParsedResultType.TEXT); doTestRXingResult("geography", "geography", ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testTel() { public void testTel() {
doTestResult("tel:+15551212", "+15551212", ParsedResultType.TEL); doTestRXingResult("tel:+15551212", "+15551212", ParsedRXingResultType.TEL);
doTestResult("TEL:+15551212", "+15551212", ParsedResultType.TEL); doTestRXingResult("TEL:+15551212", "+15551212", ParsedRXingResultType.TEL);
doTestResult("tel:212 555 1212", "212 555 1212", ParsedResultType.TEL); doTestRXingResult("tel:212 555 1212", "212 555 1212", ParsedRXingResultType.TEL);
doTestResult("tel:2125551212", "2125551212", ParsedResultType.TEL); doTestRXingResult("tel:2125551212", "2125551212", ParsedRXingResultType.TEL);
doTestResult("tel:212-555-1212", "212-555-1212", ParsedResultType.TEL); doTestRXingResult("tel:212-555-1212", "212-555-1212", ParsedRXingResultType.TEL);
doTestResult("tel", "tel", ParsedResultType.TEXT); doTestRXingResult("tel", "tel", ParsedRXingResultType.TEXT);
doTestResult("telephone", "telephone", ParsedResultType.TEXT); doTestRXingResult("telephone", "telephone", ParsedRXingResultType.TEXT);
} }
@Test @Test
public void testVCard() { public void testVCard() {
doTestResult("BEGIN:VCARD\r\nEND:VCARD", "", ParsedResultType.ADDRESSBOOK); doTestRXingResult("BEGIN:VCARD\r\nEND:VCARD", "", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen", doTestRXingResult("BEGIN:VCARD\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
ParsedResultType.ADDRESSBOOK); ParsedRXingResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen", doTestRXingResult("BEGIN:VCARD\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", "Sean Owen",
ParsedResultType.ADDRESSBOOK); ParsedRXingResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD", doTestRXingResult("BEGIN:VCARD\r\nADR;HOME:123 Main St\r\nVERSION:2.1\r\nN:Owen;Sean\r\nEND:VCARD",
"Sean Owen\n123 Main St", ParsedResultType.ADDRESSBOOK); "Sean Owen\n123 Main St", ParsedRXingResultType.ADDRESSBOOK);
doTestResult("BEGIN:VCARD", "", ParsedResultType.ADDRESSBOOK); doTestRXingResult("BEGIN:VCARD", "", ParsedRXingResultType.ADDRESSBOOK);
} }
@Test @Test
public void testVEvent() { public void testVEvent() {
// UTC times // UTC times
doTestResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" + doTestRXingResult("BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
"DTEND:20080505T234555Z\r\nEND:VEVENT\r\nEND:VCALENDAR", "DTEND:20080505T234555Z\r\nEND:VEVENT\r\nEND:VCALENDAR",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + formatTime(2008, 5, 5, 23, 45, 55), "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + formatTime(2008, 5, 5, 23, 45, 55),
ParsedResultType.CALENDAR); ParsedRXingResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" + doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\n" +
"DTEND:20080505T234555Z\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + "DTEND:20080505T234555Z\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" +
formatTime(2008, 5, 5, 23, 45, 55), formatTime(2008, 5, 5, 23, 45, 55),
ParsedResultType.CALENDAR); ParsedRXingResultType.CALENDAR);
// Local times // Local times
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\n" + doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\n" +
"DTEND:20080505T234555\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" + "DTEND:20080505T234555\r\nEND:VEVENT", "foo\n" + formatTime(2008, 5, 4, 12, 34, 56) + "\n" +
formatTime(2008, 5, 5, 23, 45, 55), formatTime(2008, 5, 5, 23, 45, 55),
ParsedResultType.CALENDAR); ParsedRXingResultType.CALENDAR);
// Date only (all day event) // Date only (all day event)
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\n" + doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\n" +
"DTEND:20080505\r\nEND:VEVENT", "foo\n" + formatDate(2008, 5, 4) + "\n" + "DTEND:20080505\r\nEND:VEVENT", "foo\n" + formatDate(2008, 5, 4) + "\n" +
formatDate(2008, 5, 5), formatDate(2008, 5, 5),
ParsedResultType.CALENDAR); ParsedRXingResultType.CALENDAR);
// Start time only // Start time only
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT", doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456Z\r\nEND:VEVENT",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedResultType.CALENDAR); "foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedRXingResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT", doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504T123456\r\nEND:VEVENT",
"foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedResultType.CALENDAR); "foo\n" + formatTime(2008, 5, 4, 12, 34, 56), ParsedRXingResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT", doTestRXingResult("BEGIN:VEVENT\r\nSUMMARY:foo\r\nDTSTART:20080504\r\nEND:VEVENT",
"foo\n" + formatDate(2008, 5, 4), ParsedResultType.CALENDAR); "foo\n" + formatDate(2008, 5, 4), ParsedRXingResultType.CALENDAR);
doTestResult("BEGIN:VEVENT\r\nDTEND:20080505T\r\nEND:VEVENT", doTestRXingResult("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", ParsedRXingResultType.TEXT);
// Yeah, it's OK that this is thought of as maybe a URI as long as it's not CALENDAR // Yeah, it's OK that this is thought of as maybe a URI as long as it's not CALENDAR
// Make sure illegal entries without newlines don't crash // Make sure illegal entries without newlines don't crash
doTestResult( doTestRXingResult(
"BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT", "BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT",
"BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT", "BEGIN:VEVENTSUMMARY:EventDTSTART:20081030T122030ZDTEND:20081030T132030ZEND:VEVENT",
ParsedResultType.URI); ParsedRXingResultType.URI);
} }
private static String formatDate(int year, int month, int day) { private static String formatDate(int year, int month, int day) {
@@ -263,68 +263,68 @@ public final class ParsedReaderResultTestCase extends Assert {
@Test @Test
public void testSMS() { public void testSMS() {
doTestResult("sms:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("sms:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("SMS:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("SMS:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("sms:+15551212;via=999333", "+15551212", ParsedResultType.SMS); doTestRXingResult("sms:+15551212;via=999333", "+15551212", ParsedRXingResultType.SMS);
doTestResult("sms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS); doTestRXingResult("sms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedRXingResultType.SMS);
doTestResult("sms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS); doTestRXingResult("sms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedRXingResultType.SMS);
} }
@Test @Test
public void testSMSTO() { public void testSMSTO() {
doTestResult("SMSTO:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("SMSTO:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("smsto:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("smsto:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("smsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS); doTestRXingResult("smsto:+15551212:subject", "+15551212\nsubject", ParsedRXingResultType.SMS);
doTestResult("smsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS); doTestRXingResult("smsto:+15551212:My message", "+15551212\nMy message", ParsedRXingResultType.SMS);
// Need to handle question mark in the subject // Need to handle question mark in the subject
doTestResult("smsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS); doTestRXingResult("smsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedRXingResultType.SMS);
// Need to handle colon in the subject // Need to handle colon in the subject
doTestResult("smsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this", doTestRXingResult("smsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
ParsedResultType.SMS); ParsedRXingResultType.SMS);
doTestResult("smsto:212-555-1212:Here's a longer message. Should be fine.", doTestRXingResult("smsto:212-555-1212:Here's a longer message. Should be fine.",
"212-555-1212\nHere's a longer message. Should be fine.", "212-555-1212\nHere's a longer message. Should be fine.",
ParsedResultType.SMS); ParsedRXingResultType.SMS);
} }
@Test @Test
public void testMMS() { public void testMMS() {
doTestResult("mms:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("mms:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("MMS:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("MMS:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("mms:+15551212;via=999333", "+15551212", ParsedResultType.SMS); doTestRXingResult("mms:+15551212;via=999333", "+15551212", ParsedRXingResultType.SMS);
doTestResult("mms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedResultType.SMS); doTestRXingResult("mms:+15551212?subject=foo&body=bar", "+15551212\nfoo\nbar", ParsedRXingResultType.SMS);
doTestResult("mms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedResultType.SMS); doTestRXingResult("mms:+15551212,+12124440101", "+15551212\n+12124440101", ParsedRXingResultType.SMS);
} }
@Test @Test
public void testMMSTO() { public void testMMSTO() {
doTestResult("MMSTO:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("MMSTO:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("mmsto:+15551212", "+15551212", ParsedResultType.SMS); doTestRXingResult("mmsto:+15551212", "+15551212", ParsedRXingResultType.SMS);
doTestResult("mmsto:+15551212:subject", "+15551212\nsubject", ParsedResultType.SMS); doTestRXingResult("mmsto:+15551212:subject", "+15551212\nsubject", ParsedRXingResultType.SMS);
doTestResult("mmsto:+15551212:My message", "+15551212\nMy message", ParsedResultType.SMS); doTestRXingResult("mmsto:+15551212:My message", "+15551212\nMy message", ParsedRXingResultType.SMS);
doTestResult("mmsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedResultType.SMS); doTestRXingResult("mmsto:+15551212:What's up?", "+15551212\nWhat's up?", ParsedRXingResultType.SMS);
doTestResult("mmsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this", doTestRXingResult("mmsto:+15551212:Directions: Do this", "+15551212\nDirections: Do this",
ParsedResultType.SMS); ParsedRXingResultType.SMS);
doTestResult("mmsto:212-555-1212:Here's a longer message. Should be fine.", doTestRXingResult("mmsto:212-555-1212:Here's a longer message. Should be fine.",
"212-555-1212\nHere's a longer message. Should be fine.", ParsedResultType.SMS); "212-555-1212\nHere's a longer message. Should be fine.", ParsedRXingResultType.SMS);
} }
private static void doTestResult(String contents, private static void doTestRXingResult(String contents,
String goldenResult, String goldenRXingResult,
ParsedResultType type) { ParsedRXingResultType type) {
doTestResult(contents, goldenResult, type, BarcodeFormat.QR_CODE); // QR code is arbitrary doTestRXingResult(contents, goldenRXingResult, type, BarcodeFormat.QR_CODE); // QR code is arbitrary
} }
private static void doTestResult(String contents, private static void doTestRXingResult(String contents,
String goldenResult, String goldenRXingResult,
ParsedResultType type, ParsedRXingResultType type,
BarcodeFormat format) { BarcodeFormat format) {
Result fakeResult = new Result(contents, null, null, format); RXingResult fakeRXingResult = new RXingResult(contents, null, null, format);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertNotNull(result); assertNotNull(result);
assertSame(type, result.getType()); assertSame(type, result.getType());
String displayResult = result.getDisplayResult(); String displayRXingResult = result.getDisplayRXingResult();
assertEquals(goldenResult, displayResult); assertEquals(goldenRXingResult, displayRXingResult);
} }
} }

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link ProductParsedResult}. * Tests {@link ProductParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class ProductParsedResultTestCase extends Assert { public final class ProductParsedRXingResultTestCase extends Assert {
@Test @Test
public void testProduct() { public void testProduct() {
@@ -37,12 +37,12 @@ public final class ProductParsedResultTestCase extends Assert {
} }
private static void doTest(String contents, String normalized, BarcodeFormat format) { private static void doTest(String contents, String normalized, BarcodeFormat format) {
Result fakeResult = new Result(contents, null, null, format); RXingResult fakeRXingResult = new RXingResult(contents, null, null, format);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.PRODUCT, result.getType()); assertSame(ParsedRXingResultType.PRODUCT, result.getType());
ProductParsedResult productResult = (ProductParsedResult) result; ProductParsedRXingResult productRXingResult = (ProductParsedRXingResult) result;
assertEquals(contents, productResult.getProductID()); assertEquals(contents, productRXingResult.getProductID());
assertEquals(normalized, productResult.getNormalizedProductID()); assertEquals(normalized, productRXingResult.getNormalizedProductID());
} }
} }

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link SMSParsedResult}. * Tests {@link SMSParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class SMSMMSParsedResultTestCase extends Assert { public final class SMSMMSParsedRXingResultTestCase extends Assert {
@Test @Test
public void testSMS() { public void testSMS() {
@@ -52,15 +52,15 @@ public final class SMSMMSParsedResultTestCase extends Assert {
String body, String body,
String via, String via,
String parsedURI) { String parsedURI) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.SMS, result.getType()); assertSame(ParsedRXingResultType.SMS, result.getType());
SMSParsedResult smsResult = (SMSParsedResult) result; SMSParsedRXingResult smsRXingResult = (SMSParsedRXingResult) result;
assertArrayEquals(new String[] { number }, smsResult.getNumbers()); assertArrayEquals(new String[] { number }, smsRXingResult.getNumbers());
assertEquals(subject, smsResult.getSubject()); assertEquals(subject, smsRXingResult.getSubject());
assertEquals(body, smsResult.getBody()); assertEquals(body, smsRXingResult.getBody());
assertArrayEquals(new String[] { via }, smsResult.getVias()); assertArrayEquals(new String[] { via }, smsRXingResult.getVias());
assertEquals(parsedURI, smsResult.getSMSURI()); assertEquals(parsedURI, smsRXingResult.getSMSURI());
} }
} }

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link TelParsedResult}. * Tests {@link TelParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class TelParsedResultTestCase extends Assert { public final class TelParsedRXingResultTestCase extends Assert {
@Test @Test
public void testTel() { public void testTel() {
@@ -35,13 +35,13 @@ public final class TelParsedResultTestCase extends Assert {
} }
private static void doTest(String contents, String number, String title) { private static void doTest(String contents, String number, String title) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.TEL, result.getType()); assertSame(ParsedRXingResultType.TEL, result.getType());
TelParsedResult telResult = (TelParsedResult) result; TelParsedRXingResult telRXingResult = (TelParsedRXingResult) result;
assertEquals(number, telResult.getNumber()); assertEquals(number, telRXingResult.getNumber());
assertEquals(title, telResult.getTitle()); assertEquals(title, telRXingResult.getTitle());
assertEquals("tel:" + number, telResult.getTelURI()); assertEquals("tel:" + number, telRXingResult.getTelURI());
} }
} }

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link URIParsedResult}. * Tests {@link URIParsedRXingResult}.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class URIParsedResultTestCase extends Assert { public final class URIParsedRXingResultTestCase extends Assert {
@Test @Test
public void testBookmarkDocomo() { public void testBookmarkDocomo() {
@@ -116,25 +116,25 @@ public final class URIParsedResultTestCase extends Assert {
} }
private static void doTest(String contents, String uri, String title) { private static void doTest(String contents, String uri, String title) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.URI, result.getType()); assertSame(ParsedRXingResultType.URI, result.getType());
URIParsedResult uriResult = (URIParsedResult) result; URIParsedRXingResult uriRXingResult = (URIParsedRXingResult) result;
assertEquals(uri, uriResult.getURI()); assertEquals(uri, uriRXingResult.getURI());
assertEquals(title, uriResult.getTitle()); assertEquals(title, uriRXingResult.getTitle());
} }
private static void doTestNotUri(String text) { private static void doTestNotUri(String text) {
Result fakeResult = new Result(text, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(text, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.TEXT, result.getType()); assertSame(ParsedRXingResultType.TEXT, result.getType());
assertEquals(text, result.getDisplayResult()); assertEquals(text, result.getDisplayRXingResult());
} }
private static void doTestIsPossiblyMalicious(String uri, boolean malicious) { private static void doTestIsPossiblyMalicious(String uri, boolean malicious) {
Result fakeResult = new Result(uri, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(uri, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(malicious ? ParsedResultType.TEXT : ParsedResultType.URI, result.getType()); assertSame(malicious ? ParsedRXingResultType.TEXT : ParsedRXingResultType.URI, result.getType());
} }
} }

View File

@@ -18,23 +18,23 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link VINParsedResult}. * Tests {@link VINParsedRXingResult}.
*/ */
public final class VINParsedResultTestCase extends Assert { public final class VINParsedRXingResultTestCase extends Assert {
@Test @Test
public void testNotVIN() { public void testNotVIN() {
Result fakeResult = new Result("1M8GDM9A1KP042788", null, null, BarcodeFormat.CODE_39); RXingResult fakeRXingResult = new RXingResult("1M8GDM9A1KP042788", null, null, BarcodeFormat.CODE_39);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertEquals(ParsedResultType.TEXT, result.getType()); assertEquals(ParsedRXingResultType.TEXT, result.getType());
fakeResult = new Result("1M8GDM9AXKP042788", null, null, BarcodeFormat.CODE_128); fakeRXingResult = new RXingResult("1M8GDM9AXKP042788", null, null, BarcodeFormat.CODE_128);
result = ResultParser.parseResult(fakeResult); result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertEquals(ParsedResultType.TEXT, result.getType()); assertEquals(ParsedRXingResultType.TEXT, result.getType());
} }
@Test @Test
@@ -53,18 +53,18 @@ public final class VINParsedResultTestCase extends Assert {
int year, int year,
char plant, char plant,
String sequential) { String sequential) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.CODE_39); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.CODE_39);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
assertSame(ParsedResultType.VIN, result.getType()); assertSame(ParsedRXingResultType.VIN, result.getType());
VINParsedResult vinResult = (VINParsedResult) result; VINParsedRXingResult vinRXingResult = (VINParsedRXingResult) result;
assertEquals(wmi, vinResult.getWorldManufacturerID()); assertEquals(wmi, vinRXingResult.getWorldManufacturerID());
assertEquals(vds, vinResult.getVehicleDescriptorSection()); assertEquals(vds, vinRXingResult.getVehicleDescriptorSection());
assertEquals(vis, vinResult.getVehicleIdentifierSection()); assertEquals(vis, vinRXingResult.getVehicleIdentifierSection());
assertEquals(country, vinResult.getCountryCode()); assertEquals(country, vinRXingResult.getCountryCode());
assertEquals(attributes, vinResult.getVehicleAttributes()); assertEquals(attributes, vinRXingResult.getVehicleAttributes());
assertEquals(year, vinResult.getModelYear()); assertEquals(year, vinRXingResult.getModelYear());
assertEquals(plant, vinResult.getPlantCode()); assertEquals(plant, vinRXingResult.getPlantCode());
assertEquals(sequential, vinResult.getSequentialNumber()); assertEquals(sequential, vinRXingResult.getSequentialNumber());
} }
} }

View File

@@ -17,16 +17,16 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/** /**
* Tests {@link WifiParsedResult}. * Tests {@link WifiParsedRXingResult}.
* *
* @author Vikram Aggarwal * @author Vikram Aggarwal
*/ */
public final class WifiParsedResultTestCase extends Assert { public final class WifiParsedRXingResultTestCase extends Assert {
@Test @Test
public void testNoPassword() { public void testNoPassword() {
@@ -79,15 +79,15 @@ public final class WifiParsedResultTestCase extends Assert {
String ssid, String ssid,
String password, String password,
String type) { String type) {
Result fakeResult = new Result(contents, null, null, BarcodeFormat.QR_CODE); RXingResult fakeRXingResult = new RXingResult(contents, null, null, BarcodeFormat.QR_CODE);
ParsedResult result = ResultParser.parseResult(fakeResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(fakeRXingResult);
// Ensure it is a wifi code // Ensure it is a wifi code
assertSame(ParsedResultType.WIFI, result.getType()); assertSame(ParsedRXingResultType.WIFI, result.getType());
WifiParsedResult wifiResult = (WifiParsedResult) result; WifiParsedRXingResult wifiRXingResult = (WifiParsedRXingResult) result;
assertEquals(ssid, wifiResult.getSsid()); assertEquals(ssid, wifiRXingResult.getSsid());
assertEquals(password, wifiResult.getPassword()); assertEquals(password, wifiRXingResult.getPassword());
assertEquals(type, wifiResult.getNetworkEncryption()); assertEquals(type, wifiRXingResult.getNetworkEncryption());
} }
} }

View File

@@ -23,8 +23,8 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource; import com.google.zxing.LuminanceSource;
import com.google.zxing.Reader; import com.google.zxing.Reader;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.ResultMetadataType; import com.google.zxing.RXingResultMetadataType;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@@ -61,7 +61,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
private final Path testBase; private final Path testBase;
private final Reader barcodeReader; private final Reader barcodeReader;
private final BarcodeFormat expectedFormat; private final BarcodeFormat expectedFormat;
private final List<TestResult> testResults; private final List<TestRXingResult> testRXingResults;
private final EnumMap<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class); private final EnumMap<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
public static Path buildTestBase(String testBasePathSuffix) { public static Path buildTestBase(String testBasePathSuffix) {
@@ -80,7 +80,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
this.testBase = buildTestBase(testBasePathSuffix); this.testBase = buildTestBase(testBasePathSuffix);
this.barcodeReader = barcodeReader; this.barcodeReader = barcodeReader;
this.expectedFormat = expectedFormat; this.expectedFormat = expectedFormat;
testResults = new ArrayList<>(); testRXingResults = new ArrayList<>();
System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n"); System.setProperty("java.util.logging.SimpleFormatter.format", "%4$s: %5$s%6$s%n");
} }
@@ -112,7 +112,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
int maxMisreads, int maxMisreads,
int maxTryHarderMisreads, int maxTryHarderMisreads,
float rotation) { float rotation) {
testResults.add(new TestResult(mustPassCount, tryHarderCount, maxMisreads, maxTryHarderMisreads, rotation)); testRXingResults.add(new TestRXingResult(mustPassCount, tryHarderCount, maxMisreads, maxTryHarderMisreads, rotation));
} }
protected final List<Path> getImageFiles() throws IOException { protected final List<Path> getImageFiles() throws IOException {
@@ -132,10 +132,10 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
@Test @Test
public void testBlackBox() throws IOException { public void testBlackBox() throws IOException {
assertFalse(testResults.isEmpty()); assertFalse(testRXingResults.isEmpty());
List<Path> imageFiles = getImageFiles(); List<Path> imageFiles = getImageFiles();
int testCount = testResults.size(); int testCount = testRXingResults.size();
int[] passedCounts = new int[testCount]; int[] passedCounts = new int[testCount];
int[] misreadCounts = new int[testCount]; int[] misreadCounts = new int[testCount];
@@ -168,7 +168,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
} }
for (int x = 0; x < testCount; x++) { for (int x = 0; x < testCount; x++) {
float rotation = testResults.get(x).getRotation(); float rotation = testRXingResults.get(x).getRotation();
BufferedImage rotatedImage = rotateImage(image, rotation); BufferedImage rotatedImage = rotateImage(image, rotation);
LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage); LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
@@ -199,23 +199,23 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
int totalMisread = 0; int totalMisread = 0;
int totalMaxMisread = 0; int totalMaxMisread = 0;
for (int x = 0; x < testResults.size(); x++) { for (int x = 0; x < testRXingResults.size(); x++) {
TestResult testResult = testResults.get(x); TestRXingResult testRXingResult = testRXingResults.get(x);
log.info(String.format("Rotation %d degrees:", (int) testResult.getRotation())); log.info(String.format("Rotation %d degrees:", (int) testRXingResult.getRotation()));
log.info(String.format(" %d of %d images passed (%d required)", log.info(String.format(" %d of %d images passed (%d required)",
passedCounts[x], imageFiles.size(), testResult.getMustPassCount())); passedCounts[x], imageFiles.size(), testRXingResult.getMustPassCount()));
int failed = imageFiles.size() - passedCounts[x]; int failed = imageFiles.size() - passedCounts[x];
log.info(String.format(" %d failed due to misreads, %d not detected", log.info(String.format(" %d failed due to misreads, %d not detected",
misreadCounts[x], failed - misreadCounts[x])); misreadCounts[x], failed - misreadCounts[x]));
log.info(String.format(" %d of %d images passed with try harder (%d required)", log.info(String.format(" %d of %d images passed with try harder (%d required)",
tryHarderCounts[x], imageFiles.size(), testResult.getTryHarderCount())); tryHarderCounts[x], imageFiles.size(), testRXingResult.getTryHarderCount()));
failed = imageFiles.size() - tryHarderCounts[x]; failed = imageFiles.size() - tryHarderCounts[x];
log.info(String.format(" %d failed due to misreads, %d not detected", log.info(String.format(" %d failed due to misreads, %d not detected",
tryHarderMisreadCounts[x], failed - tryHarderMisreadCounts[x])); tryHarderMisreadCounts[x], failed - tryHarderMisreadCounts[x]));
totalFound += passedCounts[x] + tryHarderCounts[x]; totalFound += passedCounts[x] + tryHarderCounts[x];
totalMustPass += testResult.getMustPassCount() + testResult.getTryHarderCount(); totalMustPass += testRXingResult.getMustPassCount() + testRXingResult.getTryHarderCount();
totalMisread += misreadCounts[x] + tryHarderMisreadCounts[x]; totalMisread += misreadCounts[x] + tryHarderMisreadCounts[x];
totalMaxMisread += testResult.getMaxMisreads() + testResult.getMaxTryHarderMisreads(); totalMaxMisread += testRXingResult.getMaxMisreads() + testRXingResult.getMaxTryHarderMisreads();
} }
int totalTests = imageFiles.size() * testCount * 2; int totalTests = imageFiles.size() * testCount * 2;
@@ -235,17 +235,17 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
// Then run through again and assert if any failed // Then run through again and assert if any failed
for (int x = 0; x < testCount; x++) { for (int x = 0; x < testCount; x++) {
TestResult testResult = testResults.get(x); TestRXingResult testRXingResult = testRXingResults.get(x);
String label = "Rotation " + testResult.getRotation() + " degrees: Too many images failed"; String label = "Rotation " + testRXingResult.getRotation() + " degrees: Too many images failed";
assertTrue(label, assertTrue(label,
passedCounts[x] >= testResult.getMustPassCount()); passedCounts[x] >= testRXingResult.getMustPassCount());
assertTrue("Try harder, " + label, assertTrue("Try harder, " + label,
tryHarderCounts[x] >= testResult.getTryHarderCount()); tryHarderCounts[x] >= testRXingResult.getTryHarderCount());
label = "Rotation " + testResult.getRotation() + " degrees: Too many images misread"; label = "Rotation " + testRXingResult.getRotation() + " degrees: Too many images misread";
assertTrue(label, assertTrue(label,
misreadCounts[x] <= testResult.getMaxMisreads()); misreadCounts[x] <= testRXingResult.getMaxMisreads());
assertTrue("Try harder, " + label, assertTrue("Try harder, " + label,
tryHarderMisreadCounts[x] <= testResult.getMaxTryHarderMisreads()); tryHarderMisreadCounts[x] <= testRXingResult.getMaxTryHarderMisreads());
} }
} }
@@ -264,7 +264,7 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
// Try in 'pure' mode mostly to exercise PURE_BARCODE code paths for exceptions; // Try in 'pure' mode mostly to exercise PURE_BARCODE code paths for exceptions;
// not expected to pass, generally // not expected to pass, generally
Result result = null; RXingResult result = null;
try { try {
Map<DecodeHintType,Object> pureHints = new EnumMap<>(hints); Map<DecodeHintType,Object> pureHints = new EnumMap<>(hints);
pureHints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE); pureHints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
@@ -290,9 +290,9 @@ public abstract class AbstractBlackBoxTestCase extends Assert {
return false; return false;
} }
Map<ResultMetadataType,?> resultMetadata = result.getResultMetadata(); Map<RXingResultMetadataType,?> resultMetadata = result.getRXingResultMetadata();
for (Map.Entry<?,?> metadatum : expectedMetadata.entrySet()) { for (Map.Entry<?,?> metadatum : expectedMetadata.entrySet()) {
ResultMetadataType key = ResultMetadataType.valueOf(metadatum.getKey().toString()); RXingResultMetadataType key = RXingResultMetadataType.valueOf(metadatum.getKey().toString());
Object expectedValue = metadatum.getValue(); Object expectedValue = metadatum.getValue();
Object actualValue = resultMetadata == null ? null : resultMetadata.get(key); Object actualValue = resultMetadata == null ? null : resultMetadata.get(key);
if (!expectedValue.equals(actualValue)) { if (!expectedValue.equals(actualValue)) {

View File

@@ -22,7 +22,7 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource; import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import org.junit.Test; import org.junit.Test;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
@@ -45,13 +45,13 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
private static final Logger log = Logger.getLogger(AbstractNegativeBlackBoxTestCase.class.getSimpleName()); private static final Logger log = Logger.getLogger(AbstractNegativeBlackBoxTestCase.class.getSimpleName());
private final List<TestResult> testResults; private final List<TestRXingResult> testRXingResults;
private static final class TestResult { private static final class TestRXingResult {
private final int falsePositivesAllowed; private final int falsePositivesAllowed;
private final float rotation; private final float rotation;
TestResult(int falsePositivesAllowed, float rotation) { TestRXingResult(int falsePositivesAllowed, float rotation) {
this.falsePositivesAllowed = falsePositivesAllowed; this.falsePositivesAllowed = falsePositivesAllowed;
this.rotation = rotation; this.rotation = rotation;
} }
@@ -68,29 +68,29 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
// Use the multiformat reader to evaluate all decoders in the system. // Use the multiformat reader to evaluate all decoders in the system.
protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) { protected AbstractNegativeBlackBoxTestCase(String testBasePathSuffix) {
super(testBasePathSuffix, new MultiFormatReader(), null); super(testBasePathSuffix, new MultiFormatReader(), null);
testResults = new ArrayList<>(); testRXingResults = new ArrayList<>();
} }
protected final void addTest(int falsePositivesAllowed, float rotation) { protected final void addTest(int falsePositivesAllowed, float rotation) {
testResults.add(new TestResult(falsePositivesAllowed, rotation)); testRXingResults.add(new TestRXingResult(falsePositivesAllowed, rotation));
} }
@Override @Override
@Test @Test
public void testBlackBox() throws IOException { public void testBlackBox() throws IOException {
assertFalse(testResults.isEmpty()); assertFalse(testRXingResults.isEmpty());
List<Path> imageFiles = getImageFiles(); List<Path> imageFiles = getImageFiles();
int[] falsePositives = new int[testResults.size()]; int[] falsePositives = new int[testRXingResults.size()];
for (Path testImage : imageFiles) { for (Path testImage : imageFiles) {
log.info(String.format("Starting %s", testImage)); log.info(String.format("Starting %s", testImage));
BufferedImage image = ImageIO.read(testImage.toFile()); BufferedImage image = ImageIO.read(testImage.toFile());
if (image == null) { if (image == null) {
throw new IOException("Could not read image: " + testImage); throw new IOException("Could not read image: " + testImage);
} }
for (int x = 0; x < testResults.size(); x++) { for (int x = 0; x < testRXingResults.size(); x++) {
TestResult testResult = testResults.get(x); TestRXingResult testRXingResult = testRXingResults.get(x);
if (!checkForFalsePositives(image, testResult.getRotation())) { if (!checkForFalsePositives(image, testRXingResult.getRotation())) {
falsePositives[x]++; falsePositives[x]++;
} }
} }
@@ -99,10 +99,10 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
int totalFalsePositives = 0; int totalFalsePositives = 0;
int totalAllowed = 0; int totalAllowed = 0;
for (int x = 0; x < testResults.size(); x++) { for (int x = 0; x < testRXingResults.size(); x++) {
TestResult testResult = testResults.get(x); TestRXingResult testRXingResult = testRXingResults.get(x);
totalFalsePositives += falsePositives[x]; totalFalsePositives += falsePositives[x];
totalAllowed += testResult.getFalsePositivesAllowed(); totalAllowed += testRXingResult.getFalsePositivesAllowed();
} }
if (totalFalsePositives < totalAllowed) { if (totalFalsePositives < totalAllowed) {
@@ -111,13 +111,13 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
log.warning(String.format("--- Test failed by %d images", totalFalsePositives - totalAllowed)); log.warning(String.format("--- Test failed by %d images", totalFalsePositives - totalAllowed));
} }
for (int x = 0; x < testResults.size(); x++) { for (int x = 0; x < testRXingResults.size(); x++) {
TestResult testResult = testResults.get(x); TestRXingResult testRXingResult = testRXingResults.get(x);
log.info(String.format("Rotation %d degrees: %d of %d images were false positives (%d allowed)", log.info(String.format("Rotation %d degrees: %d of %d images were false positives (%d allowed)",
(int) testResult.getRotation(), falsePositives[x], imageFiles.size(), (int) testRXingResult.getRotation(), falsePositives[x], imageFiles.size(),
testResult.getFalsePositivesAllowed())); testRXingResult.getFalsePositivesAllowed()));
assertTrue("Rotation " + testResult.getRotation() + " degrees: Too many false positives found", assertTrue("Rotation " + testRXingResult.getRotation() + " degrees: Too many false positives found",
falsePositives[x] <= testResult.getFalsePositivesAllowed()); falsePositives[x] <= testRXingResult.getFalsePositivesAllowed());
} }
} }
@@ -132,7 +132,7 @@ public abstract class AbstractNegativeBlackBoxTestCase extends AbstractBlackBoxT
BufferedImage rotatedImage = rotateImage(image, rotationInDegrees); BufferedImage rotatedImage = rotateImage(image, rotationInDegrees);
LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage); LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result; RXingResult result;
try { try {
result = getReader().decode(bitmap); result = getReader().decode(bitmap);
log.info(String.format("Found false positive: '%s' with format '%s' (rotation: %d)", log.info(String.format("Found false positive: '%s' with format '%s' (rotation: %d)",

View File

@@ -19,7 +19,7 @@ package com.google.zxing.common;
/** /**
* Encapsulates the result of one test over a batch of black-box images. * Encapsulates the result of one test over a batch of black-box images.
*/ */
public final class TestResult { public final class TestRXingResult {
private final int mustPassCount; private final int mustPassCount;
private final int tryHarderCount; private final int tryHarderCount;
@@ -27,7 +27,7 @@ public final class TestResult {
private final int maxTryHarderMisreads; private final int maxTryHarderMisreads;
private final float rotation; private final float rotation;
public TestResult(int mustPassCount, int tryHarderCount, int maxMisreads, int maxTryHarderMisreads, float rotation) { public TestRXingResult(int mustPassCount, int tryHarderCount, int maxMisreads, int maxTryHarderMisreads, float rotation) {
this.mustPassCount = mustPassCount; this.mustPassCount = mustPassCount;
this.tryHarderCount = tryHarderCount; this.tryHarderCount = tryHarderCount;
this.maxMisreads = maxMisreads; this.maxMisreads = maxMisreads;

View File

@@ -25,7 +25,7 @@ import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.LuminanceSource; import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader; import com.google.zxing.MultiFormatReader;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.HybridBinarizer; import com.google.zxing.common.HybridBinarizer;
import org.junit.Assert; import org.junit.Assert;
@@ -47,7 +47,7 @@ public final class MultiTestCase extends Assert {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
MultipleBarcodeReader reader = new GenericMultipleBarcodeReader(new MultiFormatReader()); MultipleBarcodeReader reader = new GenericMultipleBarcodeReader(new MultiFormatReader());
Result[] results = reader.decodeMultiple(bitmap); RXingResult[] results = reader.decodeMultiple(bitmap);
assertNotNull(results); assertNotNull(results);
assertEquals(2, results.length); assertEquals(2, results.length);

View File

@@ -28,9 +28,9 @@ import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap; import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.LuminanceSource; import com.google.zxing.LuminanceSource;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.ResultMetadataType; import com.google.zxing.RXingResultMetadataType;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.HybridBinarizer; import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.multi.MultipleBarcodeReader; import com.google.zxing.multi.MultipleBarcodeReader;
@@ -53,15 +53,15 @@ public final class MultiQRCodeTestCase extends Assert {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
MultipleBarcodeReader reader = new QRCodeMultiReader(); MultipleBarcodeReader reader = new QRCodeMultiReader();
Result[] results = reader.decodeMultiple(bitmap); RXingResult[] results = reader.decodeMultiple(bitmap);
assertNotNull(results); assertNotNull(results);
assertEquals(4, results.length); assertEquals(4, results.length);
Collection<String> barcodeContents = new HashSet<>(); Collection<String> barcodeContents = new HashSet<>();
for (Result result : results) { for (RXingResult result : results) {
barcodeContents.add(result.getText()); barcodeContents.add(result.getText());
assertEquals(BarcodeFormat.QR_CODE, result.getBarcodeFormat()); assertEquals(BarcodeFormat.QR_CODE, result.getBarcodeFormat());
assertNotNull(result.getResultMetadata()); assertNotNull(result.getRXingResultMetadata());
} }
Collection<String> expectedContents = new HashSet<>(); Collection<String> expectedContents = new HashSet<>();
expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!"); expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!");
@@ -74,27 +74,27 @@ public final class MultiQRCodeTestCase extends Assert {
@Test @Test
public void testProcessStructuredAppend() { public void testProcessStructuredAppend() {
Result sa1 = new Result("SA1", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); RXingResult sa1 = new RXingResult("SA1", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
Result sa2 = new Result("SA2", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); RXingResult sa2 = new RXingResult("SA2", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
Result sa3 = new Result("SA3", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); RXingResult sa3 = new RXingResult("SA3", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
sa1.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, 2); sa1.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE, 2);
sa1.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); sa1.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
sa2.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (1 << 4) + 2); sa2.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (1 << 4) + 2);
sa2.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); sa2.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
sa3.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (2 << 4) + 2); sa3.putMetadata(RXingResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (2 << 4) + 2);
sa3.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); sa3.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
Result nsa = new Result("NotSA", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE); RXingResult nsa = new RXingResult("NotSA", new byte[]{}, new RXingResultPoint[]{}, BarcodeFormat.QR_CODE);
nsa.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L"); nsa.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
List<Result> inputs = Arrays.asList(sa3, sa1, nsa, sa2); List<RXingResult> inputs = Arrays.asList(sa3, sa1, nsa, sa2);
List<Result> results = QRCodeMultiReader.processStructuredAppend(inputs); List<RXingResult> results = QRCodeMultiReader.processStructuredAppend(inputs);
assertNotNull(results); assertNotNull(results);
assertEquals(2, results.size()); assertEquals(2, results.size());
Collection<String> barcodeContents = new HashSet<>(); Collection<String> barcodeContents = new HashSet<>();
for (Result result : results) { for (RXingResult result : results) {
barcodeContents.add(result.getText()); barcodeContents.add(result.getText());
} }
Collection<String> expectedContents = new HashSet<>(); Collection<String> expectedContents = new HashSet<>();

View File

@@ -23,7 +23,7 @@ import org.junit.Test;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType; import com.google.zxing.EncodeHintType;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.Writer; import com.google.zxing.Writer;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
@@ -118,12 +118,12 @@ public class Code128WriterTestCase extends Assert {
String toEncode = "\u00f1" + "10958" + "\u00f1" + "17160526"; String toEncode = "\u00f1" + "10958" + "\u00f1" + "17160526";
String expected = "1095817160526"; String expected = "1095817160526";
BitMatrix encResult = encode(toEncode, false, expected); BitMatrix encRXingResult = encode(toEncode, false, expected);
int width = encResult.getWidth(); int width = encRXingResult.getWidth();
encResult = encode(toEncode, true, expected); encRXingResult = encode(toEncode, true, expected);
//Compact encoding has one latch less and encodes as STARTA,FNC1,1,CODEC,09,58,FNC1,17,16,05,26 //Compact encoding has one latch less and encodes as STARTA,FNC1,1,CODEC,09,58,FNC1,17,16,05,26
assertEquals(width, encResult.getWidth() + 11); assertEquals(width, encRXingResult.getWidth() + 11);
} }
@Test @Test
@@ -337,23 +337,23 @@ public class Code128WriterTestCase extends Assert {
if (compact) { if (compact) {
hints.put(EncodeHintType.CODE128_COMPACT, Boolean.TRUE); hints.put(EncodeHintType.CODE128_COMPACT, Boolean.TRUE);
} }
BitMatrix encResult = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints); BitMatrix encRXingResult = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0, hints);
if (expectedLoopback != null) { if (expectedLoopback != null) {
BitArray row = encResult.getRow(0, null); BitArray row = encRXingResult.getRow(0, null);
Result rtResult = reader.decodeRow(0, row, null); RXingResult rtRXingResult = reader.decodeRow(0, row, null);
String actual = rtResult.getText(); String actual = rtRXingResult.getText();
assertEquals(expectedLoopback, actual); assertEquals(expectedLoopback, actual);
} }
if (compact) { if (compact) {
//check that what is encoded compactly yields the same on loopback as what was encoded fast. //check that what is encoded compactly yields the same on loopback as what was encoded fast.
BitArray row = encResult.getRow(0, null); BitArray row = encRXingResult.getRow(0, null);
Result rtResult = reader.decodeRow(0, row, null); RXingResult rtRXingResult = reader.decodeRow(0, row, null);
String actual = rtResult.getText(); String actual = rtRXingResult.getText();
BitMatrix encResultFast = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0); BitMatrix encRXingResultFast = writer.encode(toEncode, BarcodeFormat.CODE_128, 0, 0);
row = encResultFast.getRow(0, null); row = encRXingResultFast.getRow(0, null);
rtResult = reader.decodeRow(0, row, null); rtRXingResult = reader.decodeRow(0, row, null);
assertEquals(rtResult.getText(), actual); assertEquals(rtRXingResult.getText(), actual);
} }
return encResult; return encRXingResult;
} }
} }

View File

@@ -24,7 +24,7 @@ import com.google.zxing.common.BitArray;
import com.google.zxing.ChecksumException; import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* @author Michael Jahn * @author Michael Jahn
@@ -44,14 +44,14 @@ public final class Code39ExtendedModeTestCase extends Assert {
"000001001011011010101001001001011001101010101001010010010110101001011010010100100101011010010110100101001001011011010010101001010010010101011001011010010100100101101011001010100101001001010110110010101001010010010101010011011010010100100101101010011010100101001001010110100110101001010010010101011001101010010100100101101010100110100101001001010110101001101001010010010110110101001010010100100101010110100110100101001001011010110100101001010010010101101101001010010100100101010101100110100101001001011010101100101001010010010101101011001010010100100101010110110010100101001001011001010101101001010010010100110101011010010100100101100110101010100101001001010010110101101001010010010110010110101010010100100101001101101010101001001001010110110100101010010010010101010110011010100100100101101010110010101001001001010110101100101010010010010101011011001010010110110100000"); "000001001011011010101001001001011001101010101001010010010110101001011010010100100101011010010110100101001001011011010010101001010010010101011001011010010100100101101011001010100101001001010110110010101001010010010101010011011010010100100101101010011010100101001001010110100110101001010010010101011001101010010100100101101010100110100101001001010110101001101001010010010110110101001010010100100101010110100110100101001001011010110100101001010010010101101101001010010100100101010101100110100101001001011010101100101001010010010101101011001010010100100101010110110010100101001001011001010101101001010010010100110101011010010100100101100110101010100101001001010010110101101001010010010110010110101010010100100101001101101010101001001001010110110100101010010010010101010110011010100100100101101010110010101001001001010110101100101010010010010101011011001010010110110100000");
} }
private static void doTest(String expectedResult, String encodedResult) private static void doTest(String expectedRXingResult, String encodedRXingResult)
throws FormatException, ChecksumException, NotFoundException { throws FormatException, ChecksumException, NotFoundException {
Code39Reader sut = new Code39Reader(false, true); Code39Reader sut = new Code39Reader(false, true);
BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0"); BitMatrix matrix = BitMatrix.parse(encodedRXingResult, "1", "0");
BitArray row = new BitArray(matrix.getWidth()); BitArray row = new BitArray(matrix.getWidth());
matrix.getRow(0, row); matrix.getRow(0, row);
Result result = sut.decodeRow(0, row, null); RXingResult result = sut.decodeRow(0, row, null);
assertEquals(expectedResult, result.getText()); assertEquals(expectedRXingResult, result.getText());
} }
} }

View File

@@ -24,7 +24,7 @@ import com.google.zxing.common.BitArray;
import com.google.zxing.ChecksumException; import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* @author Daisuke Makiuchi * @author Daisuke Makiuchi
@@ -38,14 +38,14 @@ public final class Code93ReaderTestCase extends Assert {
"0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111"); "0000001010111101101000101001100101001011001001100101100101001001100101100100101000010101010000101110101101101010001001001101001101001110010101101011101011011101011101101110100101110101101001110101110110101101010001110110101100010101110110101000110101110110101000101101110110101101001101110110101100101101110110101100110101110110101011011001110110101011001101110110101001101101110110101001110101001100101101010001010111101111");
} }
private static void doTest(String expectedResult, String encodedResult) private static void doTest(String expectedRXingResult, String encodedRXingResult)
throws FormatException, ChecksumException, NotFoundException { throws FormatException, ChecksumException, NotFoundException {
Code93Reader sut = new Code93Reader(); Code93Reader sut = new Code93Reader();
BitMatrix matrix = BitMatrix.parse(encodedResult, "1", "0"); BitMatrix matrix = BitMatrix.parse(encodedRXingResult, "1", "0");
BitArray row = new BitArray(matrix.getWidth()); BitArray row = new BitArray(matrix.getWidth());
matrix.getRow(0, row); matrix.getRow(0, row);
Result result = sut.decodeRow(0, row, null); RXingResult result = sut.decodeRow(0, row, null);
assertEquals(expectedResult, result.getText()); assertEquals(expectedRXingResult, result.getText());
} }
} }

View File

@@ -43,10 +43,10 @@ import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.client.result.ExpandedProductParsedResult; import com.google.zxing.client.result.ExpandedProductParsedRXingResult;
import com.google.zxing.client.result.ParsedResult; import com.google.zxing.client.result.ParsedRXingResult;
import com.google.zxing.client.result.ResultParser; import com.google.zxing.client.result.RXingResultParser;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
import com.google.zxing.common.GlobalHistogramBinarizer; import com.google.zxing.common.GlobalHistogramBinarizer;
@@ -63,18 +63,18 @@ public final class RSSExpandedImage2resultTestCase extends Assert {
@Test @Test
public void testDecodeRow2result2() throws Exception { public void testDecodeRow2result2() throws Exception {
// (01)90012345678908(3103)001750 // (01)90012345678908(3103)001750
ExpandedProductParsedResult expected = ExpandedProductParsedRXingResult expected =
new ExpandedProductParsedResult("(01)90012345678908(3103)001750", new ExpandedProductParsedRXingResult("(01)90012345678908(3103)001750",
"90012345678908", "90012345678908",
null, null, null, null, null, null, null, null, null, null, null, null,
"001750", "001750",
ExpandedProductParsedResult.KILOGRAM, ExpandedProductParsedRXingResult.KILOGRAM,
"3", null, null, null, new HashMap<>()); "3", null, null, null, new HashMap<>());
assertCorrectImage2result("2.png", expected); assertCorrectImage2result("2.png", expected);
} }
private static void assertCorrectImage2result(String fileName, ExpandedProductParsedResult expected) private static void assertCorrectImage2result(String fileName, ExpandedProductParsedRXingResult expected)
throws IOException, NotFoundException { throws IOException, NotFoundException {
Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName); Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);
@@ -83,18 +83,18 @@ public final class RSSExpandedImage2resultTestCase extends Assert {
int rowNumber = binaryMap.getHeight() / 2; int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null); BitArray row = binaryMap.getBlackRow(rowNumber, null);
Result theResult; RXingResult theRXingResult;
try { try {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
theResult = rssExpandedReader.decodeRow(rowNumber, row, null); theRXingResult = rssExpandedReader.decodeRow(rowNumber, row, null);
} catch (ReaderException re) { } catch (ReaderException re) {
fail(re.toString()); fail(re.toString());
return; return;
} }
assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat()); assertSame(BarcodeFormat.RSS_EXPANDED, theRXingResult.getBarcodeFormat());
ParsedResult result = ResultParser.parseResult(theResult); ParsedRXingResult result = RXingResultParser.parseRXingResult(theRXingResult);
assertEquals(expected, result); assertEquals(expected, result);
} }

View File

@@ -37,7 +37,7 @@ import com.google.zxing.BinaryBitmap;
import com.google.zxing.BufferedImageLuminanceSource; import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
import com.google.zxing.common.GlobalHistogramBinarizer; import com.google.zxing.common.GlobalHistogramBinarizer;
@@ -196,7 +196,7 @@ public final class RSSExpandedImage2stringTestCase extends Assert {
int rowNumber = binaryMap.getHeight() / 2; int rowNumber = binaryMap.getHeight() / 2;
BitArray row = binaryMap.getBlackRow(rowNumber, null); BitArray row = binaryMap.getBlackRow(rowNumber, null);
Result result; RXingResult result;
try { try {
RSSExpandedReader rssExpandedReader = new RSSExpandedReader(); RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
result = rssExpandedReader.decodeRow(rowNumber, row, null); result = rssExpandedReader.decodeRow(rowNumber, row, null);

View File

@@ -34,7 +34,7 @@ import org.junit.Test;
import com.google.zxing.BinaryBitmap; import com.google.zxing.BinaryBitmap;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.common.BitArray; import com.google.zxing.common.BitArray;
/** /**
@@ -71,7 +71,7 @@ public final class RSSExpandedStackedInternalTestCase extends Assert {
List<ExpandedPair> totalPairs = rssExpandedReader.decodeRow2pairs(secondRowNumber, secondRow); List<ExpandedPair> totalPairs = rssExpandedReader.decodeRow2pairs(secondRowNumber, secondRow);
Result result = RSSExpandedReader.constructResult(totalPairs); RXingResult result = RSSExpandedReader.constructRXingResult(totalPairs);
assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText()); assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText());
} }
@@ -81,7 +81,7 @@ public final class RSSExpandedStackedInternalTestCase extends Assert {
BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("src/test/resources/blackbox/rssexpandedstacked-2/1000.png"); BinaryBitmap binaryMap = TestCaseUtil.getBinaryBitmap("src/test/resources/blackbox/rssexpandedstacked-2/1000.png");
Result result = rssExpandedReader.decode(binaryMap); RXingResult result = rssExpandedReader.decode(binaryMap);
assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText()); assertEquals("(01)98898765432106(3202)012345(15)991231", result.getText());
} }

View File

@@ -22,11 +22,11 @@ import com.google.zxing.BufferedImageLuminanceSource;
import com.google.zxing.DecodeHintType; import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource; import com.google.zxing.LuminanceSource;
import com.google.zxing.ReaderException; import com.google.zxing.ReaderException;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.ResultMetadataType; import com.google.zxing.RXingResultMetadataType;
import com.google.zxing.common.AbstractBlackBoxTestCase; import com.google.zxing.common.AbstractBlackBoxTestCase;
import com.google.zxing.common.HybridBinarizer; import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.common.TestResult; import com.google.zxing.common.TestRXingResult;
import com.google.zxing.multi.MultipleBarcodeReader; import com.google.zxing.multi.MultipleBarcodeReader;
import org.junit.Test; import org.junit.Test;
@@ -59,20 +59,20 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
private final MultipleBarcodeReader barcodeReader = new PDF417Reader(); private final MultipleBarcodeReader barcodeReader = new PDF417Reader();
private final List<TestResult> testResults = new ArrayList<>(); private final List<TestRXingResult> testRXingResults = new ArrayList<>();
public PDF417BlackBox4TestCase() { public PDF417BlackBox4TestCase() {
super("src/test/resources/blackbox/pdf417-4", null, BarcodeFormat.PDF_417); super("src/test/resources/blackbox/pdf417-4", null, BarcodeFormat.PDF_417);
testResults.add(new TestResult(3, 3, 0, 0, 0.0f)); testRXingResults.add(new TestRXingResult(3, 3, 0, 0, 0.0f));
} }
@Test @Test
@Override @Override
public void testBlackBox() throws IOException { public void testBlackBox() throws IOException {
assertFalse(testResults.isEmpty()); assertFalse(testRXingResults.isEmpty());
Map<String,List<Path>> imageFiles = getImageFileLists(); Map<String,List<Path>> imageFiles = getImageFileLists();
int testCount = testResults.size(); int testCount = testRXingResults.size();
int[] passedCounts = new int[testCount]; int[] passedCounts = new int[testCount];
int[] tryHarderCounts = new int[testCount]; int[] tryHarderCounts = new int[testCount];
@@ -94,10 +94,10 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
} }
for (int x = 0; x < testCount; x++) { for (int x = 0; x < testCount; x++) {
List<Result> results = new ArrayList<>(); List<RXingResult> results = new ArrayList<>();
for (Path imageFile : testImageGroup.getValue()) { for (Path imageFile : testImageGroup.getValue()) {
BufferedImage image = ImageIO.read(imageFile.toFile()); BufferedImage image = ImageIO.read(imageFile.toFile());
float rotation = testResults.get(x).getRotation(); float rotation = testRXingResults.get(x).getRotation();
BufferedImage rotatedImage = rotateImage(image, rotation); BufferedImage rotatedImage = rotateImage(image, rotation);
LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage); LuminanceSource source = new BufferedImageLuminanceSource(rotatedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
@@ -108,11 +108,11 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
// ignore // ignore
} }
} }
results.sort(Comparator.comparingInt((Result r) -> getMeta(r).getSegmentIndex())); results.sort(Comparator.comparingInt((RXingResult r) -> getMeta(r).getSegmentIndex()));
StringBuilder resultText = new StringBuilder(); StringBuilder resultText = new StringBuilder();
String fileId = null; String fileId = null;
for (Result result : results) { for (RXingResult result : results) {
PDF417ResultMetadata resultMetadata = getMeta(result); PDF417RXingResultMetadata resultMetadata = getMeta(result);
assertNotNull("resultMetadata", resultMetadata); assertNotNull("resultMetadata", resultMetadata);
if (fileId == null) { if (fileId == null) {
fileId = resultMetadata.getFileId(); fileId = resultMetadata.getFileId();
@@ -131,15 +131,15 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
int totalMustPass = 0; int totalMustPass = 0;
int numberOfTests = imageFiles.keySet().size(); int numberOfTests = imageFiles.keySet().size();
for (int x = 0; x < testResults.size(); x++) { for (int x = 0; x < testRXingResults.size(); x++) {
TestResult testResult = testResults.get(x); TestRXingResult testRXingResult = testRXingResults.get(x);
log.info(String.format("Rotation %d degrees:", (int) testResult.getRotation())); log.info(String.format("Rotation %d degrees:", (int) testRXingResult.getRotation()));
log.info(String.format(" %d of %d images passed (%d required)", passedCounts[x], numberOfTests, log.info(String.format(" %d of %d images passed (%d required)", passedCounts[x], numberOfTests,
testResult.getMustPassCount())); testRXingResult.getMustPassCount()));
log.info(String.format(" %d of %d images passed with try harder (%d required)", tryHarderCounts[x], log.info(String.format(" %d of %d images passed with try harder (%d required)", tryHarderCounts[x],
numberOfTests, testResult.getTryHarderCount())); numberOfTests, testRXingResult.getTryHarderCount()));
totalFound += passedCounts[x] + tryHarderCounts[x]; totalFound += passedCounts[x] + tryHarderCounts[x];
totalMustPass += testResult.getMustPassCount() + testResult.getTryHarderCount(); totalMustPass += testRXingResult.getMustPassCount() + testRXingResult.getTryHarderCount();
} }
int totalTests = numberOfTests * testCount * 2; int totalTests = numberOfTests * testCount * 2;
@@ -154,19 +154,19 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
// Then run through again and assert if any failed // Then run through again and assert if any failed
for (int x = 0; x < testCount; x++) { for (int x = 0; x < testCount; x++) {
TestResult testResult = testResults.get(x); TestRXingResult testRXingResult = testRXingResults.get(x);
String label = "Rotation " + testResult.getRotation() + " degrees: Too many images failed"; String label = "Rotation " + testRXingResult.getRotation() + " degrees: Too many images failed";
assertTrue(label, passedCounts[x] >= testResult.getMustPassCount()); assertTrue(label, passedCounts[x] >= testRXingResult.getMustPassCount());
assertTrue("Try harder, " + label, tryHarderCounts[x] >= testResult.getTryHarderCount()); assertTrue("Try harder, " + label, tryHarderCounts[x] >= testRXingResult.getTryHarderCount());
} }
} }
private static PDF417ResultMetadata getMeta(Result result) { private static PDF417RXingResultMetadata getMeta(RXingResult result) {
return result.getResultMetadata() == null ? null : (PDF417ResultMetadata) result.getResultMetadata().get( return result.getRXingResultMetadata() == null ? null : (PDF417RXingResultMetadata) result.getRXingResultMetadata().get(
ResultMetadataType.PDF417_EXTRA_METADATA); RXingResultMetadataType.PDF417_EXTRA_METADATA);
} }
private Result[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderException { private RXingResult[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderException {
Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class); Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class);
if (tryHarder) { if (tryHarder) {
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);

View File

@@ -18,8 +18,8 @@ package com.google.zxing.pdf417.decoder;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.WriterException; import com.google.zxing.WriterException;
import com.google.zxing.pdf417.PDF417ResultMetadata; import com.google.zxing.pdf417.PDF417RXingResultMetadata;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.pdf417.encoder.Compaction; import com.google.zxing.pdf417.encoder.Compaction;
import com.google.zxing.pdf417.encoder.PDF417HighLevelEncoderTestAdapter; import com.google.zxing.pdf417.encoder.PDF417HighLevelEncoderTestAdapter;
@@ -39,7 +39,7 @@ public class PDF417DecoderTestCase extends Assert {
*/ */
@Test @Test
public void testStandardSample1() throws FormatException { public void testStandardSample1() throws FormatException {
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
int[] sampleCodes = {20, 928, 111, 100, 17, 53, 923, 1, 111, 104, 923, 3, 64, 416, 34, 923, 4, 258, 446, 67, int[] sampleCodes = {20, 928, 111, 100, 17, 53, 923, 1, 111, 104, 923, 3, 64, 416, 34, 923, 4, 258, 446, 67,
// we should never reach these // we should never reach these
1000, 1000, 1000}; 1000, 1000, 1000};
@@ -66,7 +66,7 @@ public class PDF417DecoderTestCase extends Assert {
*/ */
@Test @Test
public void testStandardSample2() throws FormatException { public void testStandardSample2() throws FormatException {
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
int[] sampleCodes = {11, 928, 111, 103, 17, 53, 923, 1, 111, 104, 922, int[] sampleCodes = {11, 928, 111, 103, 17, 53, 923, 1, 111, 104, 922,
// we should never reach these // we should never reach these
1000, 1000, 1000}; 1000, 1000, 1000};
@@ -93,7 +93,7 @@ public class PDF417DecoderTestCase extends Assert {
*/ */
@Test @Test
public void testStandardSample3() throws FormatException { public void testStandardSample3() throws FormatException {
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
int[] sampleCodes = {7, 928, 111, 100, 100, 200, 300, int[] sampleCodes = {7, 928, 111, 100, 100, 200, 300,
0}; // Final dummy ECC codeword required to avoid ArrayIndexOutOfBounds 0}; // Final dummy ECC codeword required to avoid ArrayIndexOutOfBounds
@@ -108,9 +108,9 @@ public class PDF417DecoderTestCase extends Assert {
assertNull(resultMetadata.getOptionalData()); assertNull(resultMetadata.getOptionalData());
// Check that symbol containing no data except Macro is accepted (see note in Annex H.2) // Check that symbol containing no data except Macro is accepted (see note in Annex H.2)
DecoderResult decoderResult = DecodedBitStreamParser.decode(sampleCodes, "0"); DecoderRXingResult decoderRXingResult = DecodedBitStreamParser.decode(sampleCodes, "0");
assertEquals("", decoderResult.getText()); assertEquals("", decoderRXingResult.getText());
assertNotNull(decoderResult.getOther()); assertNotNull(decoderRXingResult.getOther());
} }
@Test @Test
@@ -118,7 +118,7 @@ public class PDF417DecoderTestCase extends Assert {
int[] sampleCodes = {23, 477, 928, 111, 100, 0, 252, 21, 86, 923, 0, 815, 251, 133, 12, 148, 537, 593, int[] sampleCodes = {23, 477, 928, 111, 100, 0, 252, 21, 86, 923, 0, 815, 251, 133, 12, 148, 537, 593,
599, 923, 1, 111, 102, 98, 311, 355, 522, 920, 779, 40, 628, 33, 749, 267, 506, 213, 928, 465, 248, 599, 923, 1, 111, 102, 98, 311, 355, 522, 920, 779, 40, 628, 33, 749, 267, 506, 213, 928, 465, 248,
493, 72, 780, 699, 780, 493, 755, 84, 198, 628, 368, 156, 198, 809, 19, 113}; 493, 72, 780, 699, 780, 493, 755, 84, 198, 628, 368, 156, 198, 809, 19, 113};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata); DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata);
@@ -135,7 +135,7 @@ public class PDF417DecoderTestCase extends Assert {
public void testSampleWithNumericValues() throws FormatException { public void testSampleWithNumericValues() throws FormatException {
int[] sampleCodes = {25, 477, 928, 111, 100, 0, 252, 21, 86, 923, 2, 2, 0, 1, 0, 0, 0, 923, 5, 130, 923, int[] sampleCodes = {25, 477, 928, 111, 100, 0, 252, 21, 86, 923, 2, 2, 0, 1, 0, 0, 0, 923, 5, 130, 923,
6, 1, 500, 13, 0}; 6, 1, 500, 13, 0};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata); DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata);
@@ -151,7 +151,7 @@ public class PDF417DecoderTestCase extends Assert {
@Test @Test
public void testSampleWithMacroTerminatorOnly() throws FormatException { public void testSampleWithMacroTerminatorOnly() throws FormatException {
int[] sampleCodes = {7, 477, 928, 222, 198, 0, 922}; int[] sampleCodes = {7, 477, 928, 222, 198, 0, 922};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata); DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 3, resultMetadata);
@@ -165,14 +165,14 @@ public class PDF417DecoderTestCase extends Assert {
@Test(expected = FormatException.class) @Test(expected = FormatException.class)
public void testSampleWithBadSequenceIndexMacro() throws FormatException { public void testSampleWithBadSequenceIndexMacro() throws FormatException {
int[] sampleCodes = {3, 928, 222, 0}; int[] sampleCodes = {3, 928, 222, 0};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata); DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata);
} }
@Test(expected = FormatException.class) @Test(expected = FormatException.class)
public void testSampleWithNoFileIdMacro() throws FormatException { public void testSampleWithNoFileIdMacro() throws FormatException {
int[] sampleCodes = {4, 928, 222, 198, 0}; int[] sampleCodes = {4, 928, 222, 198, 0};
PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); PDF417RXingResultMetadata resultMetadata = new PDF417RXingResultMetadata();
DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata); DecodedBitStreamParser.decodeMacroBlock(sampleCodes, 2, resultMetadata);
} }
@@ -405,9 +405,9 @@ public class PDF417DecoderTestCase extends Assert {
} }
} }
private static void performDecodeTest(int[] codewords, String expectedResult) throws FormatException { private static void performDecodeTest(int[] codewords, String expectedRXingResult) throws FormatException {
DecoderResult result = DecodedBitStreamParser.decode(codewords, "0"); DecoderRXingResult result = DecodedBitStreamParser.decode(codewords, "0");
assertEquals(expectedResult, result.getText()); assertEquals(expectedRXingResult, result.getText());
} }
private static void performECITest(char[] chars, private static void performECITest(char[] chars,

View File

@@ -110,18 +110,18 @@ public final class QRCodeWriterTestCase extends Assert {
BufferedImage image = loadImage(fileName); BufferedImage image = loadImage(fileName);
assertNotNull(image); assertNotNull(image);
BitMatrix goldenResult = createMatrixFromImage(image); BitMatrix goldenRXingResult = createMatrixFromImage(image);
assertNotNull(goldenResult); assertNotNull(goldenRXingResult);
Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class); Map<EncodeHintType,Object> hints = new EnumMap<>(EncodeHintType.class);
hints.put(EncodeHintType.ERROR_CORRECTION, ecLevel); hints.put(EncodeHintType.ERROR_CORRECTION, ecLevel);
Writer writer = new QRCodeWriter(); Writer writer = new QRCodeWriter();
BitMatrix generatedResult = writer.encode(contents, BarcodeFormat.QR_CODE, resolution, BitMatrix generatedRXingResult = writer.encode(contents, BarcodeFormat.QR_CODE, resolution,
resolution, hints); resolution, hints);
assertEquals(resolution, generatedResult.getWidth()); assertEquals(resolution, generatedRXingResult.getWidth());
assertEquals(resolution, generatedResult.getHeight()); assertEquals(resolution, generatedRXingResult.getHeight());
assertEquals(goldenResult, generatedResult); assertEquals(goldenRXingResult, generatedRXingResult);
} }
// Golden images are generated with "qrcode_sample.cc". The images are checked with both eye balls // Golden images are generated with "qrcode_sample.cc". The images are checked with both eye balls

View File

@@ -905,11 +905,11 @@ public final class EncoderTestCase extends Assert {
".a.a.)", null, false); ".a.a.)", null, false);
} }
static void verifyMinimalEncoding(String input, String expectedResult, Charset priorityCharset, boolean isGS1) static void verifyMinimalEncoding(String input, String expectedRXingResult, Charset priorityCharset, boolean isGS1)
throws Exception { throws Exception {
MinimalEncoder.ResultList result = MinimalEncoder.encode(input, null, priorityCharset, isGS1, MinimalEncoder.RXingResultList result = MinimalEncoder.encode(input, null, priorityCharset, isGS1,
ErrorCorrectionLevel.L); ErrorCorrectionLevel.L);
assertEquals(result.toString(), expectedResult); assertEquals(result.toString(), expectedRXingResult);
} }
private static void verifyGS1EncodedData(QRCode qrCode) { private static void verifyGS1EncodedData(QRCode qrCode) {

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -1 +1 @@
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIResultHandler.java http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/result/URIRXingResultHandler.java

View File

@@ -83,10 +83,10 @@ public enum DecodeHintType {
RETURN_CODABAR_START_END(Void.class), RETURN_CODABAR_START_END(Void.class),
/** /**
* The caller needs to be notified via callback when a possible {@link ResultPoint} * The caller needs to be notified via callback when a possible {@link RXingResultPoint}
* is found. Maps to a {@link ResultPointCallback}. * is found. Maps to a {@link RXingResultPointCallback}.
*/ */
NEED_RESULT_POINT_CALLBACK(ResultPointCallback.class), NEED_RESULT_POINT_CALLBACK(RXingResultPointCallback.class),
/** /**

View File

@@ -52,7 +52,7 @@ public final class MultiFormatReader implements Reader {
* @throws NotFoundException Any errors which occurred * @throws NotFoundException Any errors which occurred
*/ */
@Override @Override
public Result decode(BinaryBitmap image) throws NotFoundException { public RXingResult decode(BinaryBitmap image) throws NotFoundException {
setHints(null); setHints(null);
return decodeInternal(image); return decodeInternal(image);
} }
@@ -66,7 +66,7 @@ public final class MultiFormatReader implements Reader {
* @throws NotFoundException Any errors which occurred * @throws NotFoundException Any errors which occurred
*/ */
@Override @Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException { public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints) throws NotFoundException {
setHints(hints); setHints(hints);
return decodeInternal(image); return decodeInternal(image);
} }
@@ -79,7 +79,7 @@ public final class MultiFormatReader implements Reader {
* @return The contents of the image * @return The contents of the image
* @throws NotFoundException Any errors which occurred * @throws NotFoundException Any errors which occurred
*/ */
public Result decodeWithState(BinaryBitmap image) throws NotFoundException { public RXingResult decodeWithState(BinaryBitmap image) throws NotFoundException {
// Make sure to set up the default state so we don't crash // Make sure to set up the default state so we don't crash
if (readers == null) { if (readers == null) {
setHints(null); setHints(null);
@@ -166,7 +166,7 @@ public final class MultiFormatReader implements Reader {
} }
} }
private Result decodeInternal(BinaryBitmap image) throws NotFoundException { private RXingResult decodeInternal(BinaryBitmap image) throws NotFoundException {
if (readers != null) { if (readers != null) {
for (Reader reader : readers) { for (Reader reader : readers) {
if (Thread.currentThread().isInterrupted()) { if (Thread.currentThread().isInterrupted()) {

View File

@@ -41,7 +41,7 @@ public interface Reader {
* @throws ChecksumException if a potential barcode is found but does not pass its checksum * @throws ChecksumException if a potential barcode is found but does not pass its checksum
* @throws FormatException if a potential barcode is found but format is invalid * @throws FormatException if a potential barcode is found but format is invalid
*/ */
Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException; RXingResult decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException;
/** /**
* Locates and decodes a barcode in some format within an image. This method also accepts * Locates and decodes a barcode in some format within an image. This method also accepts
@@ -57,7 +57,7 @@ public interface Reader {
* @throws ChecksumException if a potential barcode is found but does not pass its checksum * @throws ChecksumException if a potential barcode is found but does not pass its checksum
* @throws FormatException if a potential barcode is found but format is invalid * @throws FormatException if a potential barcode is found but format is invalid
*/ */
Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
throws NotFoundException, ChecksumException, FormatException; throws NotFoundException, ChecksumException, FormatException;
/** /**

View File

@@ -24,36 +24,36 @@ import java.util.Map;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class Result { public final class RXingResult {
private final String text; private final String text;
private final byte[] rawBytes; private final byte[] rawBytes;
private final int numBits; private final int numBits;
private ResultPoint[] resultPoints; private RXingResultPoint[] resultPoints;
private final BarcodeFormat format; private final BarcodeFormat format;
private Map<ResultMetadataType,Object> resultMetadata; private Map<RXingResultMetadataType,Object> resultMetadata;
private final long timestamp; private final long timestamp;
public Result(String text, public RXingResult(String text,
byte[] rawBytes, byte[] rawBytes,
ResultPoint[] resultPoints, RXingResultPoint[] resultPoints,
BarcodeFormat format) { BarcodeFormat format) {
this(text, rawBytes, resultPoints, format, System.currentTimeMillis()); this(text, rawBytes, resultPoints, format, System.currentTimeMillis());
} }
public Result(String text, public RXingResult(String text,
byte[] rawBytes, byte[] rawBytes,
ResultPoint[] resultPoints, RXingResultPoint[] resultPoints,
BarcodeFormat format, BarcodeFormat format,
long timestamp) { long timestamp) {
this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.length, this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.length,
resultPoints, format, timestamp); resultPoints, format, timestamp);
} }
public Result(String text, public RXingResult(String text,
byte[] rawBytes, byte[] rawBytes,
int numBits, int numBits,
ResultPoint[] resultPoints, RXingResultPoint[] resultPoints,
BarcodeFormat format, BarcodeFormat format,
long timestamp) { long timestamp) {
this.text = text; this.text = text;
@@ -92,7 +92,7 @@ public final class Result {
* identifying finder patterns or the corners of the barcode. The exact meaning is * identifying finder patterns or the corners of the barcode. The exact meaning is
* specific to the type of barcode that was decoded. * specific to the type of barcode that was decoded.
*/ */
public ResultPoint[] getResultPoints() { public RXingResultPoint[] getRXingResultPoints() {
return resultPoints; return resultPoints;
} }
@@ -104,22 +104,22 @@ public final class Result {
} }
/** /**
* @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be * @return {@link Map} mapping {@link RXingResultMetadataType} keys to values. May be
* {@code null}. This contains optional metadata about what was detected about the barcode, * {@code null}. This contains optional metadata about what was detected about the barcode,
* like orientation. * like orientation.
*/ */
public Map<ResultMetadataType,Object> getResultMetadata() { public Map<RXingResultMetadataType,Object> getRXingResultMetadata() {
return resultMetadata; return resultMetadata;
} }
public void putMetadata(ResultMetadataType type, Object value) { public void putMetadata(RXingResultMetadataType type, Object value) {
if (resultMetadata == null) { if (resultMetadata == null) {
resultMetadata = new EnumMap<>(ResultMetadataType.class); resultMetadata = new EnumMap<>(RXingResultMetadataType.class);
} }
resultMetadata.put(type, value); resultMetadata.put(type, value);
} }
public void putAllMetadata(Map<ResultMetadataType,Object> metadata) { public void putAllMetadata(Map<RXingResultMetadataType,Object> metadata) {
if (metadata != null) { if (metadata != null) {
if (resultMetadata == null) { if (resultMetadata == null) {
resultMetadata = metadata; resultMetadata = metadata;
@@ -129,12 +129,12 @@ public final class Result {
} }
} }
public void addResultPoints(ResultPoint[] newPoints) { public void addRXingResultPoints(RXingResultPoint[] newPoints) {
ResultPoint[] oldPoints = resultPoints; RXingResultPoint[] oldPoints = resultPoints;
if (oldPoints == null) { if (oldPoints == null) {
resultPoints = newPoints; resultPoints = newPoints;
} else if (newPoints != null && newPoints.length > 0) { } else if (newPoints != null && newPoints.length > 0) {
ResultPoint[] allPoints = new ResultPoint[oldPoints.length + newPoints.length]; RXingResultPoint[] allPoints = new RXingResultPoint[oldPoints.length + newPoints.length];
System.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length); System.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length);
System.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length); System.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length);
resultPoints = allPoints; resultPoints = allPoints;

View File

@@ -22,7 +22,7 @@ package com.google.zxing;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public enum ResultMetadataType { public enum RXingResultMetadataType {
/** /**
* Unspecified, application-specific metadata. Maps to an unspecified {@link Object}. * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
@@ -40,7 +40,7 @@ public enum ResultMetadataType {
/** /**
* <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode' * <p>2D barcode formats typically encode text, but allow for a sort of 'byte mode'
* which is sometimes used to encode binary data. While {@link Result} makes available * which is sometimes used to encode binary data. While {@link RXingResult} makes available
* the complete raw bytes in the barcode for these formats, it does not offer the bytes * the complete raw bytes in the barcode for these formats, it does not offer the bytes
* from the byte segments alone.</p> * from the byte segments alone.</p>
* *

View File

@@ -24,12 +24,12 @@ import com.google.zxing.common.detector.MathUtils;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public class ResultPoint { public class RXingResultPoint {
private final float x; private final float x;
private final float y; private final float y;
public ResultPoint(float x, float y) { public RXingResultPoint(float x, float y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
@@ -44,8 +44,8 @@ public class ResultPoint {
@Override @Override
public final boolean equals(Object other) { public final boolean equals(Object other) {
if (other instanceof ResultPoint) { if (other instanceof RXingResultPoint) {
ResultPoint otherPoint = (ResultPoint) other; RXingResultPoint otherPoint = (RXingResultPoint) other;
return x == otherPoint.x && y == otherPoint.y; return x == otherPoint.x && y == otherPoint.y;
} }
return false; return false;
@@ -62,21 +62,21 @@ public class ResultPoint {
} }
/** /**
* Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC * Orders an array of three RXingResultPoints in an order [A,B,C] such that AB is less than AC
* and BC is less than AC, and the angle between BC and BA is less than 180 degrees. * and BC is less than AC, and the angle between BC and BA is less than 180 degrees.
* *
* @param patterns array of three {@code ResultPoint} to order * @param patterns array of three {@code RXingResultPoint} to order
*/ */
public static void orderBestPatterns(ResultPoint[] patterns) { public static void orderBestPatterns(RXingResultPoint[] patterns) {
// Find distances between pattern centers // Find distances between pattern centers
float zeroOneDistance = distance(patterns[0], patterns[1]); float zeroOneDistance = distance(patterns[0], patterns[1]);
float oneTwoDistance = distance(patterns[1], patterns[2]); float oneTwoDistance = distance(patterns[1], patterns[2]);
float zeroTwoDistance = distance(patterns[0], patterns[2]); float zeroTwoDistance = distance(patterns[0], patterns[2]);
ResultPoint pointA; RXingResultPoint pointA;
ResultPoint pointB; RXingResultPoint pointB;
ResultPoint pointC; RXingResultPoint pointC;
// Assume one closest to other two is B; A and C will just be guesses at first // Assume one closest to other two is B; A and C will just be guesses at first
if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) { if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
pointB = patterns[0]; pointB = patterns[0];
@@ -97,7 +97,7 @@ public class ResultPoint {
// we want for A, B, C. If it's negative, then we've got it flipped around and // we want for A, B, C. If it's negative, then we've got it flipped around and
// should swap A and C. // should swap A and C.
if (crossProductZ(pointA, pointB, pointC) < 0.0f) { if (crossProductZ(pointA, pointB, pointC) < 0.0f) {
ResultPoint temp = pointA; RXingResultPoint temp = pointA;
pointA = pointC; pointA = pointC;
pointC = temp; pointC = temp;
} }
@@ -112,16 +112,16 @@ public class ResultPoint {
* @param pattern2 second pattern * @param pattern2 second pattern
* @return distance between two points * @return distance between two points
*/ */
public static float distance(ResultPoint pattern1, ResultPoint pattern2) { public static float distance(RXingResultPoint pattern1, RXingResultPoint pattern2) {
return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y); return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y);
} }
/** /**
* Returns the z component of the cross product between vectors BC and BA. * Returns the z component of the cross product between vectors BC and BA.
*/ */
private static float crossProductZ(ResultPoint pointA, private static float crossProductZ(RXingResultPoint pointA,
ResultPoint pointB, RXingResultPoint pointB,
ResultPoint pointC) { RXingResultPoint pointC) {
float bX = pointB.x; float bX = pointB.x;
float bY = pointB.y; float bY = pointB.y;
return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX)); return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));

View File

@@ -22,8 +22,8 @@ package com.google.zxing;
* *
* @see DecodeHintType#NEED_RESULT_POINT_CALLBACK * @see DecodeHintType#NEED_RESULT_POINT_CALLBACK
*/ */
public interface ResultPointCallback { public interface RXingResultPointCallback {
void foundPossibleResultPoint(ResultPoint point); void foundPossibleRXingResultPoint(RXingResultPoint point);
} }

View File

@@ -16,24 +16,24 @@
package com.google.zxing.aztec; package com.google.zxing.aztec;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DetectorResult; import com.google.zxing.common.DetectorRXingResult;
/** /**
* <p>Extends {@link DetectorResult} with more information specific to the Aztec format, * <p>Extends {@link DetectorRXingResult} with more information specific to the Aztec format,
* like the number of layers and whether it's compact.</p> * like the number of layers and whether it's compact.</p>
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class AztecDetectorResult extends DetectorResult { public final class AztecDetectorRXingResult extends DetectorRXingResult {
private final boolean compact; private final boolean compact;
private final int nbDatablocks; private final int nbDatablocks;
private final int nbLayers; private final int nbLayers;
public AztecDetectorResult(BitMatrix bits, public AztecDetectorRXingResult(BitMatrix bits,
ResultPoint[] points, RXingResultPoint[] points,
boolean compact, boolean compact,
int nbDatablocks, int nbDatablocks,
int nbLayers) { int nbLayers) {

View File

@@ -22,13 +22,13 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.Reader; import com.google.zxing.Reader;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.ResultMetadataType; import com.google.zxing.RXingResultMetadataType;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.ResultPointCallback; import com.google.zxing.RXingResultPointCallback;
import com.google.zxing.aztec.decoder.Decoder; import com.google.zxing.aztec.decoder.Decoder;
import com.google.zxing.aztec.detector.Detector; import com.google.zxing.aztec.detector.Detector;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -48,33 +48,33 @@ public final class AztecReader implements Reader {
* @throws FormatException if a Data Matrix code cannot be decoded * @throws FormatException if a Data Matrix code cannot be decoded
*/ */
@Override @Override
public Result decode(BinaryBitmap image) throws NotFoundException, FormatException { public RXingResult decode(BinaryBitmap image) throws NotFoundException, FormatException {
return decode(image, null); return decode(image, null);
} }
@Override @Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
throws NotFoundException, FormatException { throws NotFoundException, FormatException {
NotFoundException notFoundException = null; NotFoundException notFoundException = null;
FormatException formatException = null; FormatException formatException = null;
Detector detector = new Detector(image.getBlackMatrix()); Detector detector = new Detector(image.getBlackMatrix());
ResultPoint[] points = null; RXingResultPoint[] points = null;
DecoderResult decoderResult = null; DecoderRXingResult decoderRXingResult = null;
try { try {
AztecDetectorResult detectorResult = detector.detect(false); AztecDetectorRXingResult detectorRXingResult = detector.detect(false);
points = detectorResult.getPoints(); points = detectorRXingResult.getPoints();
decoderResult = new Decoder().decode(detectorResult); decoderRXingResult = new Decoder().decode(detectorRXingResult);
} catch (NotFoundException e) { } catch (NotFoundException e) {
notFoundException = e; notFoundException = e;
} catch (FormatException e) { } catch (FormatException e) {
formatException = e; formatException = e;
} }
if (decoderResult == null) { if (decoderRXingResult == null) {
try { try {
AztecDetectorResult detectorResult = detector.detect(true); AztecDetectorRXingResult detectorRXingResult = detector.detect(true);
points = detectorResult.getPoints(); points = detectorRXingResult.getPoints();
decoderResult = new Decoder().decode(detectorResult); decoderRXingResult = new Decoder().decode(detectorRXingResult);
} catch (NotFoundException | FormatException e) { } catch (NotFoundException | FormatException e) {
if (notFoundException != null) { if (notFoundException != null) {
throw notFoundException; throw notFoundException;
@@ -87,30 +87,30 @@ public final class AztecReader implements Reader {
} }
if (hints != null) { if (hints != null) {
ResultPointCallback rpcb = (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK); RXingResultPointCallback rpcb = (RXingResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
if (rpcb != null) { if (rpcb != null) {
for (ResultPoint point : points) { for (RXingResultPoint point : points) {
rpcb.foundPossibleResultPoint(point); rpcb.foundPossibleRXingResultPoint(point);
} }
} }
} }
Result result = new Result(decoderResult.getText(), RXingResult result = new RXingResult(decoderRXingResult.getText(),
decoderResult.getRawBytes(), decoderRXingResult.getRawBytes(),
decoderResult.getNumBits(), decoderRXingResult.getNumBits(),
points, points,
BarcodeFormat.AZTEC, BarcodeFormat.AZTEC,
System.currentTimeMillis()); System.currentTimeMillis());
List<byte[]> byteSegments = decoderResult.getByteSegments(); List<byte[]> byteSegments = decoderRXingResult.getByteSegments();
if (byteSegments != null) { if (byteSegments != null) {
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); result.putMetadata(RXingResultMetadataType.BYTE_SEGMENTS, byteSegments);
} }
String ecLevel = decoderResult.getECLevel(); String ecLevel = decoderRXingResult.getECLevel();
if (ecLevel != null) { if (ecLevel != null) {
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
} }
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]z" + decoderResult.getSymbologyModifier()); result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]z" + decoderRXingResult.getSymbologyModifier());
return result; return result;
} }

View File

@@ -62,10 +62,10 @@ public final class AztecWriter implements Writer {
throw new IllegalArgumentException("Can only encode AZTEC, but got " + format); throw new IllegalArgumentException("Can only encode AZTEC, but got " + format);
} }
AztecCode aztec = Encoder.encode(contents, eccPercent, layers, charset); AztecCode aztec = Encoder.encode(contents, eccPercent, layers, charset);
return renderResult(aztec, width, height); return renderRXingResult(aztec, width, height);
} }
private static BitMatrix renderResult(AztecCode code, int width, int height) { private static BitMatrix renderRXingResult(AztecCode code, int width, int height) {
BitMatrix input = code.getMatrix(); BitMatrix input = code.getMatrix();
if (input == null) { if (input == null) {
throw new IllegalStateException(); throw new IllegalStateException();

View File

@@ -17,10 +17,10 @@
package com.google.zxing.aztec.decoder; package com.google.zxing.aztec.decoder;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.aztec.AztecDetectorResult; import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.CharacterSetECI; import com.google.zxing.common.CharacterSetECI;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.common.reedsolomon.GenericGF; import com.google.zxing.common.reedsolomon.GenericGF;
import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
import com.google.zxing.common.reedsolomon.ReedSolomonException; import com.google.zxing.common.reedsolomon.ReedSolomonException;
@@ -75,19 +75,19 @@ public final class Decoder {
private static final Charset DEFAULT_ENCODING = StandardCharsets.ISO_8859_1; private static final Charset DEFAULT_ENCODING = StandardCharsets.ISO_8859_1;
private AztecDetectorResult ddata; private AztecDetectorRXingResult ddata;
public DecoderResult decode(AztecDetectorResult detectorResult) throws FormatException { public DecoderRXingResult decode(AztecDetectorRXingResult detectorRXingResult) throws FormatException {
ddata = detectorResult; ddata = detectorRXingResult;
BitMatrix matrix = detectorResult.getBits(); BitMatrix matrix = detectorRXingResult.getBits();
boolean[] rawbits = extractBits(matrix); boolean[] rawbits = extractBits(matrix);
CorrectedBitsResult correctedBits = correctBits(rawbits); CorrectedBitsRXingResult correctedBits = correctBits(rawbits);
byte[] rawBytes = convertBoolArrayToByteArray(correctedBits.correctBits); byte[] rawBytes = convertBoolArrayToByteArray(correctedBits.correctBits);
String result = getEncodedData(correctedBits.correctBits); String result = getEncodedData(correctedBits.correctBits);
DecoderResult decoderResult = DecoderRXingResult decoderRXingResult =
new DecoderResult(rawBytes, result, null, String.format("%d%%", correctedBits.ecLevel)); new DecoderRXingResult(rawBytes, result, null, String.format("%d%%", correctedBits.ecLevel));
decoderResult.setNumBits(correctedBits.correctBits.length); decoderRXingResult.setNumBits(correctedBits.correctBits.length);
return decoderResult; return decoderRXingResult;
} }
// This method is used for testing the high-level encoder // This method is used for testing the high-level encoder
@@ -262,11 +262,11 @@ public final class Decoder {
} }
} }
static final class CorrectedBitsResult { static final class CorrectedBitsRXingResult {
private final boolean[] correctBits; private final boolean[] correctBits;
private final int ecLevel; private final int ecLevel;
CorrectedBitsResult(boolean[] correctBits, int ecLevel) { CorrectedBitsRXingResult(boolean[] correctBits, int ecLevel) {
this.correctBits = correctBits; this.correctBits = correctBits;
this.ecLevel = ecLevel; this.ecLevel = ecLevel;
} }
@@ -278,7 +278,7 @@ public final class Decoder {
* @return the corrected array * @return the corrected array
* @throws FormatException if the input contains too many errors * @throws FormatException if the input contains too many errors
*/ */
private CorrectedBitsResult correctBits(boolean[] rawbits) throws FormatException { private CorrectedBitsRXingResult correctBits(boolean[] rawbits) throws FormatException {
GenericGF gf; GenericGF gf;
int codewordSize; int codewordSize;
@@ -343,7 +343,7 @@ public final class Decoder {
} }
} }
return new CorrectedBitsResult(correctedBits, 100 * (numCodewords - numDataCodewords) / numCodewords); return new CorrectedBitsRXingResult(correctedBits, 100 * (numCodewords - numDataCodewords) / numCodewords);
} }
/** /**

View File

@@ -17,8 +17,8 @@
package com.google.zxing.aztec.detector; package com.google.zxing.aztec.detector;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.aztec.AztecDetectorResult; import com.google.zxing.aztec.AztecDetectorRXingResult;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.GridSampler; import com.google.zxing.common.GridSampler;
import com.google.zxing.common.detector.MathUtils; import com.google.zxing.common.detector.MathUtils;
@@ -55,7 +55,7 @@ public final class Detector {
this.image = image; this.image = image;
} }
public AztecDetectorResult detect() throws NotFoundException { public AztecDetectorRXingResult detect() throws NotFoundException {
return detect(false); return detect(false);
} }
@@ -63,20 +63,20 @@ public final class Detector {
* Detects an Aztec Code in an image. * Detects an Aztec Code in an image.
* *
* @param isMirror if true, image is a mirror-image of original * @param isMirror if true, image is a mirror-image of original
* @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code * @return {@link AztecDetectorRXingResult} encapsulating results of detecting an Aztec Code
* @throws NotFoundException if no Aztec Code can be found * @throws NotFoundException if no Aztec Code can be found
*/ */
public AztecDetectorResult detect(boolean isMirror) throws NotFoundException { public AztecDetectorRXingResult detect(boolean isMirror) throws NotFoundException {
// 1. Get the center of the aztec matrix // 1. Get the center of the aztec matrix
Point pCenter = getMatrixCenter(); Point pCenter = getMatrixCenter();
// 2. Get the center points of the four diagonal points just outside the bull's eye // 2. Get the center points of the four diagonal points just outside the bull's eye
// [topRight, bottomRight, bottomLeft, topLeft] // [topRight, bottomRight, bottomLeft, topLeft]
ResultPoint[] bullsEyeCorners = getBullsEyeCorners(pCenter); RXingResultPoint[] bullsEyeCorners = getBullsEyeCorners(pCenter);
if (isMirror) { if (isMirror) {
ResultPoint temp = bullsEyeCorners[0]; RXingResultPoint temp = bullsEyeCorners[0];
bullsEyeCorners[0] = bullsEyeCorners[2]; bullsEyeCorners[0] = bullsEyeCorners[2];
bullsEyeCorners[2] = temp; bullsEyeCorners[2] = temp;
} }
@@ -92,9 +92,9 @@ public final class Detector {
bullsEyeCorners[(shift + 3) % 4]); bullsEyeCorners[(shift + 3) % 4]);
// 5. Get the corners of the matrix. // 5. Get the corners of the matrix.
ResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners); RXingResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners);
return new AztecDetectorResult(bits, corners, compact, nbDataBlocks, nbLayers); return new AztecDetectorRXingResult(bits, corners, compact, nbDataBlocks, nbLayers);
} }
/** /**
@@ -103,7 +103,7 @@ public final class Detector {
* @param bullsEyeCorners the array of bull's eye corners * @param bullsEyeCorners the array of bull's eye corners
* @throws NotFoundException in case of too many errors or invalid parameters * @throws NotFoundException in case of too many errors or invalid parameters
*/ */
private void extractParameters(ResultPoint[] bullsEyeCorners) throws NotFoundException { private void extractParameters(RXingResultPoint[] bullsEyeCorners) throws NotFoundException {
if (!isValid(bullsEyeCorners[0]) || !isValid(bullsEyeCorners[1]) || if (!isValid(bullsEyeCorners[0]) || !isValid(bullsEyeCorners[1]) ||
!isValid(bullsEyeCorners[2]) || !isValid(bullsEyeCorners[3])) { !isValid(bullsEyeCorners[2]) || !isValid(bullsEyeCorners[3])) {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
@@ -232,7 +232,7 @@ public final class Detector {
* @return The corners of the bull-eye * @return The corners of the bull-eye
* @throws NotFoundException If no valid bull-eye can be found * @throws NotFoundException If no valid bull-eye can be found
*/ */
private ResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException { private RXingResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException {
Point pina = pCenter; Point pina = pCenter;
Point pinb = pCenter; Point pinb = pCenter;
@@ -274,14 +274,14 @@ public final class Detector {
// Expand the square by .5 pixel in each direction so that we're on the border // Expand the square by .5 pixel in each direction so that we're on the border
// between the white square and the black square // between the white square and the black square
ResultPoint pinax = new ResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f); RXingResultPoint pinax = new RXingResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f);
ResultPoint pinbx = new ResultPoint(pinb.getX() + 0.5f, pinb.getY() + 0.5f); RXingResultPoint pinbx = new RXingResultPoint(pinb.getX() + 0.5f, pinb.getY() + 0.5f);
ResultPoint pincx = new ResultPoint(pinc.getX() - 0.5f, pinc.getY() + 0.5f); RXingResultPoint pincx = new RXingResultPoint(pinc.getX() - 0.5f, pinc.getY() + 0.5f);
ResultPoint pindx = new ResultPoint(pind.getX() - 0.5f, pind.getY() - 0.5f); RXingResultPoint pindx = new RXingResultPoint(pind.getX() - 0.5f, pind.getY() - 0.5f);
// Expand the square so that its corners are the centers of the points // Expand the square so that its corners are the centers of the points
// just outside the bull's eye. // just outside the bull's eye.
return expandSquare(new ResultPoint[]{pinax, pinbx, pincx, pindx}, return expandSquare(new RXingResultPoint[]{pinax, pinbx, pincx, pindx},
2 * nbCenterLayers - 3, 2 * nbCenterLayers - 3,
2 * nbCenterLayers); 2 * nbCenterLayers);
} }
@@ -293,15 +293,15 @@ public final class Detector {
*/ */
private Point getMatrixCenter() { private Point getMatrixCenter() {
ResultPoint pointA; RXingResultPoint pointA;
ResultPoint pointB; RXingResultPoint pointB;
ResultPoint pointC; RXingResultPoint pointC;
ResultPoint pointD; RXingResultPoint pointD;
//Get a white rectangle that can be the border of the matrix in center bull's eye or //Get a white rectangle that can be the border of the matrix in center bull's eye or
try { try {
ResultPoint[] cornerPoints = new WhiteRectangleDetector(image).detect(); RXingResultPoint[] cornerPoints = new WhiteRectangleDetector(image).detect();
pointA = cornerPoints[0]; pointA = cornerPoints[0];
pointB = cornerPoints[1]; pointB = cornerPoints[1];
pointC = cornerPoints[2]; pointC = cornerPoints[2];
@@ -313,10 +313,10 @@ public final class Detector {
// In that case, surely in the bull's eye, we try to expand the rectangle. // In that case, surely in the bull's eye, we try to expand the rectangle.
int cx = image.getWidth() / 2; int cx = image.getWidth() / 2;
int cy = image.getHeight() / 2; int cy = image.getHeight() / 2;
pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint(); pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toRXingResultPoint();
pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint(); pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toRXingResultPoint();
pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint(); pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toRXingResultPoint();
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toRXingResultPoint();
} }
@@ -328,7 +328,7 @@ public final class Detector {
// This will ensure that we end up with a white rectangle in center bull's eye // This will ensure that we end up with a white rectangle in center bull's eye
// in order to compute a more accurate center. // in order to compute a more accurate center.
try { try {
ResultPoint[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect(); RXingResultPoint[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect();
pointA = cornerPoints[0]; pointA = cornerPoints[0];
pointB = cornerPoints[1]; pointB = cornerPoints[1];
pointC = cornerPoints[2]; pointC = cornerPoints[2];
@@ -336,10 +336,10 @@ public final class Detector {
} catch (NotFoundException e) { } catch (NotFoundException e) {
// This exception can be in case the initial rectangle is white // This exception can be in case the initial rectangle is white
// In that case we try to expand the rectangle. // In that case we try to expand the rectangle.
pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint(); pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toRXingResultPoint();
pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint(); pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toRXingResultPoint();
pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint(); pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toRXingResultPoint();
pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint(); pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toRXingResultPoint();
} }
// Recompute the center of the rectangle // Recompute the center of the rectangle
@@ -355,7 +355,7 @@ public final class Detector {
* @param bullsEyeCorners the array of bull's eye corners * @param bullsEyeCorners the array of bull's eye corners
* @return the array of aztec code corners * @return the array of aztec code corners
*/ */
private ResultPoint[] getMatrixCornerPoints(ResultPoint[] bullsEyeCorners) { private RXingResultPoint[] getMatrixCornerPoints(RXingResultPoint[] bullsEyeCorners) {
return expandSquare(bullsEyeCorners, 2 * nbCenterLayers, getDimension()); return expandSquare(bullsEyeCorners, 2 * nbCenterLayers, getDimension());
} }
@@ -365,10 +365,10 @@ public final class Detector {
* diagonal just outside the bull's eye. * diagonal just outside the bull's eye.
*/ */
private BitMatrix sampleGrid(BitMatrix image, private BitMatrix sampleGrid(BitMatrix image,
ResultPoint topLeft, RXingResultPoint topLeft,
ResultPoint topRight, RXingResultPoint topRight,
ResultPoint bottomRight, RXingResultPoint bottomRight,
ResultPoint bottomLeft) throws NotFoundException { RXingResultPoint bottomLeft) throws NotFoundException {
GridSampler sampler = GridSampler.getInstance(); GridSampler sampler = GridSampler.getInstance();
int dimension = getDimension(); int dimension = getDimension();
@@ -397,7 +397,7 @@ public final class Detector {
* @param size number of bits * @param size number of bits
* @return the array of bits as an int (first bit is high-order bit of result) * @return the array of bits as an int (first bit is high-order bit of result)
*/ */
private int sampleLine(ResultPoint p1, ResultPoint p2, int size) { private int sampleLine(RXingResultPoint p1, RXingResultPoint p2, int size) {
int result = 0; int result = 0;
float d = distance(p1, p2); float d = distance(p1, p2);
@@ -529,31 +529,31 @@ public final class Detector {
* @param newSide the new length of the size of the square in the target bit matrix * @param newSide the new length of the size of the square in the target bit matrix
* @return the corners of the expanded square * @return the corners of the expanded square
*/ */
private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, int oldSide, int newSide) { private static RXingResultPoint[] expandSquare(RXingResultPoint[] cornerPoints, int oldSide, int newSide) {
float ratio = newSide / (2.0f * oldSide); float ratio = newSide / (2.0f * oldSide);
float dx = cornerPoints[0].getX() - cornerPoints[2].getX(); float dx = cornerPoints[0].getX() - cornerPoints[2].getX();
float dy = cornerPoints[0].getY() - cornerPoints[2].getY(); float dy = cornerPoints[0].getY() - cornerPoints[2].getY();
float centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0f; float centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0f;
float centery = (cornerPoints[0].getY() + cornerPoints[2].getY()) / 2.0f; float centery = (cornerPoints[0].getY() + cornerPoints[2].getY()) / 2.0f;
ResultPoint result0 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy); RXingResultPoint result0 = new RXingResultPoint(centerx + ratio * dx, centery + ratio * dy);
ResultPoint result2 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy); RXingResultPoint result2 = new RXingResultPoint(centerx - ratio * dx, centery - ratio * dy);
dx = cornerPoints[1].getX() - cornerPoints[3].getX(); dx = cornerPoints[1].getX() - cornerPoints[3].getX();
dy = cornerPoints[1].getY() - cornerPoints[3].getY(); dy = cornerPoints[1].getY() - cornerPoints[3].getY();
centerx = (cornerPoints[1].getX() + cornerPoints[3].getX()) / 2.0f; centerx = (cornerPoints[1].getX() + cornerPoints[3].getX()) / 2.0f;
centery = (cornerPoints[1].getY() + cornerPoints[3].getY()) / 2.0f; centery = (cornerPoints[1].getY() + cornerPoints[3].getY()) / 2.0f;
ResultPoint result1 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy); RXingResultPoint result1 = new RXingResultPoint(centerx + ratio * dx, centery + ratio * dy);
ResultPoint result3 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy); RXingResultPoint result3 = new RXingResultPoint(centerx - ratio * dx, centery - ratio * dy);
return new ResultPoint[]{result0, result1, result2, result3}; return new RXingResultPoint[]{result0, result1, result2, result3};
} }
private boolean isValid(int x, int y) { private boolean isValid(int x, int y) {
return x >= 0 && x < image.getWidth() && y >= 0 && y < image.getHeight(); return x >= 0 && x < image.getWidth() && y >= 0 && y < image.getHeight();
} }
private boolean isValid(ResultPoint point) { private boolean isValid(RXingResultPoint point) {
int x = MathUtils.round(point.getX()); int x = MathUtils.round(point.getX());
int y = MathUtils.round(point.getY()); int y = MathUtils.round(point.getY());
return isValid(x, y); return isValid(x, y);
@@ -563,7 +563,7 @@ public final class Detector {
return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY()); return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
} }
private static float distance(ResultPoint a, ResultPoint b) { private static float distance(RXingResultPoint a, RXingResultPoint b) {
return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY()); return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
} }
@@ -578,8 +578,8 @@ public final class Detector {
private final int x; private final int x;
private final int y; private final int y;
ResultPoint toResultPoint() { RXingResultPoint toRXingResultPoint() {
return new ResultPoint(x, y); return new RXingResultPoint(x, y);
} }
Point(int x, int y) { Point(int x, int y) {

View File

@@ -26,7 +26,7 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
abstract class AbstractDoCoMoResultParser extends ResultParser { abstract class AbstractDoCoMoRXingResultParser extends RXingResultParser {
static String[] matchDoCoMoPrefixedField(String prefix, String rawText) { static String[] matchDoCoMoPrefixedField(String prefix, String rawText) {
return matchPrefixedField(prefix, rawText, ';', true); return matchPrefixedField(prefix, rawText, ';', true);

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -29,10 +29,10 @@ import java.util.List;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class AddressBookAUResultParser extends ResultParser { public final class AddressBookAURXingResultParser extends RXingResultParser {
@Override @Override
public AddressBookParsedResult parse(Result result) { public AddressBookParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
// MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF // MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF
if (!rawText.contains("MEMORY") || !rawText.contains("\r\n")) { if (!rawText.contains("MEMORY") || !rawText.contains("\r\n")) {
@@ -49,7 +49,7 @@ public final class AddressBookAUResultParser extends ResultParser {
String note = matchSinglePrefixedField("MEMORY:", rawText, '\r', false); String note = matchSinglePrefixedField("MEMORY:", rawText, '\r', false);
String address = matchSinglePrefixedField("ADD:", rawText, '\r', true); String address = matchSinglePrefixedField("ADD:", rawText, '\r', true);
String[] addresses = address == null ? null : new String[] {address}; String[] addresses = address == null ? null : new String[] {address};
return new AddressBookParsedResult(maybeWrap(name), return new AddressBookParsedRXingResult(maybeWrap(name),
null, null,
pronunciation, pronunciation,
phoneNumbers, phoneNumbers,

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* Implements the "MECARD" address book entry format. * Implements the "MECARD" address book entry format.
@@ -33,10 +33,10 @@ import com.google.zxing.Result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultParser { public final class AddressBookDoCoMoRXingResultParser extends AbstractDoCoMoRXingResultParser {
@Override @Override
public AddressBookParsedResult parse(Result result) { public AddressBookParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!rawText.startsWith("MECARD:")) { if (!rawText.startsWith("MECARD:")) {
return null; return null;
@@ -62,7 +62,7 @@ public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultPar
// honor it when found in the wild. // honor it when found in the wild.
String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true); String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true);
return new AddressBookParsedResult(maybeWrap(name), return new AddressBookParsedRXingResult(maybeWrap(name),
null, null,
pronunciation, pronunciation,
phoneNumbers, phoneNumbers,

View File

@@ -22,7 +22,7 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class AddressBookParsedResult extends ParsedResult { public final class AddressBookParsedRXingResult extends ParsedRXingResult {
private final String[] names; private final String[] names;
private final String[] nicknames; private final String[] nicknames;
@@ -41,7 +41,7 @@ public final class AddressBookParsedResult extends ParsedResult {
private final String[] urls; private final String[] urls;
private final String[] geo; private final String[] geo;
public AddressBookParsedResult(String[] names, public AddressBookParsedRXingResult(String[] names,
String[] phoneNumbers, String[] phoneNumbers,
String[] phoneTypes, String[] phoneTypes,
String[] emails, String[] emails,
@@ -66,7 +66,7 @@ public final class AddressBookParsedResult extends ParsedResult {
null); null);
} }
public AddressBookParsedResult(String[] names, public AddressBookParsedRXingResult(String[] names,
String[] nicknames, String[] nicknames,
String pronunciation, String pronunciation,
String[] phoneNumbers, String[] phoneNumbers,
@@ -82,7 +82,7 @@ public final class AddressBookParsedResult extends ParsedResult {
String title, String title,
String[] urls, String[] urls,
String[] geo) { String[] geo) {
super(ParsedResultType.ADDRESSBOOK); super(ParsedRXingResultType.ADDRESSBOOK);
if (phoneNumbers != null && phoneTypes != null && phoneNumbers.length != phoneTypes.length) { if (phoneNumbers != null && phoneTypes != null && phoneNumbers.length != phoneTypes.length) {
throw new IllegalArgumentException("Phone numbers and types lengths differ"); throw new IllegalArgumentException("Phone numbers and types lengths differ");
} }
@@ -199,7 +199,7 @@ public final class AddressBookParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(100); StringBuilder result = new StringBuilder(100);
maybeAppend(names, result); maybeAppend(names, result);
maybeAppend(nicknames, result); maybeAppend(nicknames, result);

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -28,14 +28,14 @@ import java.util.List;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class BizcardResultParser extends AbstractDoCoMoResultParser { public final class BizcardRXingResultParser extends AbstractDoCoMoRXingResultParser {
// Yes, we extend AbstractDoCoMoResultParser since the format is very much // Yes, we extend AbstractDoCoMoRXingResultParser since the format is very much
// like the DoCoMo MECARD format, but this is not technically one of // like the DoCoMo MECARD format, but this is not technically one of
// DoCoMo's proposed formats // DoCoMo's proposed formats
@Override @Override
public AddressBookParsedResult parse(Result result) { public AddressBookParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!rawText.startsWith("BIZCARD:")) { if (!rawText.startsWith("BIZCARD:")) {
return null; return null;
@@ -51,7 +51,7 @@ public final class BizcardResultParser extends AbstractDoCoMoResultParser {
String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true); String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true);
String email = matchSingleDoCoMoPrefixedField("E:", rawText, true); String email = matchSingleDoCoMoPrefixedField("E:", rawText, true);
return new AddressBookParsedResult(maybeWrap(fullName), return new AddressBookParsedRXingResult(maybeWrap(fullName),
null, null,
null, null,
buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3), buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3),

View File

@@ -16,15 +16,15 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* @author Sean Owen * @author Sean Owen
*/ */
public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser { public final class BookmarkDoCoMoRXingResultParser extends AbstractDoCoMoRXingResultParser {
@Override @Override
public URIParsedResult parse(Result result) { public URIParsedRXingResult parse(RXingResult result) {
String rawText = result.getText(); String rawText = result.getText();
if (!rawText.startsWith("MEBKM:")) { if (!rawText.startsWith("MEBKM:")) {
return null; return null;
@@ -35,7 +35,7 @@ public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser
return null; return null;
} }
String uri = rawUri[0]; String uri = rawUri[0];
return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null; return URIRXingResultParser.isBasicallyValidURI(uri) ? new URIParsedRXingResult(uri, title) : null;
} }
} }

View File

@@ -33,7 +33,7 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class CalendarParsedResult extends ParsedResult { public final class CalendarParsedRXingResult extends ParsedRXingResult {
private static final Pattern RFC2445_DURATION = private static final Pattern RFC2445_DURATION =
Pattern.compile("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?"); Pattern.compile("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?");
@@ -59,7 +59,7 @@ public final class CalendarParsedResult extends ParsedResult {
private final double latitude; private final double latitude;
private final double longitude; private final double longitude;
public CalendarParsedResult(String summary, public CalendarParsedRXingResult(String summary,
String startString, String startString,
String endString, String endString,
String durationString, String durationString,
@@ -69,7 +69,7 @@ public final class CalendarParsedResult extends ParsedResult {
String description, String description,
double latitude, double latitude,
double longitude) { double longitude) {
super(ParsedResultType.CALENDAR); super(ParsedRXingResultType.CALENDAR);
this.summary = summary; this.summary = summary;
try { try {
@@ -177,7 +177,7 @@ public final class CalendarParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(100); StringBuilder result = new StringBuilder(100);
maybeAppend(summary, result); maybeAppend(summary, result);
maybeAppend(format(startAllDay, start), result); maybeAppend(format(startAllDay, start), result);

View File

@@ -22,7 +22,7 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class EmailAddressParsedResult extends ParsedResult { public final class EmailAddressParsedRXingResult extends ParsedRXingResult {
private final String[] tos; private final String[] tos;
private final String[] ccs; private final String[] ccs;
@@ -30,16 +30,16 @@ public final class EmailAddressParsedResult extends ParsedResult {
private final String subject; private final String subject;
private final String body; private final String body;
EmailAddressParsedResult(String to) { EmailAddressParsedRXingResult(String to) {
this(new String[] {to}, null, null, null, null); this(new String[] {to}, null, null, null, null);
} }
EmailAddressParsedResult(String[] tos, EmailAddressParsedRXingResult(String[] tos,
String[] ccs, String[] ccs,
String[] bccs, String[] bccs,
String subject, String subject,
String body) { String body) {
super(ParsedResultType.EMAIL_ADDRESS); super(ParsedRXingResultType.EMAIL_ADDRESS);
this.tos = tos; this.tos = tos;
this.ccs = ccs; this.ccs = ccs;
this.bccs = bccs; this.bccs = bccs;
@@ -86,7 +86,7 @@ public final class EmailAddressParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(30); StringBuilder result = new StringBuilder(30);
maybeAppend(tos, result); maybeAppend(tos, result);
maybeAppend(ccs, result); maybeAppend(ccs, result);

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -27,12 +27,12 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class EmailAddressResultParser extends ResultParser { public final class EmailAddressRXingResultParser extends RXingResultParser {
private static final Pattern COMMA = Pattern.compile(","); private static final Pattern COMMA = Pattern.compile(",");
@Override @Override
public EmailAddressParsedResult parse(Result result) { public EmailAddressParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (rawText.startsWith("mailto:") || rawText.startsWith("MAILTO:")) { if (rawText.startsWith("mailto:") || rawText.startsWith("MAILTO:")) {
// If it starts with mailto:, assume it is definitely trying to be an email address // If it starts with mailto:, assume it is definitely trying to be an email address
@@ -73,12 +73,12 @@ public final class EmailAddressResultParser extends ResultParser {
subject = nameValues.get("subject"); subject = nameValues.get("subject");
body = nameValues.get("body"); body = nameValues.get("body");
} }
return new EmailAddressParsedResult(tos, ccs, bccs, subject, body); return new EmailAddressParsedRXingResult(tos, ccs, bccs, subject, body);
} else { } else {
if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText)) { if (!EmailDoCoMoRXingResultParser.isBasicallyValidEmailAddress(rawText)) {
return null; return null;
} }
return new EmailAddressParsedResult(rawText); return new EmailAddressParsedRXingResult(rawText);
} }
} }

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -27,12 +27,12 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser { public final class EmailDoCoMoRXingResultParser extends AbstractDoCoMoRXingResultParser {
private static final Pattern ATEXT_ALPHANUMERIC = Pattern.compile("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+"); private static final Pattern ATEXT_ALPHANUMERIC = Pattern.compile("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+");
@Override @Override
public EmailAddressParsedResult parse(Result result) { public EmailAddressParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!rawText.startsWith("MATMSG:")) { if (!rawText.startsWith("MATMSG:")) {
return null; return null;
@@ -48,7 +48,7 @@ public final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser {
} }
String subject = matchSingleDoCoMoPrefixedField("SUB:", rawText, false); String subject = matchSingleDoCoMoPrefixedField("SUB:", rawText, false);
String body = matchSingleDoCoMoPrefixedField("BODY:", rawText, false); String body = matchSingleDoCoMoPrefixedField("BODY:", rawText, false);
return new EmailAddressParsedResult(tos, null, null, subject, body); return new EmailAddressParsedRXingResult(tos, null, null, subject, body);
} }
/** /**

View File

@@ -36,7 +36,7 @@ import java.util.Objects;
* @author Antonio Manuel Benjumea Conde, Servinform, S.A. * @author Antonio Manuel Benjumea Conde, Servinform, S.A.
* @author Agustín Delgado, Servinform, S.A. * @author Agustín Delgado, Servinform, S.A.
*/ */
public final class ExpandedProductParsedResult extends ParsedResult { public final class ExpandedProductParsedRXingResult extends ParsedRXingResult {
public static final String KILOGRAM = "KG"; public static final String KILOGRAM = "KG";
public static final String POUND = "LB"; public static final String POUND = "LB";
@@ -58,7 +58,7 @@ public final class ExpandedProductParsedResult extends ParsedResult {
// For AIS that not exist in this object // For AIS that not exist in this object
private final Map<String,String> uncommonAIs; private final Map<String,String> uncommonAIs;
public ExpandedProductParsedResult(String rawText, public ExpandedProductParsedRXingResult(String rawText,
String productID, String productID,
String sscc, String sscc,
String lotNumber, String lotNumber,
@@ -73,7 +73,7 @@ public final class ExpandedProductParsedResult extends ParsedResult {
String priceIncrement, String priceIncrement,
String priceCurrency, String priceCurrency,
Map<String,String> uncommonAIs) { Map<String,String> uncommonAIs) {
super(ParsedResultType.PRODUCT); super(ParsedRXingResultType.PRODUCT);
this.rawText = rawText; this.rawText = rawText;
this.productID = productID; this.productID = productID;
this.sscc = sscc; this.sscc = sscc;
@@ -93,11 +93,11 @@ public final class ExpandedProductParsedResult extends ParsedResult {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (!(o instanceof ExpandedProductParsedResult)) { if (!(o instanceof ExpandedProductParsedRXingResult)) {
return false; return false;
} }
ExpandedProductParsedResult other = (ExpandedProductParsedResult) o; ExpandedProductParsedRXingResult other = (ExpandedProductParsedRXingResult) o;
return Objects.equals(productID, other.productID) return Objects.equals(productID, other.productID)
&& Objects.equals(sscc, other.sscc) && Objects.equals(sscc, other.sscc)
@@ -193,7 +193,7 @@ public final class ExpandedProductParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
return String.valueOf(rawText); return String.valueOf(rawText);
} }
} }

View File

@@ -30,7 +30,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* Parses strings of digits that represent a RSS Extended code. * Parses strings of digits that represent a RSS Extended code.
@@ -38,13 +38,13 @@ import com.google.zxing.Result;
* @author Antonio Manuel Benjumea Conde, Servinform, S.A. * @author Antonio Manuel Benjumea Conde, Servinform, S.A.
* @author Agustín Delgado, Servinform, S.A. * @author Agustín Delgado, Servinform, S.A.
*/ */
public final class ExpandedProductResultParser extends ResultParser { public final class ExpandedProductRXingResultParser extends RXingResultParser {
@Override @Override
public ExpandedProductParsedResult parse(Result result) { public ExpandedProductParsedRXingResult parse(RXingResult result) {
BarcodeFormat format = result.getBarcodeFormat(); BarcodeFormat format = result.getBarcodeFormat();
if (format != BarcodeFormat.RSS_EXPANDED) { if (format != BarcodeFormat.RSS_EXPANDED) {
// ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode // ExtendedProductParsedRXingResult NOT created. Not a RSS Expanded barcode
return null; return null;
} }
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
@@ -70,7 +70,7 @@ public final class ExpandedProductResultParser extends ResultParser {
String ai = findAIvalue(i, rawText); String ai = findAIvalue(i, rawText);
if (ai == null) { if (ai == null) {
// Error. Code doesn't match with RSS expanded pattern // Error. Code doesn't match with RSS expanded pattern
// ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern // ExtendedProductParsedRXingResult NOT created. Not match with RSS Expanded pattern
return null; return null;
} }
i += ai.length() + 2; i += ai.length() + 2;
@@ -110,7 +110,7 @@ public final class ExpandedProductResultParser extends ResultParser {
case "3108": case "3108":
case "3109": case "3109":
weight = value; weight = value;
weightType = ExpandedProductParsedResult.KILOGRAM; weightType = ExpandedProductParsedRXingResult.KILOGRAM;
weightIncrement = ai.substring(3); weightIncrement = ai.substring(3);
break; break;
case "3200": case "3200":
@@ -124,7 +124,7 @@ public final class ExpandedProductResultParser extends ResultParser {
case "3208": case "3208":
case "3209": case "3209":
weight = value; weight = value;
weightType = ExpandedProductParsedResult.POUND; weightType = ExpandedProductParsedRXingResult.POUND;
weightIncrement = ai.substring(3); weightIncrement = ai.substring(3);
break; break;
case "3920": case "3920":
@@ -141,7 +141,7 @@ public final class ExpandedProductResultParser extends ResultParser {
if (value.length() < 4) { if (value.length() < 4) {
// The value must have more of 3 symbols (3 for currency and // The value must have more of 3 symbols (3 for currency and
// 1 at least for the price) // 1 at least for the price)
// ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern // ExtendedProductParsedRXingResult NOT created. Not match with RSS Expanded pattern
return null; return null;
} }
price = value.substring(3); price = value.substring(3);
@@ -155,7 +155,7 @@ public final class ExpandedProductResultParser extends ResultParser {
} }
} }
return new ExpandedProductParsedResult(rawText, return new ExpandedProductParsedRXingResult(rawText,
productID, productID,
sscc, sscc,
lotNumber, lotNumber,

View File

@@ -22,15 +22,15 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class GeoParsedResult extends ParsedResult { public final class GeoParsedRXingResult extends ParsedRXingResult {
private final double latitude; private final double latitude;
private final double longitude; private final double longitude;
private final double altitude; private final double altitude;
private final String query; private final String query;
GeoParsedResult(double latitude, double longitude, double altitude, String query) { GeoParsedRXingResult(double latitude, double longitude, double altitude, String query) {
super(ParsedResultType.GEO); super(ParsedRXingResultType.GEO);
this.latitude = latitude; this.latitude = latitude;
this.longitude = longitude; this.longitude = longitude;
this.altitude = altitude; this.altitude = altitude;
@@ -83,7 +83,7 @@ public final class GeoParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(20); StringBuilder result = new StringBuilder(20);
result.append(latitude); result.append(latitude);
result.append(", "); result.append(", ");

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -29,13 +29,13 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class GeoResultParser extends ResultParser { public final class GeoRXingResultParser extends RXingResultParser {
private static final Pattern GEO_URL_PATTERN = private static final Pattern GEO_URL_PATTERN =
Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE); Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE);
@Override @Override
public GeoParsedResult parse(Result result) { public GeoParsedRXingResult parse(RXingResult result) {
CharSequence rawText = getMassagedText(result); CharSequence rawText = getMassagedText(result);
Matcher matcher = GEO_URL_PATTERN.matcher(rawText); Matcher matcher = GEO_URL_PATTERN.matcher(rawText);
if (!matcher.matches()) { if (!matcher.matches()) {
@@ -67,7 +67,7 @@ public final class GeoResultParser extends ResultParser {
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
return null; return null;
} }
return new GeoParsedResult(latitude, longitude, altitude, query); return new GeoParsedRXingResult(latitude, longitude, altitude, query);
} }
} }

View File

@@ -21,12 +21,12 @@ package com.google.zxing.client.result;
* *
* @author jbreiden@google.com (Jeff Breidenbach) * @author jbreiden@google.com (Jeff Breidenbach)
*/ */
public final class ISBNParsedResult extends ParsedResult { public final class ISBNParsedRXingResult extends ParsedRXingResult {
private final String isbn; private final String isbn;
ISBNParsedResult(String isbn) { ISBNParsedRXingResult(String isbn) {
super(ParsedResultType.ISBN); super(ParsedRXingResultType.ISBN);
this.isbn = isbn; this.isbn = isbn;
} }
@@ -35,7 +35,7 @@ public final class ISBNParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
return isbn; return isbn;
} }

View File

@@ -17,20 +17,20 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* Parses strings of digits that represent a ISBN. * Parses strings of digits that represent a ISBN.
* *
* @author jbreiden@google.com (Jeff Breidenbach) * @author jbreiden@google.com (Jeff Breidenbach)
*/ */
public final class ISBNResultParser extends ResultParser { public final class ISBNRXingResultParser extends RXingResultParser {
/** /**
* See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a> * See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a>
*/ */
@Override @Override
public ISBNParsedResult parse(Result result) { public ISBNParsedRXingResult parse(RXingResult result) {
BarcodeFormat format = result.getBarcodeFormat(); BarcodeFormat format = result.getBarcodeFormat();
if (format != BarcodeFormat.EAN_13) { if (format != BarcodeFormat.EAN_13) {
return null; return null;
@@ -44,7 +44,7 @@ public final class ISBNResultParser extends ResultParser {
return null; return null;
} }
return new ISBNParsedResult(rawText); return new ISBNParsedRXingResult(rawText);
} }
} }

View File

@@ -19,7 +19,7 @@ package com.google.zxing.client.result;
/** /**
* <p>Abstract class representing the result of decoding a barcode, as more than * <p>Abstract class representing the result of decoding a barcode, as more than
* a String -- as some type of structured data. This might be a subclass which represents * a String -- as some type of structured data. This might be a subclass which represents
* a URL, or an e-mail address. {@link ResultParser#parseResult(com.google.zxing.Result)} will turn a raw * a URL, or an e-mail address. {@link RXingResultParser#parseRXingResult(com.google.zxing.RXingResult)} will turn a raw
* decoded string into the most appropriate type of structured representation.</p> * decoded string into the most appropriate type of structured representation.</p>
* *
* <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less * <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
@@ -27,23 +27,23 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public abstract class ParsedResult { public abstract class ParsedRXingResult {
private final ParsedResultType type; private final ParsedRXingResultType type;
protected ParsedResult(ParsedResultType type) { protected ParsedRXingResult(ParsedRXingResultType type) {
this.type = type; this.type = type;
} }
public final ParsedResultType getType() { public final ParsedRXingResultType getType() {
return type; return type;
} }
public abstract String getDisplayResult(); public abstract String getDisplayRXingResult();
@Override @Override
public final String toString() { public final String toString() {
return getDisplayResult(); return getDisplayRXingResult();
} }
public static void maybeAppend(String value, StringBuilder result) { public static void maybeAppend(String value, StringBuilder result) {

View File

@@ -22,7 +22,7 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public enum ParsedResultType { public enum ParsedRXingResultType {
ADDRESSBOOK, ADDRESSBOOK,
EMAIL_ADDRESS, EMAIL_ADDRESS,

View File

@@ -21,17 +21,17 @@ package com.google.zxing.client.result;
* *
* @author dswitkin@google.com (Daniel Switkin) * @author dswitkin@google.com (Daniel Switkin)
*/ */
public final class ProductParsedResult extends ParsedResult { public final class ProductParsedRXingResult extends ParsedRXingResult {
private final String productID; private final String productID;
private final String normalizedProductID; private final String normalizedProductID;
ProductParsedResult(String productID) { ProductParsedRXingResult(String productID) {
this(productID, productID); this(productID, productID);
} }
ProductParsedResult(String productID, String normalizedProductID) { ProductParsedRXingResult(String productID, String normalizedProductID) {
super(ParsedResultType.PRODUCT); super(ParsedRXingResultType.PRODUCT);
this.productID = productID; this.productID = productID;
this.normalizedProductID = normalizedProductID; this.normalizedProductID = normalizedProductID;
} }
@@ -45,7 +45,7 @@ public final class ProductParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
return productID; return productID;
} }

View File

@@ -17,7 +17,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.oned.UPCEReader; import com.google.zxing.oned.UPCEReader;
/** /**
@@ -25,11 +25,11 @@ import com.google.zxing.oned.UPCEReader;
* *
* @author dswitkin@google.com (Daniel Switkin) * @author dswitkin@google.com (Daniel Switkin)
*/ */
public final class ProductResultParser extends ResultParser { public final class ProductRXingResultParser extends RXingResultParser {
// Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes. // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes.
@Override @Override
public ProductParsedResult parse(Result result) { public ProductParsedRXingResult parse(RXingResult result) {
BarcodeFormat format = result.getBarcodeFormat(); BarcodeFormat format = result.getBarcodeFormat();
if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E || if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E ||
format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) { format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) {
@@ -49,7 +49,7 @@ public final class ProductResultParser extends ResultParser {
normalizedProductID = rawText; normalizedProductID = rawText;
} }
return new ProductParsedResult(rawText, normalizedProductID); return new ProductParsedRXingResult(rawText, normalizedProductID);
} }
} }

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
/** /**
* <p>Abstract class representing the result of decoding a barcode, as more than * <p>Abstract class representing the result of decoding a barcode, as more than
* a String -- as some type of structured data. This might be a subclass which represents * a String -- as some type of structured data. This might be a subclass which represents
* a URL, or an e-mail address. {@link #parseResult(Result)} will turn a raw * a URL, or an e-mail address. {@link #parseRXingResult(RXingResult)} will turn a raw
* decoded string into the most appropriate type of structured representation.</p> * decoded string into the most appropriate type of structured representation.</p>
* *
* <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less * <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
@@ -37,29 +37,29 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public abstract class ResultParser { public abstract class RXingResultParser {
private static final ResultParser[] PARSERS = { private static final RXingResultParser[] PARSERS = {
new BookmarkDoCoMoResultParser(), new BookmarkDoCoMoRXingResultParser(),
new AddressBookDoCoMoResultParser(), new AddressBookDoCoMoRXingResultParser(),
new EmailDoCoMoResultParser(), new EmailDoCoMoRXingResultParser(),
new AddressBookAUResultParser(), new AddressBookAURXingResultParser(),
new VCardResultParser(), new VCardRXingResultParser(),
new BizcardResultParser(), new BizcardRXingResultParser(),
new VEventResultParser(), new VEventRXingResultParser(),
new EmailAddressResultParser(), new EmailAddressRXingResultParser(),
new SMTPResultParser(), new SMTPRXingResultParser(),
new TelResultParser(), new TelRXingResultParser(),
new SMSMMSResultParser(), new SMSMMSRXingResultParser(),
new SMSTOMMSTOResultParser(), new SMSTOMMSTORXingResultParser(),
new GeoResultParser(), new GeoRXingResultParser(),
new WifiResultParser(), new WifiRXingResultParser(),
new URLTOResultParser(), new URLTORXingResultParser(),
new URIResultParser(), new URIRXingResultParser(),
new ISBNResultParser(), new ISBNRXingResultParser(),
new ProductResultParser(), new ProductRXingResultParser(),
new ExpandedProductResultParser(), new ExpandedProductRXingResultParser(),
new VINResultParser(), new VINRXingResultParser(),
}; };
private static final Pattern DIGITS = Pattern.compile("\\d+"); private static final Pattern DIGITS = Pattern.compile("\\d+");
@@ -70,16 +70,16 @@ public abstract class ResultParser {
static final String[] EMPTY_STR_ARRAY = new String[0]; static final String[] EMPTY_STR_ARRAY = new String[0];
/** /**
* Attempts to parse the raw {@link Result}'s contents as a particular type * Attempts to parse the raw {@link RXingResult}'s contents as a particular type
* of information (email, URL, etc.) and return a {@link ParsedResult} encapsulating * of information (email, URL, etc.) and return a {@link ParsedRXingResult} encapsulating
* the result of parsing. * the result of parsing.
* *
* @param theResult the raw {@link Result} to parse * @param theRXingResult the raw {@link RXingResult} to parse
* @return {@link ParsedResult} encapsulating the parsing result * @return {@link ParsedRXingResult} encapsulating the parsing result
*/ */
public abstract ParsedResult parse(Result theResult); public abstract ParsedRXingResult parse(RXingResult theRXingResult);
protected static String getMassagedText(Result result) { protected static String getMassagedText(RXingResult result) {
String text = result.getText(); String text = result.getText();
if (text.startsWith(BYTE_ORDER_MARK)) { if (text.startsWith(BYTE_ORDER_MARK)) {
text = text.substring(1); text = text.substring(1);
@@ -87,14 +87,14 @@ public abstract class ResultParser {
return text; return text;
} }
public static ParsedResult parseResult(Result theResult) { public static ParsedRXingResult parseRXingResult(RXingResult theRXingResult) {
for (ResultParser parser : PARSERS) { for (RXingResultParser parser : PARSERS) {
ParsedResult result = parser.parse(theResult); ParsedRXingResult result = parser.parse(theRXingResult);
if (result != null) { if (result != null) {
return result; return result;
} }
} }
return new TextParsedResult(theResult.getText(), null); return new TextParsedRXingResult(theRXingResult.getText(), null);
} }
protected static void maybeAppend(String value, StringBuilder result) { protected static void maybeAppend(String value, StringBuilder result) {

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -38,10 +38,10 @@ import java.util.Map;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class SMSMMSResultParser extends ResultParser { public final class SMSMMSRXingResultParser extends RXingResultParser {
@Override @Override
public SMSParsedResult parse(Result result) { public SMSParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!(rawText.startsWith("sms:") || rawText.startsWith("SMS:") || if (!(rawText.startsWith("sms:") || rawText.startsWith("SMS:") ||
rawText.startsWith("mms:") || rawText.startsWith("MMS:"))) { rawText.startsWith("mms:") || rawText.startsWith("MMS:"))) {
@@ -80,7 +80,7 @@ public final class SMSMMSResultParser extends ResultParser {
} }
addNumberVia(numbers, vias, smsURIWithoutQuery.substring(lastComma + 1)); addNumberVia(numbers, vias, smsURIWithoutQuery.substring(lastComma + 1));
return new SMSParsedResult(numbers.toArray(EMPTY_STR_ARRAY), return new SMSParsedRXingResult(numbers.toArray(EMPTY_STR_ARRAY),
vias.toArray(EMPTY_STR_ARRAY), vias.toArray(EMPTY_STR_ARRAY),
subject, subject,
body); body);

View File

@@ -22,29 +22,29 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class SMSParsedResult extends ParsedResult { public final class SMSParsedRXingResult extends ParsedRXingResult {
private final String[] numbers; private final String[] numbers;
private final String[] vias; private final String[] vias;
private final String subject; private final String subject;
private final String body; private final String body;
public SMSParsedResult(String number, public SMSParsedRXingResult(String number,
String via, String via,
String subject, String subject,
String body) { String body) {
super(ParsedResultType.SMS); super(ParsedRXingResultType.SMS);
this.numbers = new String[] {number}; this.numbers = new String[] {number};
this.vias = new String[] {via}; this.vias = new String[] {via};
this.subject = subject; this.subject = subject;
this.body = body; this.body = body;
} }
public SMSParsedResult(String[] numbers, public SMSParsedRXingResult(String[] numbers,
String[] vias, String[] vias,
String subject, String subject,
String body) { String body) {
super(ParsedResultType.SMS); super(ParsedRXingResultType.SMS);
this.numbers = numbers; this.numbers = numbers;
this.vias = vias; this.vias = vias;
this.subject = subject; this.subject = subject;
@@ -103,7 +103,7 @@ public final class SMSParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(100); StringBuilder result = new StringBuilder(100);
maybeAppend(numbers, result); maybeAppend(numbers, result);
maybeAppend(subject, result); maybeAppend(subject, result);

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* <p>Parses an "smsto:" URI result, whose format is not standardized but appears to be like: * <p>Parses an "smsto:" URI result, whose format is not standardized but appears to be like:
@@ -28,10 +28,10 @@ import com.google.zxing.Result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class SMSTOMMSTOResultParser extends ResultParser { public final class SMSTOMMSTORXingResultParser extends RXingResultParser {
@Override @Override
public SMSParsedResult parse(Result result) { public SMSParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!(rawText.startsWith("smsto:") || rawText.startsWith("SMSTO:") || if (!(rawText.startsWith("smsto:") || rawText.startsWith("SMSTO:") ||
rawText.startsWith("mmsto:") || rawText.startsWith("MMSTO:"))) { rawText.startsWith("mmsto:") || rawText.startsWith("MMSTO:"))) {
@@ -46,7 +46,7 @@ public final class SMSTOMMSTOResultParser extends ResultParser {
body = number.substring(bodyStart + 1); body = number.substring(bodyStart + 1);
number = number.substring(0, bodyStart); number = number.substring(0, bodyStart);
} }
return new SMSParsedResult(number, null, null, body); return new SMSParsedRXingResult(number, null, null, body);
} }
} }

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* <p>Parses an "smtp:" URI result, whose format is not standardized but appears to be like: * <p>Parses an "smtp:" URI result, whose format is not standardized but appears to be like:
@@ -24,10 +24,10 @@ import com.google.zxing.Result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class SMTPResultParser extends ResultParser { public final class SMTPRXingResultParser extends RXingResultParser {
@Override @Override
public EmailAddressParsedResult parse(Result result) { public EmailAddressParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!(rawText.startsWith("smtp:") || rawText.startsWith("SMTP:"))) { if (!(rawText.startsWith("smtp:") || rawText.startsWith("SMTP:"))) {
return null; return null;
@@ -45,7 +45,7 @@ public final class SMTPResultParser extends ResultParser {
subject = subject.substring(0, colon); subject = subject.substring(0, colon);
} }
} }
return new EmailAddressParsedResult(new String[] {emailAddress}, return new EmailAddressParsedRXingResult(new String[] {emailAddress},
null, null,
null, null,
subject, subject,

View File

@@ -21,14 +21,14 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class TelParsedResult extends ParsedResult { public final class TelParsedRXingResult extends ParsedRXingResult {
private final String number; private final String number;
private final String telURI; private final String telURI;
private final String title; private final String title;
public TelParsedResult(String number, String telURI, String title) { public TelParsedRXingResult(String number, String telURI, String title) {
super(ParsedResultType.TEL); super(ParsedRXingResultType.TEL);
this.number = number; this.number = number;
this.telURI = telURI; this.telURI = telURI;
this.title = title; this.title = title;
@@ -47,7 +47,7 @@ public final class TelParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(20); StringBuilder result = new StringBuilder(20);
maybeAppend(number, result); maybeAppend(number, result);
maybeAppend(title, result); maybeAppend(title, result);

View File

@@ -16,17 +16,17 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* Parses a "tel:" URI result, which specifies a phone number. * Parses a "tel:" URI result, which specifies a phone number.
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class TelResultParser extends ResultParser { public final class TelRXingResultParser extends RXingResultParser {
@Override @Override
public TelParsedResult parse(Result result) { public TelParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:")) { if (!rawText.startsWith("tel:") && !rawText.startsWith("TEL:")) {
return null; return null;
@@ -36,7 +36,7 @@ public final class TelResultParser extends ResultParser {
// Drop tel, query portion // Drop tel, query portion
int queryStart = rawText.indexOf('?', 4); int queryStart = rawText.indexOf('?', 4);
String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart); String number = queryStart < 0 ? rawText.substring(4) : rawText.substring(4, queryStart);
return new TelParsedResult(number, telURI, null); return new TelParsedRXingResult(number, telURI, null);
} }
} }

View File

@@ -22,13 +22,13 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class TextParsedResult extends ParsedResult { public final class TextParsedRXingResult extends ParsedRXingResult {
private final String text; private final String text;
private final String language; private final String language;
public TextParsedResult(String text, String language) { public TextParsedRXingResult(String text, String language) {
super(ParsedResultType.TEXT); super(ParsedRXingResultType.TEXT);
this.text = text; this.text = text;
this.language = language; this.language = language;
} }
@@ -42,7 +42,7 @@ public final class TextParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
return text; return text;
} }

View File

@@ -21,13 +21,13 @@ package com.google.zxing.client.result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class URIParsedResult extends ParsedResult { public final class URIParsedRXingResult extends ParsedRXingResult {
private final String uri; private final String uri;
private final String title; private final String title;
public URIParsedResult(String uri, String title) { public URIParsedRXingResult(String uri, String title) {
super(ParsedResultType.URI); super(ParsedRXingResultType.URI);
this.uri = massageURI(uri); this.uri = massageURI(uri);
this.title = title; this.title = title;
} }
@@ -43,15 +43,15 @@ public final class URIParsedResult extends ParsedResult {
/** /**
* @return true if the URI contains suspicious patterns that may suggest it intends to * @return true if the URI contains suspicious patterns that may suggest it intends to
* mislead the user about its true nature * mislead the user about its true nature
* @deprecated see {@link URIResultParser#isPossiblyMaliciousURI(String)} * @deprecated see {@link URIRXingResultParser#isPossiblyMaliciousURI(String)}
*/ */
@Deprecated @Deprecated
public boolean isPossiblyMaliciousURI() { public boolean isPossiblyMaliciousURI() {
return URIResultParser.isPossiblyMaliciousURI(uri); return URIRXingResultParser.isPossiblyMaliciousURI(uri);
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(30); StringBuilder result = new StringBuilder(30);
maybeAppend(title, result); maybeAppend(title, result);
maybeAppend(uri, result); maybeAppend(uri, result);
@@ -79,7 +79,7 @@ public final class URIParsedResult extends ParsedResult {
if (nextSlash < 0) { if (nextSlash < 0) {
nextSlash = uri.length(); nextSlash = uri.length();
} }
return ResultParser.isSubstringOfDigits(uri, start, nextSlash - start); return RXingResultParser.isSubstringOfDigits(uri, start, nextSlash - start);
} }

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -26,7 +26,7 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class URIResultParser extends ResultParser { public final class URIRXingResultParser extends RXingResultParser {
private static final Pattern ALLOWED_URI_CHARS_PATTERN = private static final Pattern ALLOWED_URI_CHARS_PATTERN =
Pattern.compile("[-._~:/?#\\[\\]@!$&'()*+,;=%A-Za-z0-9]+"); Pattern.compile("[-._~:/?#\\[\\]@!$&'()*+,;=%A-Za-z0-9]+");
@@ -39,18 +39,18 @@ public final class URIResultParser extends ResultParser {
"(/|\\?|$)"); // query, path or nothing "(/|\\?|$)"); // query, path or nothing
@Override @Override
public URIParsedResult parse(Result result) { public URIParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
// We specifically handle the odd "URL" scheme here for simplicity and add "URI" for fun // We specifically handle the odd "URL" scheme here for simplicity and add "URI" for fun
// Assume anything starting this way really means to be a URI // Assume anything starting this way really means to be a URI
if (rawText.startsWith("URL:") || rawText.startsWith("URI:")) { if (rawText.startsWith("URL:") || rawText.startsWith("URI:")) {
return new URIParsedResult(rawText.substring(4).trim(), null); return new URIParsedRXingResult(rawText.substring(4).trim(), null);
} }
rawText = rawText.trim(); rawText = rawText.trim();
if (!isBasicallyValidURI(rawText) || isPossiblyMaliciousURI(rawText)) { if (!isBasicallyValidURI(rawText) || isPossiblyMaliciousURI(rawText)) {
return null; return null;
} }
return new URIParsedResult(rawText, null); return new URIParsedRXingResult(rawText, null);
} }
/** /**

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
/** /**
* Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]". * Parses the "URLTO" result format, which is of the form "URLTO:[title]:[url]".
@@ -25,10 +25,10 @@ import com.google.zxing.Result;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class URLTOResultParser extends ResultParser { public final class URLTORXingResultParser extends RXingResultParser {
@Override @Override
public URIParsedResult parse(Result result) { public URIParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:")) { if (!rawText.startsWith("urlto:") && !rawText.startsWith("URLTO:")) {
return null; return null;
@@ -39,7 +39,7 @@ public final class URLTOResultParser extends ResultParser {
} }
String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd); String title = titleEnd <= 6 ? null : rawText.substring(6, titleEnd);
String uri = rawText.substring(titleEnd + 1); String uri = rawText.substring(titleEnd + 1);
return new URIParsedResult(uri, title); return new URIParsedRXingResult(uri, title);
} }
} }

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@@ -34,7 +34,7 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class VCardResultParser extends ResultParser { public final class VCardRXingResultParser extends RXingResultParser {
private static final Pattern BEGIN_VCARD = Pattern.compile("BEGIN:VCARD", Pattern.CASE_INSENSITIVE); private static final Pattern BEGIN_VCARD = Pattern.compile("BEGIN:VCARD", Pattern.CASE_INSENSITIVE);
private static final Pattern VCARD_LIKE_DATE = Pattern.compile("\\d{4}-?\\d{2}-?\\d{2}"); private static final Pattern VCARD_LIKE_DATE = Pattern.compile("\\d{4}-?\\d{2}-?\\d{2}");
@@ -48,7 +48,7 @@ public final class VCardResultParser extends ResultParser {
private static final Pattern SEMICOLON_OR_COMMA = Pattern.compile("[;,]"); private static final Pattern SEMICOLON_OR_COMMA = Pattern.compile("[;,]");
@Override @Override
public AddressBookParsedResult parse(Result result) { public AddressBookParsedRXingResult parse(RXingResult result) {
// Although we should insist on the raw text ending with "END:VCARD", there's no reason // Although we should insist on the raw text ending with "END:VCARD", there's no reason
// to throw out everything else we parsed just because this was omitted. In fact, Eclair // to throw out everything else we parsed just because this was omitted. In fact, Eclair
// is doing just that, and we can't parse its contacts without this leniency. // is doing just that, and we can't parse its contacts without this leniency.
@@ -82,7 +82,7 @@ public final class VCardResultParser extends ResultParser {
if (geo != null && geo.length != 2) { if (geo != null && geo.length != 2) {
geo = null; geo = null;
} }
return new AddressBookParsedResult(toPrimaryValues(names), return new AddressBookParsedRXingResult(toPrimaryValues(names),
nicknames, nicknames,
null, null,
toPrimaryValues(phoneNumbers), toPrimaryValues(phoneNumbers),

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.List; import java.util.List;
@@ -26,10 +26,10 @@ import java.util.List;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class VEventResultParser extends ResultParser { public final class VEventRXingResultParser extends RXingResultParser {
@Override @Override
public CalendarParsedResult parse(Result result) { public CalendarParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
int vEventStart = rawText.indexOf("BEGIN:VEVENT"); int vEventStart = rawText.indexOf("BEGIN:VEVENT");
if (vEventStart < 0) { if (vEventStart < 0) {
@@ -74,7 +74,7 @@ public final class VEventResultParser extends ResultParser {
} }
try { try {
return new CalendarParsedResult(summary, return new CalendarParsedRXingResult(summary,
start, start,
end, end,
duration, duration,
@@ -91,12 +91,12 @@ public final class VEventResultParser extends ResultParser {
private static String matchSingleVCardPrefixedField(CharSequence prefix, private static String matchSingleVCardPrefixedField(CharSequence prefix,
String rawText) { String rawText) {
List<String> values = VCardResultParser.matchSingleVCardPrefixedField(prefix, rawText, true, false); List<String> values = VCardRXingResultParser.matchSingleVCardPrefixedField(prefix, rawText, true, false);
return values == null || values.isEmpty() ? null : values.get(0); return values == null || values.isEmpty() ? null : values.get(0);
} }
private static String[] matchVCardPrefixedField(CharSequence prefix, String rawText) { private static String[] matchVCardPrefixedField(CharSequence prefix, String rawText) {
List<List<String>> values = VCardResultParser.matchVCardPrefixedField(prefix, rawText, true, false); List<List<String>> values = VCardRXingResultParser.matchVCardPrefixedField(prefix, rawText, true, false);
if (values == null || values.isEmpty()) { if (values == null || values.isEmpty()) {
return null; return null;
} }

View File

@@ -20,7 +20,7 @@ package com.google.zxing.client.result;
/** /**
* Represents a parsed result that encodes a Vehicle Identification Number (VIN). * Represents a parsed result that encodes a Vehicle Identification Number (VIN).
*/ */
public final class VINParsedResult extends ParsedResult { public final class VINParsedRXingResult extends ParsedRXingResult {
private final String vin; private final String vin;
private final String worldManufacturerID; private final String worldManufacturerID;
@@ -32,7 +32,7 @@ public final class VINParsedResult extends ParsedResult {
private final char plantCode; private final char plantCode;
private final String sequentialNumber; private final String sequentialNumber;
public VINParsedResult(String vin, public VINParsedRXingResult(String vin,
String worldManufacturerID, String worldManufacturerID,
String vehicleDescriptorSection, String vehicleDescriptorSection,
String vehicleIdentifierSection, String vehicleIdentifierSection,
@@ -41,7 +41,7 @@ public final class VINParsedResult extends ParsedResult {
int modelYear, int modelYear,
char plantCode, char plantCode,
String sequentialNumber) { String sequentialNumber) {
super(ParsedResultType.VIN); super(ParsedRXingResultType.VIN);
this.vin = vin; this.vin = vin;
this.worldManufacturerID = worldManufacturerID; this.worldManufacturerID = worldManufacturerID;
this.vehicleDescriptorSection = vehicleDescriptorSection; this.vehicleDescriptorSection = vehicleDescriptorSection;
@@ -90,7 +90,7 @@ public final class VINParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(50); StringBuilder result = new StringBuilder(50);
result.append(worldManufacturerID).append(' '); result.append(worldManufacturerID).append(' ');
result.append(vehicleDescriptorSection).append(' '); result.append(vehicleDescriptorSection).append(' ');

View File

@@ -17,7 +17,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.BarcodeFormat; import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -26,13 +26,13 @@ import java.util.regex.Pattern;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class VINResultParser extends ResultParser { public final class VINRXingResultParser extends RXingResultParser {
private static final Pattern IOQ = Pattern.compile("[IOQ]"); private static final Pattern IOQ = Pattern.compile("[IOQ]");
private static final Pattern AZ09 = Pattern.compile("[A-Z0-9]{17}"); private static final Pattern AZ09 = Pattern.compile("[A-Z0-9]{17}");
@Override @Override
public VINParsedResult parse(Result result) { public VINParsedRXingResult parse(RXingResult result) {
if (result.getBarcodeFormat() != BarcodeFormat.CODE_39) { if (result.getBarcodeFormat() != BarcodeFormat.CODE_39) {
return null; return null;
} }
@@ -46,7 +46,7 @@ public final class VINResultParser extends ResultParser {
return null; return null;
} }
String wmi = rawText.substring(0, 3); String wmi = rawText.substring(0, 3);
return new VINParsedResult(rawText, return new VINParsedRXingResult(rawText,
wmi, wmi,
rawText.substring(3, 9), rawText.substring(3, 9),
rawText.substring(9, 17), rawText.substring(9, 17),

View File

@@ -21,7 +21,7 @@ package com.google.zxing.client.result;
* *
* @author Vikram Aggarwal * @author Vikram Aggarwal
*/ */
public final class WifiParsedResult extends ParsedResult { public final class WifiParsedRXingResult extends ParsedRXingResult {
private final String ssid; private final String ssid;
private final String networkEncryption; private final String networkEncryption;
@@ -32,15 +32,15 @@ public final class WifiParsedResult extends ParsedResult {
private final String eapMethod; private final String eapMethod;
private final String phase2Method; private final String phase2Method;
public WifiParsedResult(String networkEncryption, String ssid, String password) { public WifiParsedRXingResult(String networkEncryption, String ssid, String password) {
this(networkEncryption, ssid, password, false); this(networkEncryption, ssid, password, false);
} }
public WifiParsedResult(String networkEncryption, String ssid, String password, boolean hidden) { public WifiParsedRXingResult(String networkEncryption, String ssid, String password, boolean hidden) {
this(networkEncryption, ssid, password, hidden, null, null, null, null); this(networkEncryption, ssid, password, hidden, null, null, null, null);
} }
public WifiParsedResult(String networkEncryption, public WifiParsedRXingResult(String networkEncryption,
String ssid, String ssid,
String password, String password,
boolean hidden, boolean hidden,
@@ -48,7 +48,7 @@ public final class WifiParsedResult extends ParsedResult {
String anonymousIdentity, String anonymousIdentity,
String eapMethod, String eapMethod,
String phase2Method) { String phase2Method) {
super(ParsedResultType.WIFI); super(ParsedRXingResultType.WIFI);
this.ssid = ssid; this.ssid = ssid;
this.networkEncryption = networkEncryption; this.networkEncryption = networkEncryption;
this.password = password; this.password = password;
@@ -92,7 +92,7 @@ public final class WifiParsedResult extends ParsedResult {
} }
@Override @Override
public String getDisplayResult() { public String getDisplayRXingResult() {
StringBuilder result = new StringBuilder(80); StringBuilder result = new StringBuilder(80);
maybeAppend(ssid, result); maybeAppend(ssid, result);
maybeAppend(networkEncryption, result); maybeAppend(networkEncryption, result);

View File

@@ -16,7 +16,7 @@
package com.google.zxing.client.result; package com.google.zxing.client.result;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
@SuppressWarnings("checkstyle:lineLength") @SuppressWarnings("checkstyle:lineLength")
/** /**
@@ -36,10 +36,10 @@ import com.google.zxing.Result;
* @author Sean Owen * @author Sean Owen
* @author Steffen Kieß * @author Steffen Kieß
*/ */
public final class WifiResultParser extends ResultParser { public final class WifiRXingResultParser extends RXingResultParser {
@Override @Override
public WifiParsedResult parse(Result result) { public WifiParsedRXingResult parse(RXingResult result) {
String rawText = getMassagedText(result); String rawText = getMassagedText(result);
if (!rawText.startsWith("WIFI:")) { if (!rawText.startsWith("WIFI:")) {
return null; return null;
@@ -74,6 +74,6 @@ public final class WifiResultParser extends ResultParser {
String anonymousIdentity = matchSinglePrefixedField("A:", rawText, ';', false); String anonymousIdentity = matchSinglePrefixedField("A:", rawText, ';', false);
String eapMethod = matchSinglePrefixedField("E:", rawText, ';', false); String eapMethod = matchSinglePrefixedField("E:", rawText, ';', false);
return new WifiParsedResult(type, ssid, pass, hidden, identity, anonymousIdentity, eapMethod, phase2Method); return new WifiParsedRXingResult(type, ssid, pass, hidden, identity, anonymousIdentity, eapMethod, phase2Method);
} }
} }

View File

@@ -25,7 +25,7 @@ import java.util.List;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public final class DecoderResult { public final class DecoderRXingResult {
private final byte[] rawBytes; private final byte[] rawBytes;
private int numBits; private int numBits;
@@ -39,14 +39,14 @@ public final class DecoderResult {
private final int structuredAppendSequenceNumber; private final int structuredAppendSequenceNumber;
private final int symbologyModifier; private final int symbologyModifier;
public DecoderResult(byte[] rawBytes, public DecoderRXingResult(byte[] rawBytes,
String text, String text,
List<byte[]> byteSegments, List<byte[]> byteSegments,
String ecLevel) { String ecLevel) {
this(rawBytes, text, byteSegments, ecLevel, -1, -1, 0); this(rawBytes, text, byteSegments, ecLevel, -1, -1, 0);
} }
public DecoderResult(byte[] rawBytes, public DecoderRXingResult(byte[] rawBytes,
String text, String text,
List<byte[]> byteSegments, List<byte[]> byteSegments,
String ecLevel, String ecLevel,
@@ -54,7 +54,7 @@ public final class DecoderResult {
this(rawBytes, text, byteSegments, ecLevel, -1, -1, symbologyModifier); this(rawBytes, text, byteSegments, ecLevel, -1, -1, symbologyModifier);
} }
public DecoderResult(byte[] rawBytes, public DecoderRXingResult(byte[] rawBytes,
String text, String text,
List<byte[]> byteSegments, List<byte[]> byteSegments,
String ecLevel, String ecLevel,
@@ -63,7 +63,7 @@ public final class DecoderResult {
this(rawBytes, text, byteSegments, ecLevel, saSequence, saParity, 0); this(rawBytes, text, byteSegments, ecLevel, saSequence, saParity, 0);
} }
public DecoderResult(byte[] rawBytes, public DecoderRXingResult(byte[] rawBytes,
String text, String text,
List<byte[]> byteSegments, List<byte[]> byteSegments,
String ecLevel, String ecLevel,

View File

@@ -16,7 +16,7 @@
package com.google.zxing.common; package com.google.zxing.common;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
/** /**
* <p>Encapsulates the result of detecting a barcode in an image. This includes the raw * <p>Encapsulates the result of detecting a barcode in an image. This includes the raw
@@ -25,12 +25,12 @@ import com.google.zxing.ResultPoint;
* *
* @author Sean Owen * @author Sean Owen
*/ */
public class DetectorResult { public class DetectorRXingResult {
private final BitMatrix bits; private final BitMatrix bits;
private final ResultPoint[] points; private final RXingResultPoint[] points;
public DetectorResult(BitMatrix bits, ResultPoint[] points) { public DetectorRXingResult(BitMatrix bits, RXingResultPoint[] points) {
this.bits = bits; this.bits = bits;
this.points = points; this.points = points;
} }
@@ -39,7 +39,7 @@ public class DetectorResult {
return bits; return bits;
} }
public final ResultPoint[] getPoints() { public final RXingResultPoint[] getPoints() {
return points; return points;
} }

View File

@@ -15,7 +15,7 @@
*/ */
//package com.google.zxing.common.detector; //package com.google.zxing.common.detector;
use crate::{NotFoundException,ResultPoint}; use crate::{NotFoundException,RXingResultPoint};
use crate::common::BitMatrix; use crate::common::BitMatrix;
@@ -42,13 +42,13 @@ public final class MonochromeRectangleDetector {
* <p>Detects a rectangular region of black and white -- mostly black -- with a region of mostly * <p>Detects a rectangular region of black and white -- mostly black -- with a region of mostly
* white, in an image.</p> * white, in an image.</p>
* *
* @return {@link ResultPoint}[] describing the corners of the rectangular region. The first and * @return {@link RXingResultPoint}[] describing the corners of the rectangular region. The first and
* last points are opposed on the diagonal, as are the second and third. The first point will be * last points are opposed on the diagonal, as are the second and third. The first point will be
* the topmost point and the last, the bottommost. The second point will be leftmost and the * the topmost point and the last, the bottommost. The second point will be leftmost and the
* third, the rightmost * third, the rightmost
* @throws NotFoundException if no Data Matrix Code can be found * @throws NotFoundException if no Data Matrix Code can be found
*/ */
public ResultPoint[] detect() throws NotFoundException { public RXingResultPoint[] detect() throws NotFoundException {
int height = image.getHeight(); int height = image.getHeight();
int width = image.getWidth(); int width = image.getWidth();
int halfHeight = height / 2; int halfHeight = height / 2;
@@ -60,16 +60,16 @@ public final class MonochromeRectangleDetector {
int bottom = height; int bottom = height;
int left = 0; int left = 0;
int right = width; int right = width;
ResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right, RXingResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, -deltaY, top, bottom, halfWidth / 2); halfHeight, -deltaY, top, bottom, halfWidth / 2);
top = (int) pointA.getY() - 1; top = (int) pointA.getY() - 1;
ResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right, RXingResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right,
halfHeight, 0, top, bottom, halfHeight / 2); halfHeight, 0, top, bottom, halfHeight / 2);
left = (int) pointB.getX() - 1; left = (int) pointB.getX() - 1;
ResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right, RXingResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right,
halfHeight, 0, top, bottom, halfHeight / 2); halfHeight, 0, top, bottom, halfHeight / 2);
right = (int) pointC.getX() + 1; right = (int) pointC.getX() + 1;
ResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right, RXingResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, deltaY, top, bottom, halfWidth / 2); halfHeight, deltaY, top, bottom, halfWidth / 2);
bottom = (int) pointD.getY() + 1; bottom = (int) pointD.getY() + 1;
@@ -77,7 +77,7 @@ public final class MonochromeRectangleDetector {
pointA = findCornerFromCenter(halfWidth, 0, left, right, pointA = findCornerFromCenter(halfWidth, 0, left, right,
halfHeight, -deltaY, top, bottom, halfWidth / 4); halfHeight, -deltaY, top, bottom, halfWidth / 4);
return new ResultPoint[] { pointA, pointB, pointC, pointD }; return new RXingResultPoint[] { pointA, pointB, pointC, pointD };
} }
/** /**
@@ -95,10 +95,10 @@ public final class MonochromeRectangleDetector {
* @param bottom maximum value of y * @param bottom maximum value of y
* @param maxWhiteRun maximum run of white pixels that can still be considered to be within * @param maxWhiteRun maximum run of white pixels that can still be considered to be within
* the barcode * the barcode
* @return a {@link ResultPoint} encapsulating the corner that was found * @return a {@link RXingResultPoint} encapsulating the corner that was found
* @throws NotFoundException if such a point cannot be found * @throws NotFoundException if such a point cannot be found
*/ */
private ResultPoint findCornerFromCenter(int centerX, private RXingResultPoint findCornerFromCenter(int centerX,
int deltaX, int deltaX,
int left, int left,
int right, int right,
@@ -129,21 +129,21 @@ public final class MonochromeRectangleDetector {
if (lastRange[0] < centerX) { if (lastRange[0] < centerX) {
if (lastRange[1] > centerX) { if (lastRange[1] > centerX) {
// straddle, choose one or the other based on direction // straddle, choose one or the other based on direction
return new ResultPoint(lastRange[deltaY > 0 ? 0 : 1], lastY); return new RXingResultPoint(lastRange[deltaY > 0 ? 0 : 1], lastY);
} }
return new ResultPoint(lastRange[0], lastY); return new RXingResultPoint(lastRange[0], lastY);
} else { } else {
return new ResultPoint(lastRange[1], lastY); return new RXingResultPoint(lastRange[1], lastY);
} }
} else { } else {
int lastX = x - deltaX; int lastX = x - deltaX;
if (lastRange[0] < centerY) { if (lastRange[0] < centerY) {
if (lastRange[1] > centerY) { if (lastRange[1] > centerY) {
return new ResultPoint(lastX, lastRange[deltaX < 0 ? 0 : 1]); return new RXingResultPoint(lastX, lastRange[deltaX < 0 ? 0 : 1]);
} }
return new ResultPoint(lastX, lastRange[0]); return new RXingResultPoint(lastX, lastRange[0]);
} else { } else {
return new ResultPoint(lastX, lastRange[1]); return new RXingResultPoint(lastX, lastRange[1]);
} }
} }
} }

View File

@@ -17,7 +17,7 @@
package com.google.zxing.common.detector; package com.google.zxing.common.detector;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
/** /**
@@ -75,14 +75,14 @@ public final class WhiteRectangleDetector {
* region until it finds a white rectangular region. * region until it finds a white rectangular region.
* </p> * </p>
* *
* @return {@link ResultPoint}[] describing the corners of the rectangular * @return {@link RXingResultPoint}[] describing the corners of the rectangular
* region. The first and last points are opposed on the diagonal, as * region. The first and last points are opposed on the diagonal, as
* are the second and third. The first point will be the topmost * are the second and third. The first point will be the topmost
* point and the last, the bottommost. The second point will be * point and the last, the bottommost. The second point will be
* leftmost and the third, the rightmost * leftmost and the third, the rightmost
* @throws NotFoundException if no Data Matrix Code can be found * @throws NotFoundException if no Data Matrix Code can be found
*/ */
public ResultPoint[] detect() throws NotFoundException { public RXingResultPoint[] detect() throws NotFoundException {
int left = leftInit; int left = leftInit;
int right = rightInit; int right = rightInit;
@@ -186,7 +186,7 @@ public final class WhiteRectangleDetector {
int maxSize = right - left; int maxSize = right - left;
ResultPoint z = null; RXingResultPoint z = null;
for (int i = 1; z == null && i < maxSize; i++) { for (int i = 1; z == null && i < maxSize; i++) {
z = getBlackPointOnSegment(left, down - i, left + i, down); z = getBlackPointOnSegment(left, down - i, left + i, down);
} }
@@ -195,7 +195,7 @@ public final class WhiteRectangleDetector {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
ResultPoint t = null; RXingResultPoint t = null;
//go down right //go down right
for (int i = 1; t == null && i < maxSize; i++) { for (int i = 1; t == null && i < maxSize; i++) {
t = getBlackPointOnSegment(left, up + i, left + i, up); t = getBlackPointOnSegment(left, up + i, left + i, up);
@@ -205,7 +205,7 @@ public final class WhiteRectangleDetector {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
ResultPoint x = null; RXingResultPoint x = null;
//go down left //go down left
for (int i = 1; x == null && i < maxSize; i++) { for (int i = 1; x == null && i < maxSize; i++) {
x = getBlackPointOnSegment(right, up + i, right - i, up); x = getBlackPointOnSegment(right, up + i, right - i, up);
@@ -215,7 +215,7 @@ public final class WhiteRectangleDetector {
throw NotFoundException.getNotFoundInstance(); throw NotFoundException.getNotFoundInstance();
} }
ResultPoint y = null; RXingResultPoint y = null;
//go up left //go up left
for (int i = 1; y == null && i < maxSize; i++) { for (int i = 1; y == null && i < maxSize; i++) {
y = getBlackPointOnSegment(right, down - i, right - i, down); y = getBlackPointOnSegment(right, down - i, right - i, down);
@@ -232,7 +232,7 @@ public final class WhiteRectangleDetector {
} }
} }
private ResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY) { private RXingResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY) {
int dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY)); int dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY));
float xStep = (bX - aX) / dist; float xStep = (bX - aX) / dist;
float yStep = (bY - aY) / dist; float yStep = (bY - aY) / dist;
@@ -241,7 +241,7 @@ public final class WhiteRectangleDetector {
int x = MathUtils.round(aX + i * xStep); int x = MathUtils.round(aX + i * xStep);
int y = MathUtils.round(aY + i * yStep); int y = MathUtils.round(aY + i * yStep);
if (image.get(x, y)) { if (image.get(x, y)) {
return new ResultPoint(x, y); return new RXingResultPoint(x, y);
} }
} }
return null; return null;
@@ -254,14 +254,14 @@ public final class WhiteRectangleDetector {
* @param z left most point * @param z left most point
* @param x right most point * @param x right most point
* @param t top most point * @param t top most point
* @return {@link ResultPoint}[] describing the corners of the rectangular * @return {@link RXingResultPoint}[] describing the corners of the rectangular
* region. The first and last points are opposed on the diagonal, as * region. The first and last points are opposed on the diagonal, as
* are the second and third. The first point will be the topmost * are the second and third. The first point will be the topmost
* point and the last, the bottommost. The second point will be * point and the last, the bottommost. The second point will be
* leftmost and the third, the rightmost * leftmost and the third, the rightmost
*/ */
private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, private RXingResultPoint[] centerEdges(RXingResultPoint y, RXingResultPoint z,
ResultPoint x, ResultPoint t) { RXingResultPoint x, RXingResultPoint t) {
// //
// t t // t t
@@ -280,17 +280,17 @@ public final class WhiteRectangleDetector {
float tj = t.getY(); float tj = t.getY();
if (yi < width / 2.0f) { if (yi < width / 2.0f) {
return new ResultPoint[]{ return new RXingResultPoint[]{
new ResultPoint(ti - CORR, tj + CORR), new RXingResultPoint(ti - CORR, tj + CORR),
new ResultPoint(zi + CORR, zj + CORR), new RXingResultPoint(zi + CORR, zj + CORR),
new ResultPoint(xi - CORR, xj - CORR), new RXingResultPoint(xi - CORR, xj - CORR),
new ResultPoint(yi + CORR, yj - CORR)}; new RXingResultPoint(yi + CORR, yj - CORR)};
} else { } else {
return new ResultPoint[]{ return new RXingResultPoint[]{
new ResultPoint(ti + CORR, tj + CORR), new RXingResultPoint(ti + CORR, tj + CORR),
new ResultPoint(zi + CORR, zj - CORR), new RXingResultPoint(zi + CORR, zj - CORR),
new ResultPoint(xi - CORR, xj + CORR), new RXingResultPoint(xi - CORR, xj + CORR),
new ResultPoint(yi - CORR, yj - CORR)}; new RXingResultPoint(yi - CORR, yj - CORR)};
} }
} }

View File

@@ -23,12 +23,12 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.Reader; import com.google.zxing.Reader;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.ResultMetadataType; import com.google.zxing.RXingResultMetadataType;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.common.DetectorResult; import com.google.zxing.common.DetectorRXingResult;
import com.google.zxing.datamatrix.decoder.Decoder; import com.google.zxing.datamatrix.decoder.Decoder;
import com.google.zxing.datamatrix.detector.Detector; import com.google.zxing.datamatrix.detector.Detector;
@@ -42,7 +42,7 @@ import java.util.Map;
*/ */
public final class DataMatrixReader implements Reader { public final class DataMatrixReader implements Reader {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
private final Decoder decoder = new Decoder(); private final Decoder decoder = new Decoder();
@@ -55,35 +55,35 @@ public final class DataMatrixReader implements Reader {
* @throws ChecksumException if error correction fails * @throws ChecksumException if error correction fails
*/ */
@Override @Override
public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException { public RXingResult decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
return decode(image, null); return decode(image, null);
} }
@Override @Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
throws NotFoundException, ChecksumException, FormatException { throws NotFoundException, ChecksumException, FormatException {
DecoderResult decoderResult; DecoderRXingResult decoderRXingResult;
ResultPoint[] points; RXingResultPoint[] points;
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) { if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
BitMatrix bits = extractPureBits(image.getBlackMatrix()); BitMatrix bits = extractPureBits(image.getBlackMatrix());
decoderResult = decoder.decode(bits); decoderRXingResult = decoder.decode(bits);
points = NO_POINTS; points = NO_POINTS;
} else { } else {
DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(); DetectorRXingResult detectorRXingResult = new Detector(image.getBlackMatrix()).detect();
decoderResult = decoder.decode(detectorResult.getBits()); decoderRXingResult = decoder.decode(detectorRXingResult.getBits());
points = detectorResult.getPoints(); points = detectorRXingResult.getPoints();
} }
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, RXingResult result = new RXingResult(decoderRXingResult.getText(), decoderRXingResult.getRawBytes(), points,
BarcodeFormat.DATA_MATRIX); BarcodeFormat.DATA_MATRIX);
List<byte[]> byteSegments = decoderResult.getByteSegments(); List<byte[]> byteSegments = decoderRXingResult.getByteSegments();
if (byteSegments != null) { if (byteSegments != null) {
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments); result.putMetadata(RXingResultMetadataType.BYTE_SEGMENTS, byteSegments);
} }
String ecLevel = decoderResult.getECLevel(); String ecLevel = decoderRXingResult.getECLevel();
if (ecLevel != null) { if (ecLevel != null) {
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
} }
result.putMetadata(ResultMetadataType.SYMBOLOGY_IDENTIFIER, "]d" + decoderResult.getSymbologyModifier()); result.putMetadata(RXingResultMetadataType.SYMBOLOGY_IDENTIFIER, "]d" + decoderRXingResult.getSymbologyModifier());
return result; return result;
} }

View File

@@ -57,12 +57,12 @@ final class DataBlock {
// Now establish DataBlocks of the appropriate size and number of data codewords // Now establish DataBlocks of the appropriate size and number of data codewords
DataBlock[] result = new DataBlock[totalBlocks]; DataBlock[] result = new DataBlock[totalBlocks];
int numResultBlocks = 0; int numRXingResultBlocks = 0;
for (Version.ECB ecBlock : ecBlockArray) { for (Version.ECB ecBlock : ecBlockArray) {
for (int i = 0; i < ecBlock.getCount(); i++) { for (int i = 0; i < ecBlock.getCount(); i++) {
int numDataCodewords = ecBlock.getDataCodewords(); int numDataCodewords = ecBlock.getDataCodewords();
int numBlockCodewords = ecBlocks.getECCodewords() + numDataCodewords; int numBlockCodewords = ecBlocks.getECCodewords() + numDataCodewords;
result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); result[numRXingResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]);
} }
} }
@@ -78,14 +78,14 @@ final class DataBlock {
// first fill out as many elements as all of them have minus 1 // first fill out as many elements as all of them have minus 1
int rawCodewordsOffset = 0; int rawCodewordsOffset = 0;
for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { for (int i = 0; i < shorterBlocksNumDataCodewords; i++) {
for (int j = 0; j < numResultBlocks; j++) { for (int j = 0; j < numRXingResultBlocks; j++) {
result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; result[j].codewords[i] = rawCodewords[rawCodewordsOffset++];
} }
} }
// Fill out the last data block in the longer ones // Fill out the last data block in the longer ones
boolean specialVersion = version.getVersionNumber() == 24; boolean specialVersion = version.getVersionNumber() == 24;
int numLongerBlocks = specialVersion ? 8 : numResultBlocks; int numLongerBlocks = specialVersion ? 8 : numRXingResultBlocks;
for (int j = 0; j < numLongerBlocks; j++) { for (int j = 0; j < numLongerBlocks; j++) {
result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++]; result[j].codewords[longerBlocksNumDataCodewords - 1] = rawCodewords[rawCodewordsOffset++];
} }
@@ -93,8 +93,8 @@ final class DataBlock {
// Now add in error correction blocks // Now add in error correction blocks
int max = result[0].codewords.length; int max = result[0].codewords.length;
for (int i = longerBlocksNumDataCodewords; i < max; i++) { for (int i = longerBlocksNumDataCodewords; i < max; i++) {
for (int j = 0; j < numResultBlocks; j++) { for (int j = 0; j < numRXingResultBlocks; j++) {
int jOffset = specialVersion ? (j + 8) % numResultBlocks : j; int jOffset = specialVersion ? (j + 8) % numRXingResultBlocks : j;
int iOffset = specialVersion && jOffset > 7 ? i - 1 : i; int iOffset = specialVersion && jOffset > 7 ? i - 1 : i;
result[jOffset].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; result[jOffset].codewords[iOffset] = rawCodewords[rawCodewordsOffset++];
} }

View File

@@ -18,7 +18,7 @@ package com.google.zxing.datamatrix.decoder;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.common.BitSource; import com.google.zxing.common.BitSource;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.common.ECIStringBuilder; import com.google.zxing.common.ECIStringBuilder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@@ -86,7 +86,7 @@ final class DecodedBitStreamParser {
private DecodedBitStreamParser() { private DecodedBitStreamParser() {
} }
static DecoderResult decode(byte[] bytes) throws FormatException { static DecoderRXingResult decode(byte[] bytes) throws FormatException {
BitSource bits = new BitSource(bytes); BitSource bits = new BitSource(bytes);
ECIStringBuilder result = new ECIStringBuilder(100); ECIStringBuilder result = new ECIStringBuilder(100);
StringBuilder resultTrailer = new StringBuilder(0); StringBuilder resultTrailer = new StringBuilder(0);
@@ -149,7 +149,7 @@ final class DecodedBitStreamParser {
} }
} }
return new DecoderResult(bytes, return new DecoderRXingResult(bytes,
result.toString(), result.toString(),
byteSegments.isEmpty() ? null : byteSegments, byteSegments.isEmpty() ? null : byteSegments,
null, null,

View File

@@ -19,7 +19,7 @@ package com.google.zxing.datamatrix.decoder;
import com.google.zxing.ChecksumException; import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.common.reedsolomon.GenericGF; import com.google.zxing.common.reedsolomon.GenericGF;
import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
import com.google.zxing.common.reedsolomon.ReedSolomonException; import com.google.zxing.common.reedsolomon.ReedSolomonException;
@@ -47,7 +47,7 @@ public final class Decoder {
* @throws FormatException if the Data Matrix Code cannot be decoded * @throws FormatException if the Data Matrix Code cannot be decoded
* @throws ChecksumException if error correction fails * @throws ChecksumException if error correction fails
*/ */
public DecoderResult decode(boolean[][] image) throws FormatException, ChecksumException { public DecoderRXingResult decode(boolean[][] image) throws FormatException, ChecksumException {
return decode(BitMatrix.parse(image)); return decode(BitMatrix.parse(image));
} }
@@ -60,7 +60,7 @@ public final class Decoder {
* @throws FormatException if the Data Matrix Code cannot be decoded * @throws FormatException if the Data Matrix Code cannot be decoded
* @throws ChecksumException if error correction fails * @throws ChecksumException if error correction fails
*/ */
public DecoderResult decode(BitMatrix bits) throws FormatException, ChecksumException { public DecoderRXingResult decode(BitMatrix bits) throws FormatException, ChecksumException {
// Construct a parser and read version, error-correction level // Construct a parser and read version, error-correction level
BitMatrixParser parser = new BitMatrixParser(bits); BitMatrixParser parser = new BitMatrixParser(bits);

View File

@@ -17,9 +17,9 @@
package com.google.zxing.datamatrix.detector; package com.google.zxing.datamatrix.detector;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DetectorResult; import com.google.zxing.common.DetectorRXingResult;
import com.google.zxing.common.GridSampler; import com.google.zxing.common.GridSampler;
import com.google.zxing.common.detector.WhiteRectangleDetector; import com.google.zxing.common.detector.WhiteRectangleDetector;
@@ -42,14 +42,14 @@ public final class Detector {
/** /**
* <p>Detects a Data Matrix Code in an image.</p> * <p>Detects a Data Matrix Code in an image.</p>
* *
* @return {@link DetectorResult} encapsulating results of detecting a Data Matrix Code * @return {@link DetectorRXingResult} encapsulating results of detecting a Data Matrix Code
* @throws NotFoundException if no Data Matrix Code can be found * @throws NotFoundException if no Data Matrix Code can be found
*/ */
public DetectorResult detect() throws NotFoundException { public DetectorRXingResult detect() throws NotFoundException {
ResultPoint[] cornerPoints = rectangleDetector.detect(); RXingResultPoint[] cornerPoints = rectangleDetector.detect();
ResultPoint[] points = detectSolid1(cornerPoints); RXingResultPoint[] points = detectSolid1(cornerPoints);
points = detectSolid2(points); points = detectSolid2(points);
points[3] = correctTopRight(points); points[3] = correctTopRight(points);
if (points[3] == null) { if (points[3] == null) {
@@ -57,10 +57,10 @@ public final class Detector {
} }
points = shiftToModuleCenter(points); points = shiftToModuleCenter(points);
ResultPoint topLeft = points[0]; RXingResultPoint topLeft = points[0];
ResultPoint bottomLeft = points[1]; RXingResultPoint bottomLeft = points[1];
ResultPoint bottomRight = points[2]; RXingResultPoint bottomRight = points[2];
ResultPoint topRight = points[3]; RXingResultPoint topRight = points[3];
int dimensionTop = transitionsBetween(topLeft, topRight) + 1; int dimensionTop = transitionsBetween(topLeft, topRight) + 1;
int dimensionRight = transitionsBetween(bottomRight, topRight) + 1; int dimensionRight = transitionsBetween(bottomRight, topRight) + 1;
@@ -84,16 +84,16 @@ public final class Detector {
dimensionTop, dimensionTop,
dimensionRight); dimensionRight);
return new DetectorResult(bits, new ResultPoint[]{topLeft, bottomLeft, bottomRight, topRight}); return new DetectorRXingResult(bits, new RXingResultPoint[]{topLeft, bottomLeft, bottomRight, topRight});
} }
private static ResultPoint shiftPoint(ResultPoint point, ResultPoint to, int div) { private static RXingResultPoint shiftPoint(RXingResultPoint point, RXingResultPoint to, int div) {
float x = (to.getX() - point.getX()) / (div + 1); float x = (to.getX() - point.getX()) / (div + 1);
float y = (to.getY() - point.getY()) / (div + 1); float y = (to.getY() - point.getY()) / (div + 1);
return new ResultPoint(point.getX() + x, point.getY() + y); return new RXingResultPoint(point.getX() + x, point.getY() + y);
} }
private static ResultPoint moveAway(ResultPoint point, float fromX, float fromY) { private static RXingResultPoint moveAway(RXingResultPoint point, float fromX, float fromY) {
float x = point.getX(); float x = point.getX();
float y = point.getY(); float y = point.getY();
@@ -109,19 +109,19 @@ public final class Detector {
y += 1; y += 1;
} }
return new ResultPoint(x, y); return new RXingResultPoint(x, y);
} }
/** /**
* Detect a solid side which has minimum transition. * Detect a solid side which has minimum transition.
*/ */
private ResultPoint[] detectSolid1(ResultPoint[] cornerPoints) { private RXingResultPoint[] detectSolid1(RXingResultPoint[] cornerPoints) {
// 0 2 // 0 2
// 1 3 // 1 3
ResultPoint pointA = cornerPoints[0]; RXingResultPoint pointA = cornerPoints[0];
ResultPoint pointB = cornerPoints[1]; RXingResultPoint pointB = cornerPoints[1];
ResultPoint pointC = cornerPoints[3]; RXingResultPoint pointC = cornerPoints[3];
ResultPoint pointD = cornerPoints[2]; RXingResultPoint pointD = cornerPoints[2];
int trAB = transitionsBetween(pointA, pointB); int trAB = transitionsBetween(pointA, pointB);
int trBC = transitionsBetween(pointB, pointC); int trBC = transitionsBetween(pointB, pointC);
@@ -132,7 +132,7 @@ public final class Detector {
// : : // : :
// 1--2 // 1--2
int min = trAB; int min = trAB;
ResultPoint[] points = {pointD, pointA, pointB, pointC}; RXingResultPoint[] points = {pointD, pointA, pointB, pointC};
if (min > trBC) { if (min > trBC) {
min = trBC; min = trBC;
points[0] = pointA; points[0] = pointA;
@@ -160,20 +160,20 @@ public final class Detector {
/** /**
* Detect a second solid side next to first solid side. * Detect a second solid side next to first solid side.
*/ */
private ResultPoint[] detectSolid2(ResultPoint[] points) { private RXingResultPoint[] detectSolid2(RXingResultPoint[] points) {
// A..D // A..D
// : : // : :
// B--C // B--C
ResultPoint pointA = points[0]; RXingResultPoint pointA = points[0];
ResultPoint pointB = points[1]; RXingResultPoint pointB = points[1];
ResultPoint pointC = points[2]; RXingResultPoint pointC = points[2];
ResultPoint pointD = points[3]; RXingResultPoint pointD = points[3];
// Transition detection on the edge is not stable. // Transition detection on the edge is not stable.
// To safely detect, shift the points to the module center. // To safely detect, shift the points to the module center.
int tr = transitionsBetween(pointA, pointD); int tr = transitionsBetween(pointA, pointD);
ResultPoint pointBs = shiftPoint(pointB, pointC, (tr + 1) * 4); RXingResultPoint pointBs = shiftPoint(pointB, pointC, (tr + 1) * 4);
ResultPoint pointCs = shiftPoint(pointC, pointB, (tr + 1) * 4); RXingResultPoint pointCs = shiftPoint(pointC, pointB, (tr + 1) * 4);
int trBA = transitionsBetween(pointBs, pointA); int trBA = transitionsBetween(pointBs, pointA);
int trCD = transitionsBetween(pointCs, pointD); int trCD = transitionsBetween(pointCs, pointD);
@@ -200,28 +200,28 @@ public final class Detector {
/** /**
* Calculates the corner position of the white top right module. * Calculates the corner position of the white top right module.
*/ */
private ResultPoint correctTopRight(ResultPoint[] points) { private RXingResultPoint correctTopRight(RXingResultPoint[] points) {
// A..D // A..D
// | : // | :
// B--C // B--C
ResultPoint pointA = points[0]; RXingResultPoint pointA = points[0];
ResultPoint pointB = points[1]; RXingResultPoint pointB = points[1];
ResultPoint pointC = points[2]; RXingResultPoint pointC = points[2];
ResultPoint pointD = points[3]; RXingResultPoint pointD = points[3];
// shift points for safe transition detection. // shift points for safe transition detection.
int trTop = transitionsBetween(pointA, pointD); int trTop = transitionsBetween(pointA, pointD);
int trRight = transitionsBetween(pointB, pointD); int trRight = transitionsBetween(pointB, pointD);
ResultPoint pointAs = shiftPoint(pointA, pointB, (trRight + 1) * 4); RXingResultPoint pointAs = shiftPoint(pointA, pointB, (trRight + 1) * 4);
ResultPoint pointCs = shiftPoint(pointC, pointB, (trTop + 1) * 4); RXingResultPoint pointCs = shiftPoint(pointC, pointB, (trTop + 1) * 4);
trTop = transitionsBetween(pointAs, pointD); trTop = transitionsBetween(pointAs, pointD);
trRight = transitionsBetween(pointCs, pointD); trRight = transitionsBetween(pointCs, pointD);
ResultPoint candidate1 = new ResultPoint( RXingResultPoint candidate1 = new RXingResultPoint(
pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop + 1), pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop + 1),
pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop + 1)); pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop + 1));
ResultPoint candidate2 = new ResultPoint( RXingResultPoint candidate2 = new RXingResultPoint(
pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight + 1), pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight + 1),
pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight + 1)); pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight + 1));
@@ -248,22 +248,22 @@ public final class Detector {
/** /**
* Shift the edge points to the module center. * Shift the edge points to the module center.
*/ */
private ResultPoint[] shiftToModuleCenter(ResultPoint[] points) { private RXingResultPoint[] shiftToModuleCenter(RXingResultPoint[] points) {
// A..D // A..D
// | : // | :
// B--C // B--C
ResultPoint pointA = points[0]; RXingResultPoint pointA = points[0];
ResultPoint pointB = points[1]; RXingResultPoint pointB = points[1];
ResultPoint pointC = points[2]; RXingResultPoint pointC = points[2];
ResultPoint pointD = points[3]; RXingResultPoint pointD = points[3];
// calculate pseudo dimensions // calculate pseudo dimensions
int dimH = transitionsBetween(pointA, pointD) + 1; int dimH = transitionsBetween(pointA, pointD) + 1;
int dimV = transitionsBetween(pointC, pointD) + 1; int dimV = transitionsBetween(pointC, pointD) + 1;
// shift points for safe dimension detection // shift points for safe dimension detection
ResultPoint pointAs = shiftPoint(pointA, pointB, dimV * 4); RXingResultPoint pointAs = shiftPoint(pointA, pointB, dimV * 4);
ResultPoint pointCs = shiftPoint(pointC, pointB, dimH * 4); RXingResultPoint pointCs = shiftPoint(pointC, pointB, dimH * 4);
// calculate more precise dimensions // calculate more precise dimensions
dimH = transitionsBetween(pointAs, pointD) + 1; dimH = transitionsBetween(pointAs, pointD) + 1;
@@ -284,8 +284,8 @@ public final class Detector {
pointC = moveAway(pointC, centerX, centerY); pointC = moveAway(pointC, centerX, centerY);
pointD = moveAway(pointD, centerX, centerY); pointD = moveAway(pointD, centerX, centerY);
ResultPoint pointBs; RXingResultPoint pointBs;
ResultPoint pointDs; RXingResultPoint pointDs;
// shift points to the center of each modules // shift points to the center of each modules
pointAs = shiftPoint(pointA, pointB, dimV * 4); pointAs = shiftPoint(pointA, pointB, dimV * 4);
@@ -297,18 +297,18 @@ public final class Detector {
pointDs = shiftPoint(pointD, pointC, dimV * 4); pointDs = shiftPoint(pointD, pointC, dimV * 4);
pointDs = shiftPoint(pointDs, pointA, dimH * 4); pointDs = shiftPoint(pointDs, pointA, dimH * 4);
return new ResultPoint[]{pointAs, pointBs, pointCs, pointDs}; return new RXingResultPoint[]{pointAs, pointBs, pointCs, pointDs};
} }
private boolean isValid(ResultPoint p) { private boolean isValid(RXingResultPoint p) {
return p.getX() >= 0 && p.getX() <= image.getWidth() - 1 && p.getY() > 0 && p.getY() <= image.getHeight() - 1; return p.getX() >= 0 && p.getX() <= image.getWidth() - 1 && p.getY() > 0 && p.getY() <= image.getHeight() - 1;
} }
private static BitMatrix sampleGrid(BitMatrix image, private static BitMatrix sampleGrid(BitMatrix image,
ResultPoint topLeft, RXingResultPoint topLeft,
ResultPoint bottomLeft, RXingResultPoint bottomLeft,
ResultPoint bottomRight, RXingResultPoint bottomRight,
ResultPoint topRight, RXingResultPoint topRight,
int dimensionX, int dimensionX,
int dimensionY) throws NotFoundException { int dimensionY) throws NotFoundException {
@@ -338,7 +338,7 @@ public final class Detector {
/** /**
* Counts the number of black/white transitions between two points, using something like Bresenham's algorithm. * Counts the number of black/white transitions between two points, using something like Bresenham's algorithm.
*/ */
private int transitionsBetween(ResultPoint from, ResultPoint to) { private int transitionsBetween(RXingResultPoint from, RXingResultPoint to) {
// See QR Code Detector, sizeOfBlackWhiteBlackRun() // See QR Code Detector, sizeOfBlackWhiteBlackRun()
int fromX = (int) from.getX(); int fromX = (int) from.getX();
int fromY = (int) from.getY(); int fromY = (int) from.getY();

View File

@@ -251,7 +251,7 @@ public final class MinimalEncoder {
addEdge(edges, new Edge(input, Mode.EDF, from, 4, previous)); addEdge(edges, new Edge(input, Mode.EDF, from, 4, previous));
} }
} }
static Result encodeMinimally(Input input) { static RXingResult encodeMinimally(Input input) {
@SuppressWarnings("checkstyle:lineLength") @SuppressWarnings("checkstyle:lineLength")
/* The minimal encoding is computed by Dijkstra. The acyclic graph is modeled as follows: /* The minimal encoding is computed by Dijkstra. The acyclic graph is modeled as follows:
@@ -474,7 +474,7 @@ public final class MinimalEncoder {
if (minimalJ < 0) { if (minimalJ < 0) {
throw new RuntimeException("Internal error: failed to encode \"" + input + "\""); throw new RuntimeException("Internal error: failed to encode \"" + input + "\"");
} }
return new Result(edges[inputLength][minimalJ]); return new RXingResult(edges[inputLength][minimalJ]);
} }
private static final class Edge { private static final class Edge {
@@ -926,11 +926,11 @@ public final class MinimalEncoder {
} }
} }
private static final class Result { private static final class RXingResult {
private final byte[] bytes; private final byte[] bytes;
Result(Edge solution) { RXingResult(Edge solution) {
Input input = solution.input; Input input = solution.input;
int size = 0; int size = 0;
List<Byte> bytesAL = new ArrayList<>(); List<Byte> bytesAL = new ArrayList<>();

View File

@@ -23,11 +23,11 @@ import com.google.zxing.DecodeHintType;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.NotFoundException; import com.google.zxing.NotFoundException;
import com.google.zxing.Reader; import com.google.zxing.Reader;
import com.google.zxing.Result; import com.google.zxing.RXingResult;
import com.google.zxing.ResultMetadataType; import com.google.zxing.RXingResultMetadataType;
import com.google.zxing.ResultPoint; import com.google.zxing.RXingResultPoint;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.maxicode.decoder.Decoder; import com.google.zxing.maxicode.decoder.Decoder;
import java.util.Map; import java.util.Map;
@@ -37,7 +37,7 @@ import java.util.Map;
*/ */
public final class MaxiCodeReader implements Reader { public final class MaxiCodeReader implements Reader {
private static final ResultPoint[] NO_POINTS = new ResultPoint[0]; private static final RXingResultPoint[] NO_POINTS = new RXingResultPoint[0];
private static final int MATRIX_WIDTH = 30; private static final int MATRIX_WIDTH = 30;
private static final int MATRIX_HEIGHT = 33; private static final int MATRIX_HEIGHT = 33;
@@ -52,22 +52,22 @@ public final class MaxiCodeReader implements Reader {
* @throws ChecksumException if error correction fails * @throws ChecksumException if error correction fails
*/ */
@Override @Override
public Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException { public RXingResult decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException {
return decode(image, null); return decode(image, null);
} }
@Override @Override
public Result decode(BinaryBitmap image, Map<DecodeHintType,?> hints) public RXingResult decode(BinaryBitmap image, Map<DecodeHintType,?> hints)
throws NotFoundException, ChecksumException, FormatException { throws NotFoundException, ChecksumException, FormatException {
// Note that MaxiCode reader effectively always assumes PURE_BARCODE mode // Note that MaxiCode reader effectively always assumes PURE_BARCODE mode
// and can't detect it in an image // and can't detect it in an image
BitMatrix bits = extractPureBits(image.getBlackMatrix()); BitMatrix bits = extractPureBits(image.getBlackMatrix());
DecoderResult decoderResult = decoder.decode(bits, hints); DecoderRXingResult decoderRXingResult = decoder.decode(bits, hints);
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), NO_POINTS, BarcodeFormat.MAXICODE); RXingResult result = new RXingResult(decoderRXingResult.getText(), decoderRXingResult.getRawBytes(), NO_POINTS, BarcodeFormat.MAXICODE);
String ecLevel = decoderResult.getECLevel(); String ecLevel = decoderRXingResult.getECLevel();
if (ecLevel != null) { if (ecLevel != null) {
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel); result.putMetadata(RXingResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
} }
return result; return result;
} }

View File

@@ -17,7 +17,7 @@
package com.google.zxing.maxicode.decoder; package com.google.zxing.maxicode.decoder;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.NumberFormat; import java.text.NumberFormat;
@@ -84,7 +84,7 @@ final class DecodedBitStreamParser {
private DecodedBitStreamParser() { private DecodedBitStreamParser() {
} }
static DecoderResult decode(byte[] bytes, int mode) throws FormatException { static DecoderRXingResult decode(byte[] bytes, int mode) throws FormatException {
StringBuilder result = new StringBuilder(144); StringBuilder result = new StringBuilder(144);
switch (mode) { switch (mode) {
case 2: case 2:
@@ -118,7 +118,7 @@ final class DecodedBitStreamParser {
result.append(getMessage(bytes, 1, 77)); result.append(getMessage(bytes, 1, 77));
break; break;
} }
return new DecoderResult(bytes, result.toString(), null, String.valueOf(mode)); return new DecoderRXingResult(bytes, result.toString(), null, String.valueOf(mode));
} }
private static int getBit(int bit, byte[] bytes) { private static int getBit(int bit, byte[] bytes) {

View File

@@ -20,7 +20,7 @@ import com.google.zxing.ChecksumException;
import com.google.zxing.DecodeHintType; import com.google.zxing.DecodeHintType;
import com.google.zxing.FormatException; import com.google.zxing.FormatException;
import com.google.zxing.common.BitMatrix; import com.google.zxing.common.BitMatrix;
import com.google.zxing.common.DecoderResult; import com.google.zxing.common.DecoderRXingResult;
import com.google.zxing.common.reedsolomon.GenericGF; import com.google.zxing.common.reedsolomon.GenericGF;
import com.google.zxing.common.reedsolomon.ReedSolomonDecoder; import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
import com.google.zxing.common.reedsolomon.ReedSolomonException; import com.google.zxing.common.reedsolomon.ReedSolomonException;
@@ -45,11 +45,11 @@ public final class Decoder {
rsDecoder = new ReedSolomonDecoder(GenericGF.MAXICODE_FIELD_64); rsDecoder = new ReedSolomonDecoder(GenericGF.MAXICODE_FIELD_64);
} }
public DecoderResult decode(BitMatrix bits) throws ChecksumException, FormatException { public DecoderRXingResult decode(BitMatrix bits) throws ChecksumException, FormatException {
return decode(bits, null); return decode(bits, null);
} }
public DecoderResult decode(BitMatrix bits, public DecoderRXingResult decode(BitMatrix bits,
Map<DecodeHintType,?> hints) throws FormatException, ChecksumException { Map<DecodeHintType,?> hints) throws FormatException, ChecksumException {
BitMatrixParser parser = new BitMatrixParser(bits); BitMatrixParser parser = new BitMatrixParser(bits);
byte[] codewords = parser.readCodewords(); byte[] codewords = parser.readCodewords();

Some files were not shown because too many files have changed in this diff Show More