Remove MobileTag support -- outdated, unused, and not clear we support the direction MobileTag is going

git-svn-id: https://zxing.googlecode.com/svn/trunk@1060 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-09-23 13:33:45 +00:00
parent e844ff06f4
commit 63b8253e10
9 changed files with 0 additions and 575 deletions

View file

@ -1,82 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.client.result.ResultParser;
/**
* <p>Superclass for classes encapsulating reader results encoded according
* to the MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
abstract class AbstractMobileTagResultParser extends ResultParser {
public static final int ACTION_DO = 1;
public static final int ACTION_EDIT = 2;
public static final int ACTION_SAVE = 4;
static String[] matchDelimitedFields(String rawText, int maxItems) {
String[] result = new String[maxItems];
int item = 0;
int i = 0;
int max = rawText.length();
while (item < maxItems && i < max) {
int start = i; // Found the start of a match here
boolean done = false;
while (!done) {
i = rawText.indexOf((int) '|', i);
if (i < 0) {
// No terminating end character? done. Set i such that loop terminates and break
i = rawText.length();
done = true;
} else if (rawText.charAt(i - 1) == '\\') {
// semicolon was escaped so continue
i++;
} else {
// found a match
if (start != i) {
result[item] = unescapeBackslash(rawText.substring(start, i));
}
item++;
i++;
done = true;
}
}
}
if (item < maxItems) {
return null;
}
return result;
}
static boolean isDigits(String s, int expectedLength) {
if (s == null) {
return true;
}
if (s.length() != expectedLength) {
return false;
}
for (int i = 0; i < expectedLength; i++) {
if (!Character.isDigit(s.charAt(i))) {
return false;
}
}
return true;
}
}

View file

@ -1,54 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.client.result.SMSParsedResult;
/**
* <p>Represents a "MMS" result encoded according to section 4.7 of the
* MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
final class MobileTagMMSResultParser extends AbstractMobileTagResultParser {
public static final String SERVICE_TYPE = "05";
public static SMSParsedResult parse(Result result) {
if (!result.getBarcodeFormat().equals(BarcodeFormat.DATAMATRIX)) {
return null;
}
String rawText = result.getText();
if (!rawText.startsWith(SERVICE_TYPE)) {
return null;
}
String[] matches = matchDelimitedFields(rawText.substring(2), 4);
if (matches == null) {
return null;
}
String to = matches[0];
String subject = matches[1];
String body = matches[2];
String title = matches[3];
return new SMSParsedResult("sms:" + to, to, null, subject, body, title);
}
}

View file

@ -1,59 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.client.result.ParsedResult;
import com.google.zxing.client.result.ParsedResultType;
/**
* @author Sean Owen
*/
public final class MobileTagRichWebParsedResult extends ParsedResult {
// Example: "http://www.tagserver.com/script.asp?id="
static final String TAGSERVER_URI_PREFIX = System.getProperty("zxing.mobiletag.tagserver");
private final String id;
private final int action;
MobileTagRichWebParsedResult(String id, int action) {
super(ParsedResultType.MOBILETAG_RICH_WEB);
this.id = id;
this.action = action;
}
public static String getTagserverURIPrefix() {
return TAGSERVER_URI_PREFIX;
}
public String getId() {
return id;
}
public int getAction() {
return action;
}
public String getTagserverURI() {
return TAGSERVER_URI_PREFIX + id;
}
public String getDisplayResult() {
return id;
}
}

View file

@ -1,65 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
/**
* <p>Represents a "rich web" result encoded according to section 5 of the
* MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
final class MobileTagRichWebResultParser extends AbstractMobileTagResultParser {
public static final String SERVICE_TYPE = "54";
private static final int DEFAULT_ACTION = ACTION_DO;
public static MobileTagRichWebParsedResult parse(Result result) {
if (MobileTagRichWebParsedResult.TAGSERVER_URI_PREFIX == null) {
return null;
}
if (!result.getBarcodeFormat().equals(BarcodeFormat.DATAMATRIX)) {
return null;
}
String rawText = result.getText();
if (!rawText.startsWith(SERVICE_TYPE)) {
return null;
}
int length = rawText.length();
if (!isDigits(rawText, length)) {
return null;
}
int action;
String id;
if (length == 15) {
action = DEFAULT_ACTION;
id = rawText.substring(0, 2) + action + rawText.substring(2);
} else if (length == 16) {
action = rawText.charAt(2) - '0';
id = rawText;
} else {
return null;
}
return new MobileTagRichWebParsedResult(id, action);
}
}

View file

@ -1,53 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.client.result.SMSParsedResult;
/**
* <p>Represents a "SMS" result encoded according to section 4.6 of the
* MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
final class MobileTagSMSResultParser extends AbstractMobileTagResultParser {
public static final String SERVICE_TYPE = "03";
public static SMSParsedResult parse(Result result) {
if (!result.getBarcodeFormat().equals(BarcodeFormat.DATAMATRIX)) {
return null;
}
String rawText = result.getText();
if (!rawText.startsWith(SERVICE_TYPE)) {
return null;
}
String[] matches = matchDelimitedFields(rawText.substring(2), 3);
if (matches == null) {
return null;
}
String to = matches[0];
String body = matches[1];
String title = matches[2];
return new SMSParsedResult("sms:" + to, to, null, null, body, title);
}
}

View file

@ -1,68 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.client.result.CalendarParsedResult;
/**
* <p>Represents a "simple calendar" result encoded according to section 4.9 of the
* MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
final class MobileTagSimpleCalendarResultParser extends AbstractMobileTagResultParser {
public static final String SERVICE_TYPE = "07";
public static CalendarParsedResult parse(Result result) {
if (!result.getBarcodeFormat().equals(BarcodeFormat.DATAMATRIX)) {
return null;
}
String rawText = result.getText();
if (!rawText.startsWith(SERVICE_TYPE)) {
return null;
}
String[] matches = matchDelimitedFields(rawText.substring(2), 6);
if (matches == null || !isDigits(matches[1], 10) || !isDigits(matches[2], 10)) {
return null;
}
String summary = matches[0];
String start = expandDateString(matches[1]);
String end = expandDateString(matches[2]);
String location = matches[3];
String attendee = matches[4];
String title = matches[5];
try {
return new CalendarParsedResult(summary, start, end, location, attendee, title);
} catch (IllegalArgumentException iae) {
return null;
}
}
private static String expandDateString(String date) {
if (date == null) {
return null;
}
// Input is of form YYMMddHHmmss, and needs to be YYYYMMdd'T'HHmmss'Z'
return "20" + date.substring(0, 6) + 'T' + date.substring(6) + "00Z";
}
}

View file

@ -1,71 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.client.result.AddressBookParsedResult;
/**
* <p>Represents a "simple contact" result encoded according to section 4.8 of the
* MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
final class MobileTagSimpleContactResultParser extends AbstractMobileTagResultParser {
public static final String SERVICE_TYPE = "02";
public static AddressBookParsedResult parse(Result result) {
if (!result.getBarcodeFormat().equals(BarcodeFormat.DATAMATRIX)) {
return null;
}
String rawText = result.getText();
if (!rawText.startsWith(SERVICE_TYPE)) {
return null;
}
String[] matches = matchDelimitedFields(rawText.substring(2), 9);
if (matches == null || !isDigits(matches[7], 8)) {
return null;
}
String fullName = matches[0];
String telephoneCell = matches[1];
String telephone = matches[2];
String email1 = matches[3];
String email2 = matches[4];
String address = matches[5];
String org = matches[6];
String birthday = matches[7];
if (!isStringOfDigits(birthday, 8)) {
return null;
}
String title = matches[8];
return new AddressBookParsedResult(new String[] {fullName},
null,
new String[] {telephoneCell, telephone},
new String[] {email1, email2},
null,
address,
org,
birthday,
title,
null);
}
}

View file

@ -1,71 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.client.result.URIParsedResult;
/**
* <p>Represents a "simple web" result encoded according to section 4.11 of the
* MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
final class MobileTagSimpleWebResultParser extends AbstractMobileTagResultParser {
public static final String SERVICE_TYPE = "04";
private static final String[] URI_PREFIXES = {
null,
"http://",
"http://www.",
"https://",
"https://www.",
"rtsp://",
};
public static URIParsedResult parse(Result result) {
if (!result.getBarcodeFormat().equals(BarcodeFormat.DATAMATRIX)) {
return null;
}
String rawText = result.getText();
if (!rawText.startsWith(SERVICE_TYPE)) {
return null;
}
String[] matches = matchDelimitedFields(rawText.substring(2), 2);
if (matches == null) {
return null;
}
String uri = matches[0];
String title = matches[1];
char maybePrefixChar = uri.charAt(2);
if (maybePrefixChar >= '0' && maybePrefixChar <= '9') {
int prefixIndex = maybePrefixChar - '0';
// Note that '0' is reserved
if (prefixIndex >= 1 && prefixIndex < URI_PREFIXES.length) {
uri = URI_PREFIXES[prefixIndex] + uri.substring(1);
} else {
uri = uri.substring(1);
}
}
return new URIParsedResult(uri, title);
}
}

View file

@ -1,52 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.client.result.optional;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.client.result.TelParsedResult;
/**
* <p>Represents a "TEL" result encoded according to section 4.4 of the
* MobileTag Reader International Specification.</p>
*
* @author Sean Owen
*/
final class MobileTagTelResultParser extends AbstractMobileTagResultParser {
public static final String SERVICE_TYPE = "01";
public static TelParsedResult parse(Result result) {
if (!result.getBarcodeFormat().equals(BarcodeFormat.DATAMATRIX)) {
return null;
}
String rawText = result.getText();
if (!rawText.startsWith(SERVICE_TYPE)) {
return null;
}
String[] matches = matchDelimitedFields(rawText.substring(2), 2);
if (matches == null) {
return null;
}
String number = matches[0];
String title = matches[1];
return new TelParsedResult(number, "tel:" + number, title);
}
}