2 * Copyright 2008 ZXing authors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 using Result = com.google.zxing.Result;
\r
18 namespace com.google.zxing.client.result
\r
21 /// <summary> Parses a "tel:" URI result, which specifies a phone number.
\r
24 /// <author> Sean Owen
\r
26 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
28 sealed class TelResultParser:ResultParser
\r
31 private TelResultParser()
\r
35 public static TelParsedResult parse(Result result)
\r
37 System.String rawText = result.Text;
\r
38 if (rawText == null || (!rawText.StartsWith("tel:") && !rawText.StartsWith("TEL:")))
\r
42 // Normalize "TEL:" to "tel:"
\r
43 System.String telURI = rawText.StartsWith("TEL:")?"tel:" + rawText.Substring(4):rawText;
\r
44 // Drop tel, query portion
\r
45 //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
\r
46 int queryStart = rawText.IndexOf('?', 4);
\r
47 System.String number = queryStart < 0?rawText.Substring(4):rawText.Substring(4, (queryStart) - (4));
\r
48 return new TelParsedResult(number, telURI, null);
\r