One more change to accommodate differences in jpeg libraries. Some machines will...
[zxing.git] / csharp / client / result / VEventResultParser.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> Partially implements the iCalendar format's "VEVENT" format for specifying a\r
22         /// calendar event. See RFC 2445. This supports SUMMARY, DTSTART and DTEND fields.\r
23         /// \r
24         /// </summary>\r
25         /// <author>  Sean Owen\r
26         /// </author>\r
27         /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
28         /// </author>\r
29         sealed class VEventResultParser:ResultParser\r
30         {\r
31                 \r
32                 private VEventResultParser()\r
33                 {\r
34                 }\r
35                 \r
36                 public static CalendarParsedResult parse(Result result)\r
37                 {\r
38                         System.String rawText = result.Text;\r
39                         if (rawText == null)\r
40                         {\r
41                                 return null;\r
42                         }\r
43                         int vEventStart = rawText.IndexOf("BEGIN:VEVENT");\r
44                         if (vEventStart < 0)\r
45                         {\r
46                                 return null;\r
47                         }\r
48                         int vEventEnd = rawText.IndexOf("END:VEVENT");\r
49                         if (vEventEnd < 0)\r
50                         {\r
51                                 return null;\r
52                         }\r
53                         \r
54                         System.String summary = VCardResultParser.matchSingleVCardPrefixedField("SUMMARY", rawText, true);\r
55                         System.String start = VCardResultParser.matchSingleVCardPrefixedField("DTSTART", rawText, true);\r
56                         System.String end = VCardResultParser.matchSingleVCardPrefixedField("DTEND", rawText, true);\r
57                         try\r
58                         {\r
59                                 return new CalendarParsedResult(summary, start, end, null, null, null);\r
60                         }\r
61                         catch (System.ArgumentException iae)\r
62                         {\r
63                                 return null;\r
64                         }\r
65                 }\r
66         }\r
67 }