Issues 155.2 -- add %f for format
[zxing.git] / csharp / BarcodeFormat.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 namespace com.google.zxing\r
18 {\r
19         \r
20         /// <summary> Enumerates barcode formats known to this package.\r
21         /// \r
22         /// </summary>\r
23         /// <author>  Sean Owen\r
24         /// </author>\r
25         /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
26         /// </author>\r
27 \r
28         public sealed class BarcodeFormat\r
29         {\r
30                 public System.String Name\r
31                 {\r
32                         get\r
33                         {\r
34                                 return name;\r
35                         }\r
36                         \r
37                 }\r
38                 \r
39                 // No, we can't use an enum here. J2ME doesn't support it.\r
40                 \r
41                 //UPGRADE_NOTE: Final was removed from the declaration of 'VALUES '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
42                 private static readonly System.Collections.Hashtable VALUES = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());\r
43                 \r
44                 /// <summary>QR Code 2D barcode format. </summary>\r
45                 //UPGRADE_NOTE: Final was removed from the declaration of 'QR_CODE '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
46                 public static readonly BarcodeFormat QR_CODE = new BarcodeFormat("QR_CODE");\r
47                 \r
48                 /// <summary>DataMatrix 2D barcode format. </summary>\r
49                 //UPGRADE_NOTE: Final was removed from the declaration of 'DATAMATRIX '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
50                 public static readonly BarcodeFormat DATAMATRIX = new BarcodeFormat("DATAMATRIX");\r
51                 \r
52                 /// <summary>UPC-E 1D format. </summary>\r
53                 //UPGRADE_NOTE: Final was removed from the declaration of 'UPC_E '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
54                 public static readonly BarcodeFormat UPC_E = new BarcodeFormat("UPC_E");\r
55                 \r
56                 /// <summary>UPC-A 1D format. </summary>\r
57                 //UPGRADE_NOTE: Final was removed from the declaration of 'UPC_A '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
58                 public static readonly BarcodeFormat UPC_A = new BarcodeFormat("UPC_A");\r
59                 \r
60                 /// <summary>EAN-8 1D format. </summary>\r
61                 //UPGRADE_NOTE: Final was removed from the declaration of 'EAN_8 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
62                 public static readonly BarcodeFormat EAN_8 = new BarcodeFormat("EAN_8");\r
63                 \r
64                 /// <summary>EAN-13 1D format. </summary>\r
65                 //UPGRADE_NOTE: Final was removed from the declaration of 'EAN_13 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
66                 public static readonly BarcodeFormat EAN_13 = new BarcodeFormat("EAN_13");\r
67                 \r
68                 /// <summary>Code 128 1D format. </summary>\r
69                 //UPGRADE_NOTE: Final was removed from the declaration of 'CODE_128 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
70                 public static readonly BarcodeFormat CODE_128 = new BarcodeFormat("CODE_128");\r
71                 \r
72                 /// <summary>Code 39 1D format. </summary>\r
73                 //UPGRADE_NOTE: Final was removed from the declaration of 'CODE_39 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
74                 public static readonly BarcodeFormat CODE_39 = new BarcodeFormat("CODE_39");\r
75                 \r
76                 /// <summary>ITF (Interleaved Two of Five) 1D format. </summary>\r
77                 //UPGRADE_NOTE: Final was removed from the declaration of 'ITF '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
78                 public static readonly BarcodeFormat ITF = new BarcodeFormat("ITF");\r
79                 \r
80                 /// <summary>PDF417 format. </summary>\r
81                 //UPGRADE_NOTE: Final was removed from the declaration of 'PDF417 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
82                 public static readonly BarcodeFormat PDF417 = new BarcodeFormat("PDF417");\r
83                 \r
84                 //UPGRADE_NOTE: Final was removed from the declaration of 'name '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
85                 private System.String name;\r
86                 \r
87                 private BarcodeFormat(System.String name)\r
88                 {\r
89                         this.name = name;\r
90                         VALUES[name] = this;\r
91                 }\r
92                 \r
93                 public override System.String ToString()\r
94                 {\r
95                         return name;\r
96                 }\r
97                 \r
98                 public static BarcodeFormat valueOf(System.String name)\r
99                 {\r
100                         BarcodeFormat format = (BarcodeFormat) VALUES[name];\r
101                         if (format == null)\r
102                         {\r
103                                 throw new System.ArgumentException();\r
104                         }\r
105                         return format;\r
106                 }\r
107         }\r
108 }