Issue 489 update the port
[zxing.git] / csharp / client / result / ParsedResult.cs
1 /*\r
2 * Copyright 2007 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> <p>Abstract class representing the result of decoding a barcode, as more than\r
22         /// a String -- as some type of structured data. This might be a subclass which represents\r
23         /// a URL, or an e-mail address. {@link ResultParser#parseResult(Result)} will turn a raw\r
24         /// decoded string into the most appropriate type of structured representation.</p>\r
25         /// \r
26         /// <p>Thanks to Jeff Griffin for proposing rewrite of these classes that relies less\r
27         /// on exception-based mechanisms during parsing.</p>\r
28         /// \r
29         /// </summary>\r
30         /// <author>  Sean Owen\r
31         /// </author>\r
32         /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
33         /// </author>\r
34         public abstract class ParsedResult\r
35         {\r
36                 virtual public ParsedResultType Type\r
37                 {\r
38                         get\r
39                         {\r
40                                 return type;\r
41                         }\r
42                         \r
43                 }\r
44                 public abstract System.String DisplayResult{get;}\r
45                 \r
46                 //UPGRADE_NOTE: Final was removed from the declaration of 'type '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
47                 private ParsedResultType type;\r
48                 \r
49                 protected internal ParsedResult(ParsedResultType type)\r
50                 {\r
51                         this.type = type;\r
52                 }\r
53                 \r
54                 public override System.String ToString()\r
55                 {\r
56                         return DisplayResult;\r
57                 }\r
58                 \r
59                 public static void  maybeAppend(System.String value_Renamed, System.Text.StringBuilder result)\r
60                 {\r
61                         if (value_Renamed != null && value_Renamed.Length > 0)\r
62                         {\r
63                                 // Don't add a newline before the first value\r
64                                 if (result.Length > 0)\r
65                                 {\r
66                                         result.Append('\n');\r
67                                 }\r
68                                 result.Append(value_Renamed);\r
69                         }\r
70                 }\r
71                 \r
72                 public static void  maybeAppend(System.String[] value_Renamed, System.Text.StringBuilder result)\r
73                 {\r
74                         if (value_Renamed != null)\r
75                         {\r
76                                 for (int i = 0; i < value_Renamed.Length; i++)\r
77                                 {\r
78                                         if (value_Renamed[i] != null && value_Renamed[i].Length > 0)\r
79                                         {\r
80                                                 if (result.Length > 0)\r
81                                                 {\r
82                                                         result.Append('\n');\r
83                                                 }\r
84                                                 result.Append(value_Renamed[i]);\r
85                                         }\r
86                                 }\r
87                         }\r
88                 }\r
89         }\r
90 }