/*
- * Copyright 2008 Google Inc.
+ * 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.
package com.google.zxing.client.result;
-import com.google.zxing.Result;
-
/**
- * Represents a "tel:" URI result, which specifies a phone number.
- *
- * @author srowen@google.com (Sean Owen)
+ * @author Sean Owen
*/
-public final class TelParsedResult extends ParsedReaderResult {
+public final class TelParsedResult extends ParsedResult {
private final String number;
+ private final String telURI;
+ private final String title;
- private TelParsedResult(String number) {
- super(ParsedReaderResultType.TEL);
+ public TelParsedResult(String number, String telURI, String title) {
+ super(ParsedResultType.TEL);
this.number = number;
- }
-
- public static TelParsedResult parse(Result result) {
- String rawText = result.getText();
- if (rawText == null || !rawText.startsWith("tel:")) {
- return null;
- }
- // Drop tel, query portion
- int queryStart = rawText.indexOf('?', 4);
- if (queryStart < 0) {
- rawText = rawText.substring(4);
- } else {
- rawText = rawText.substring(4, queryStart);
- }
- return new TelParsedResult(rawText);
+ this.telURI = telURI;
+ this.title = title;
}
public String getNumber() {
return number;
}
+ public String getTelURI() {
+ return telURI;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
public String getDisplayResult() {
- return number;
+ StringBuffer result = new StringBuffer(20);
+ maybeAppend(number, result);
+ maybeAppend(title, result);
+ return result.toString();
}
}
\ No newline at end of file