Support SMTP URLs
[zxing.git] / core / src / com / google / zxing / client / result / AbstractDoCoMoResultParser.java
index 3b320e2..3d2c1d2 100644 (file)
@@ -16,8 +16,6 @@
 
 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">
@@ -26,68 +24,16 @@ import java.util.Vector;
  * <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)
+ * @author Sean Owen
  */
 abstract class AbstractDoCoMoResultParser extends ResultParser {
 
-  // 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(unescapeBackslash(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[] matchDoCoMoPrefixedField(String prefix, String rawText, boolean trim) {
+    return matchPrefixedField(prefix, rawText, ';', trim);
   }
 
-  static String matchSinglePrefixedField(String prefix, String rawText) {
-    return matchSinglePrefixedField(prefix, rawText, ';');
+  static String matchSingleDoCoMoPrefixedField(String prefix, String rawText, boolean trim) {
+    return matchSinglePrefixedField(prefix, rawText, ';', trim);
   }
 
-  static String matchSinglePrefixedField(String prefix, String rawText, char endChar) {
-    String[] matches = matchPrefixedField(prefix, rawText, endChar);
-    return matches == null ? null : matches[0];
-  }
-
-
-}
\ No newline at end of file
+}