git-svn-id: http://zxing.googlecode.com/svn/trunk@290 59b500cc-1b3d-0410-9834-0bbf25f...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 17 Mar 2008 18:41:10 +0000 (18:41 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Mon, 17 Mar 2008 18:41:10 +0000 (18:41 +0000)
core/src/com/google/zxing/client/result/AbstractDoCoMoResult.java [deleted file]
core/src/com/google/zxing/client/result/AddressBookAUResult.java [deleted file]
core/src/com/google/zxing/client/result/AddressBookDoCoMoResult.java [deleted file]
core/src/com/google/zxing/client/result/BookmarkDoCoMoResult.java [deleted file]
core/src/com/google/zxing/client/result/EmailAddressResult.java [deleted file]
core/src/com/google/zxing/client/result/EmailDoCoMoResult.java [deleted file]
core/src/com/google/zxing/client/result/URLTOResult.java [deleted file]

diff --git a/core/src/com/google/zxing/client/result/AbstractDoCoMoResult.java b/core/src/com/google/zxing/client/result/AbstractDoCoMoResult.java
deleted file mode 100644 (file)
index 88a4024..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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;
-
-import java.util.Vector;
-
-/**
- * <p>See
- * <a href="http://www.nttdocomo.co.jp/english/service/imode/make/content/barcode/about/s2.html">
- * DoCoMo's documentation</a> about the result types represented by subclasses of this class.</p>
- *
- * <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
- * on exception-based mechanisms during parsing.</p>
- *
- * @author srowen@google.com (Sean Owen)
- */
-abstract class AbstractDoCoMoResult extends ParsedReaderResult {
-
-  AbstractDoCoMoResult(ParsedReaderResultType type) {
-    super(type);
-  }
-
-  // This could as well be implemented with java.util.regex. It was already implemented partially
-  // to run in a J2ME enviroment, where this unavailable.
-
-  static String[] matchPrefixedField(String prefix, String rawText) {
-    return matchPrefixedField(prefix, rawText, ';');
-  }
-
-  static String[] matchPrefixedField(String prefix, String rawText, char endChar) {
-    Vector matches = null;
-    int i = 0;
-    int max = rawText.length();
-    while (i < max) {
-      i = rawText.indexOf(prefix, i);
-      if (i < 0) {
-        break;
-      }
-      i += prefix.length(); // Skip past this prefix we found to start
-      int start = i; // Found the start of a match here
-      boolean done = false;
-      while (!done) {
-        i = rawText.indexOf((int) endChar, i);
-        if (i < 0) {
-          // No terminating end character? uh, 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 (matches == null) {
-            matches = new Vector(3); // lazy init
-          }
-          matches.addElement(unescape(rawText.substring(start, i)));
-          i++;
-          done = true;
-        }
-      }
-    }
-    if (matches == null || matches.isEmpty()) {
-      return null;
-    }
-    int size = matches.size();
-    String[] result = new String[size];
-    for (int j = 0; j < size; j++) {
-      result[j] = (String) matches.elementAt(j);
-    }
-    return result;
-  }
-
-  static String matchSinglePrefixedField(String prefix, String rawText) {
-    return matchSinglePrefixedField(prefix, rawText, ';');
-  }
-
-  static String matchSinglePrefixedField(String prefix, String rawText, char endChar) {
-    String[] matches = matchPrefixedField(prefix, rawText, endChar);
-    return matches == null ? null : matches[0];
-  }
-
-  private static String unescape(String escaped) {
-    if (escaped != null) {
-      int backslash = escaped.indexOf((int) '\\');
-      if (backslash >= 0) {
-        int max = escaped.length();
-        StringBuffer unescaped = new StringBuffer(max - 1);
-        unescaped.append(escaped.toCharArray(), 0, backslash);
-        boolean nextIsEscaped = false;
-        for (int i = backslash; i < max; i++) {
-          char c = escaped.charAt(i);
-          if (nextIsEscaped || c != '\\') {
-            unescaped.append(c);
-            nextIsEscaped = false;
-          } else {
-            nextIsEscaped = true;
-          }
-        }
-        return unescaped.toString();
-      }
-    }
-    return escaped;
-  }
-
-  static void maybeAppend(String value, StringBuffer result) {
-    if (value != null) {
-      result.append('\n');
-      result.append(value);
-    }
-  }
-
-  static void maybeAppend(String[] value, StringBuffer result) {
-    if (value != null) {
-      for (int i = 0; i < value.length; i++) {
-        result.append('\n');
-        result.append(value[i]);
-      }
-    }
-  }
-
-}
\ No newline at end of file
diff --git a/core/src/com/google/zxing/client/result/AddressBookAUResult.java b/core/src/com/google/zxing/client/result/AddressBookAUResult.java
deleted file mode 100644 (file)
index 963d6b1..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2008 Google Inc.
- *
- * 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;
-
-import com.google.zxing.Result;
-
-import java.util.Vector;
-
-/**
- * Implements KDDI AU's address book format. See
- * <a href="http://www.au.kddi.com/ezfactory/tec/two_dimensions/index.html">
- * http://www.au.kddi.com/ezfactory/tec/two_dimensions/index.html</a>.
- * (Thanks to Yuzo for translating!)
- *
- * @author srowen@google.com (Sean Owen)
- */
-public final class AddressBookAUResult extends ParsedReaderResult {
-
-  private final String[] names;
-  private final String[] phoneNumbers;
-  private final String[] emails;
-  private final String note;
-  private final String address;
-
-  private AddressBookAUResult(String[] names, String[] phoneNumbers, String[] emails, String note, String address) {
-    super(ParsedReaderResultType.ADDRESSBOOK_AU);
-    this.names = names;
-    this.phoneNumbers = phoneNumbers;
-    this.emails = emails;
-    this.note = note;
-    this.address = address;
-  }
-
-  public static AddressBookAUResult parse(Result result) {
-    String rawText = result.getText();
-    // MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF
-    if (rawText.indexOf("MEMORY") < 0 || rawText.indexOf("\r\n") < 0) {
-      return null;
-    }
-    String[] names = matchMultipleValuePrefix("NAME", 2, rawText);
-    String[] phoneNumbers = matchMultipleValuePrefix("TEL", 3, rawText);
-    String[] emails = matchMultipleValuePrefix("MAIL", 3, rawText);
-    String note = AbstractDoCoMoResult.matchSinglePrefixedField("MEMORY", rawText, '\r');
-    String address = AbstractDoCoMoResult.matchSinglePrefixedField("ADD", rawText, '\r');
-    return new AddressBookAUResult(names, phoneNumbers, emails, note, address);
-  }
-
-  private static String[] matchMultipleValuePrefix(String prefix, int max, String rawText) {
-    Vector values = null;
-    for (int i = 1; i <= max; i++) {
-      String value = AbstractDoCoMoResult.matchSinglePrefixedField(prefix + i, rawText, '\r');
-      if (value == null) {
-        break;
-      }
-      if (values == null) {
-        values = new Vector(max); // lazy init
-      }
-      values.addElement(value);
-    }
-    if (values == null) {
-      return null;
-    }
-    String[] result = new String[values.size()];
-    for (int i = 0; i < result.length; i++) {
-      result[i] = (String) values.elementAt(i);
-    }
-    return result;
-  }
-
-  public String[] getNames() {
-    return names;
-  }
-
-  public String[] getPhoneNumbers() {
-    return phoneNumbers;
-  }
-
-  public String[] getEmails() {
-    return emails;
-  }
-
-  public String getNote() {
-    return note;
-  }
-
-  public String getAddress() {
-    return address;
-  }
-
-  public String getDisplayResult() {
-    StringBuffer result = new StringBuffer();
-    AbstractDoCoMoResult.maybeAppend(names, result);
-    AbstractDoCoMoResult.maybeAppend(emails, result);
-    AbstractDoCoMoResult.maybeAppend(address, result);
-    AbstractDoCoMoResult.maybeAppend(phoneNumbers, result);
-    AbstractDoCoMoResult.maybeAppend(note, result);
-    return result.toString();
-  }
-
-}
\ No newline at end of file
diff --git a/core/src/com/google/zxing/client/result/AddressBookDoCoMoResult.java b/core/src/com/google/zxing/client/result/AddressBookDoCoMoResult.java
deleted file mode 100644 (file)
index 0921a62..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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;
-
-import com.google.zxing.Result;
-
-/**
- * Implements the "MECARD" address book entry format.
- *
- * Supported keys: N, TEL, EMAIL, NOTE, ADR Unsupported keys: SOUND, TEL-AV, BDAY, URL, NICKNAME
- *
- * Except for TEL, multiple values for keys are also not supported;
- * the first one found takes precedence.
- *
- * @author srowen@google.com (Sean Owen)
- */
-public final class AddressBookDoCoMoResult extends AbstractDoCoMoResult {
-
-  private final String name;
-  private final String[] phoneNumbers;
-  private final String email;
-  private final String note;
-  private final String address;
-
-  private AddressBookDoCoMoResult(String name, String[] phoneNumbers, String email, String note, String address) {
-    super(ParsedReaderResultType.ADDRESSBOOK);
-    this.name = name;
-    this.phoneNumbers = phoneNumbers;
-    this.email = email;
-    this.note = note;
-    this.address = address;
-  }
-
-  public static AddressBookDoCoMoResult parse(Result result) {
-    String rawText = result.getText();
-    if (!rawText.startsWith("MECARD:")) {
-      return null;
-    }
-    String[] rawName = matchPrefixedField("N:", rawText);
-    if (rawName == null) {
-      return null;
-    }
-    String name = parseName(rawName[0]);
-    String[] phoneNumbers = matchPrefixedField("TEL:", rawText);
-    String email = matchSinglePrefixedField("EMAIL:", rawText);
-    String note = matchSinglePrefixedField("NOTE:", rawText);
-    String address = matchSinglePrefixedField("ADR:", rawText);
-    return new AddressBookDoCoMoResult(name, phoneNumbers, email, note, address);
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public String[] getPhoneNumbers() {
-    return phoneNumbers;
-  }
-
-  public String getEmail() {
-    return email;
-  }
-
-  public String getNote() {
-    return note;
-  }
-
-  public String getAddress() {
-    return address;
-  }
-
-  public String getDisplayResult() {
-    StringBuffer result = new StringBuffer(name);
-    maybeAppend(email, result);
-    maybeAppend(address, result);
-    maybeAppend(phoneNumbers, result);
-    maybeAppend(note, result);
-    return result.toString();
-  }
-
-  private static String parseName(String name) {
-    int comma = name.indexOf((int) ',');
-    if (comma >= 0) {
-      // Format may be last,first; switch it around
-      return name.substring(comma + 1) + ' ' + name.substring(0, comma);
-    }
-    return name;
-  }
-
-}
\ No newline at end of file
diff --git a/core/src/com/google/zxing/client/result/BookmarkDoCoMoResult.java b/core/src/com/google/zxing/client/result/BookmarkDoCoMoResult.java
deleted file mode 100644 (file)
index 3e97a74..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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;
-
-import com.google.zxing.Result;
-
-/**
- * @author srowen@google.com (Sean Owen)
- */
-public final class BookmarkDoCoMoResult extends AbstractDoCoMoResult {
-
-  private final String title;
-  private final String uri;
-
-  private BookmarkDoCoMoResult(String title, String uri) {
-    super(ParsedReaderResultType.BOOKMARK);
-    this.title = title;
-    this.uri = uri;
-  }
-
-  public static BookmarkDoCoMoResult parse(Result result) {
-    String rawText = result.getText();
-    if (!rawText.startsWith("MEBKM:")) {
-      return null;
-    }
-    String title = matchSinglePrefixedField("TITLE:", rawText);
-    String[] rawUri = matchPrefixedField("URL:", rawText);
-    if (rawUri == null) {
-      return null;
-    }
-    String uri = rawUri[0];
-    if (!URIParsedResult.isBasicallyValidURI(uri)) {
-      return null;
-    }
-    return new BookmarkDoCoMoResult(title, uri);
-  }
-
-  public String getTitle() {
-    return title;
-  }
-
-  public String getURI() {
-    return uri;
-  }
-
-  public String getDisplayResult() {
-    if (title == null) {
-      return uri;
-    } else {
-      return title + '\n' + uri;
-    }
-  }
-
-}
\ No newline at end of file
diff --git a/core/src/com/google/zxing/client/result/EmailAddressResult.java b/core/src/com/google/zxing/client/result/EmailAddressResult.java
deleted file mode 100644 (file)
index 9708da9..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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;
-
-import com.google.zxing.Result;
-
-/**
- * Represents a result that encodes an e-mail address, either as a plain address
- * like "joe@example.org" or a mailto: URL like "mailto:joe@example.org".
- *
- * @author srowen@google.com (Sean Owen)
- */
-public final class EmailAddressResult extends AbstractDoCoMoResult {
-
-  private final String emailAddress;
-
-  private EmailAddressResult(String emailAddress) {
-    super(ParsedReaderResultType.EMAIL_ADDRESS);
-    this.emailAddress = emailAddress;
-  }
-
-  public static EmailAddressResult parse(Result result) {
-    String rawText = result.getText();
-    String emailAddress;
-    if (rawText.startsWith("mailto:")) {
-      // If it starts with mailto:, assume it is definitely trying to be an email address
-      emailAddress = rawText.substring(7);
-    } else {
-      if (!EmailDoCoMoResult.isBasicallyValidEmailAddress(rawText)) {
-        return null;
-      }
-      emailAddress = rawText;
-    }
-    return new EmailAddressResult(emailAddress);
-  }
-
-  public String getEmailAddress() {
-    return emailAddress;
-  }
-
-  public String getDisplayResult() {
-    return emailAddress;
-  }
-
-}
\ No newline at end of file
diff --git a/core/src/com/google/zxing/client/result/EmailDoCoMoResult.java b/core/src/com/google/zxing/client/result/EmailDoCoMoResult.java
deleted file mode 100644 (file)
index 6457e0e..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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;
-
-import com.google.zxing.Result;
-
-/**
- * Implements the "MATMSG" email message entry format.
- *
- * Supported keys: TO, SUB, BODY
- *
- * @author srowen@google.com (Sean Owen)
- */
-public final class EmailDoCoMoResult extends AbstractDoCoMoResult {
-
-  private final String to;
-  private final String subject;
-  private final String body;
-
-  private EmailDoCoMoResult(String to, String subject, String body) {
-    super(ParsedReaderResultType.EMAIL);
-    this.to = to;
-    this.subject = subject;
-    this.body = body;
-  }
-
-  public static EmailDoCoMoResult parse(Result result) {
-    String rawText = result.getText();
-    if (!rawText.startsWith("MATMSG:")) {
-      return null;
-    }
-    String[] rawTo = matchPrefixedField("TO:", rawText);
-    if (rawTo == null) {
-      return null;
-    }
-    String to = rawTo[0];
-    if (!isBasicallyValidEmailAddress(to)) {
-      return null;
-    }
-    String subject = matchSinglePrefixedField("SUB:", rawText);
-    String body = matchSinglePrefixedField("BODY:", rawText);
-    return new EmailDoCoMoResult(to, subject, body);
-  }
-
-  public String getTo() {
-    return to;
-  }
-
-  public String getSubject() {
-    return subject;
-  }
-
-  public String getBody() {
-    return body;
-  }
-
-  public String getDisplayResult() {
-    StringBuffer result = new StringBuffer(to);
-    maybeAppend(subject, result);
-    maybeAppend(body, result);
-    return result.toString();
-  }
-
-  /**
-   * This implements only the most basic checking for an email address's validity -- that it contains
-   * an '@' and a '.' somewhere after that, and that it contains no space.
-   * We want to generally be lenient here since this class is only intended to encapsulate what's
-   * in a barcode, not "judge" it.
-   */
-  static boolean isBasicallyValidEmailAddress(String email) {
-    int atIndex = email.indexOf('@');
-    return atIndex >= 0 && email.indexOf('.') > atIndex && email.indexOf(' ') < 0;
-  }
-
-}
\ No newline at end of file
diff --git a/core/src/com/google/zxing/client/result/URLTOResult.java b/core/src/com/google/zxing/client/result/URLTOResult.java
deleted file mode 100644 (file)
index 3550390..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2007 Google Inc.
- *
- * 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;
-
-import com.google.zxing.Result;
-
-/**
- * "URLTO" result format, which is of the form "URLTO:[title]:[url]".
- * This seems to be used sometimes, but I am not able to find documentation
- * on its origin or official format?
- *
- * @author srowen@google.com (Sean Owen)
- */
-public final class URLTOResult extends ParsedReaderResult {
-
-  private final String title;
-  private final String uri;
-
-  private URLTOResult(String title, String uri) {
-    super(ParsedReaderResultType.URLTO);
-    this.title = title;
-    this.uri = uri;
-  }
-
-  public static URLTOResult parse(Result result) {
-    String rawText = result.getText();
-    if (!rawText.startsWith("URLTO:")) {
-      return null;
-    }
-    int titleEnd = rawText.indexOf(':', 6);
-    if (titleEnd < 0) {
-      return null;
-    }
-    String title = rawText.substring(6, titleEnd);
-    String uri = rawText.substring(titleEnd + 1);
-    return new URLTOResult(title, uri);
-  }
-
-  public String getTitle() {
-    return title;
-  }
-
-  public String getURI() {
-    return uri;
-  }
-
-  public String getDisplayResult() {
-    if (title == null) {
-      return uri;
-    } else {
-      return title + '\n' + uri;
-    }
-  }
-
-}
\ No newline at end of file