Add geo: URL support (oh and removed an old moved file)
[zxing.git] / core / src / com / google / zxing / client / result / ParsedReaderResult.java
index 18950c5..cff844d 100644 (file)
 
 package com.google.zxing.client.result;
 
+import com.google.zxing.Result;
+
 /**
  * <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 URL, or an e-mail address. {@link #parseReaderResult(String)} will turn a raw
+ * a URL, or an e-mail address. {@link #parseReaderResult(Result)} will turn a raw
  * 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
@@ -31,7 +33,7 @@ public abstract class ParsedReaderResult {
 
   private final ParsedReaderResultType type;
 
-  ParsedReaderResult(ParsedReaderResultType type) {
+  public ParsedReaderResult(ParsedReaderResultType type) {
     this.type = type;
   }
 
@@ -41,27 +43,31 @@ public abstract class ParsedReaderResult {
 
   public abstract String getDisplayResult();
 
-  public static ParsedReaderResult parseReaderResult(String rawText) {
+  public static ParsedReaderResult parseReaderResult(Result theResult) {
     // This is a bit messy, but given limited options in MIDP / CLDC, this may well be the simplest
     // way to go about this. For example, we have no reflection available, really.
     // Order is important here.
     ParsedReaderResult result;
-    if ((result = BookmarkDoCoMoResult.parse(rawText)) != null) {
+    if ((result = BookmarkDoCoMoResult.parse(theResult)) != null) {
+      return result;
+    } else if ((result = AddressBookDoCoMoResult.parse(theResult)) != null) {
+      return result;
+    } else if ((result = EmailDoCoMoResult.parse(theResult)) != null) {
       return result;
-    } else if ((result = AddressBookDoCoMoResult.parse(rawText)) != null) {
+    } else if ((result = EmailAddressResult.parse(theResult)) != null) {
       return result;
-    } else if ((result = EmailDoCoMoResult.parse(rawText)) != null) {
+    } else if ((result = AddressBookAUResult.parse(theResult)) != null) {
       return result;
-    } else if ((result = EmailAddressResult.parse(rawText)) != null) {
+    } else if ((result = GeoParsedResult.parse(theResult)) != null) {
       return result;
-    } else if ((result = URLTOResult.parse(rawText)) != null) {
+    } else if ((result = URLTOResult.parse(theResult)) != null) {
       return result;
-    } else if ((result = URIParsedResult.parse(rawText)) != null) {
+    } else if ((result = URIParsedResult.parse(theResult)) != null) {
       return result;
-    } else if ((result = UPCParsedResult.parse(rawText)) != null) {
+    } else if ((result = UPCParsedResult.parse(theResult)) != null) {
       return result;
     }
-    return TextParsedResult.parse(rawText);
+    return TextParsedResult.parse(theResult);
   }
 
   public String toString() {