fix log to reflect reality
[zxing.git] / csharp / client / result / TelResultParser.cs
1 /*\r
2 * Copyright 2008 ZXing authors\r
3 *\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
7 *\r
8 *      http://www.apache.org/licenses/LICENSE-2.0\r
9 *\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
15 */\r
16 using System;\r
17 using Result = com.google.zxing.Result;\r
18 namespace com.google.zxing.client.result\r
19 {\r
20         \r
21         /// <summary> Parses a "tel:" URI result, which specifies a phone number.\r
22         /// \r
23         /// </summary>\r
24         /// <author>  Sean Owen\r
25         /// </author>\r
26         /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
27         /// </author>\r
28         sealed class TelResultParser:ResultParser\r
29         {\r
30                 \r
31                 private TelResultParser()\r
32                 {\r
33                 }\r
34                 \r
35                 public static TelParsedResult parse(Result result)\r
36                 {\r
37                         System.String rawText = result.Text;\r
38                         if (rawText == null || (!rawText.StartsWith("tel:") && !rawText.StartsWith("TEL:")))\r
39                         {\r
40                                 return null;\r
41                         }\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
49                 }\r
50         }\r
51 }