-/*\r
+/*\r
+* Copyright 2008 ZXing authors\r
+*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
*/\r
+using System;\r
+using BarcodeFormat = com.google.zxing.BarcodeFormat;\r
+using DecodeHintType = com.google.zxing.DecodeHintType;\r
+using ReaderException = com.google.zxing.ReaderException;\r
+using Result = com.google.zxing.Result;\r
+using BitArray = com.google.zxing.common.BitArray;\r
namespace com.google.zxing.oned\r
{\r
- /**\r
- * @author dswitkin@google.com (Daniel Switkin)\r
- * @author Sean Owen\r
- */\r
- using System.Text;\r
- using com.google.zxing.common;\r
-\r
- public sealed class MultiFormatOneDReader : AbstractOneDReader\r
- { \r
- private System.Collections.ArrayList readers;\r
-\r
- public MultiFormatOneDReader(System.Collections.Hashtable hints)\r
- {\r
- System.Collections.ArrayList possibleFormats = hints == null ? null : (System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];\r
- readers = new System.Collections.ArrayList();\r
- if (possibleFormats != null) {\r
- if (possibleFormats.Contains(BarcodeFormat.EAN_13) ||\r
- possibleFormats.Contains(BarcodeFormat.UPC_A) ||\r
- possibleFormats.Contains(BarcodeFormat.EAN_8) ||\r
- possibleFormats.Contains(BarcodeFormat.UPC_E))\r
- {\r
- readers.Add(new MultiFormatUPCEANReader(hints));\r
- }\r
- if (possibleFormats.Contains(BarcodeFormat.CODE_39)) {\r
- readers.Add(new Code39Reader());\r
- }\r
- if (possibleFormats.Contains(BarcodeFormat.CODE_128))\r
- {\r
- readers.Add(new Code128Reader());\r
- }\r
- if (possibleFormats.Contains(BarcodeFormat.ITF))\r
- {\r
- readers.Add(new ITFReader());\r
- }\r
- }\r
- if (readers.Count==0) {\r
- readers.Contains(new MultiFormatUPCEANReader(hints));\r
- readers.Contains(new Code39Reader());\r
- readers.Contains(new Code128Reader());\r
- // TODO: Add ITFReader once it is validated as production ready, and tested for performance.\r
- //readers.addElement(new ITFReader());\r
- }\r
- }\r
-\r
- public override Result decodeRow(int rowNumber, BitArray row, System.Collections.Hashtable hints)\r
- {\r
- int size = readers.Count;\r
- for (int i = 0; i < size; i++) {\r
- OneDReader reader = (OneDReader) readers[i];\r
- try {\r
- return reader.decodeRow(rowNumber, row, hints);\r
- } catch (ReaderException re) {\r
- // continue\r
- }\r
- }\r
-\r
- throw new ReaderException();\r
- }\r
- \r
- }\r
+ \r
+ /// <author> dswitkin@google.com (Daniel Switkin)\r
+ /// </author>\r
+ /// <author> Sean Owen\r
+ /// </author>\r
+ /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
+ /// </author>\r
+ public sealed class MultiFormatOneDReader:OneDReader\r
+ {\r
+ \r
+ //UPGRADE_NOTE: Final was removed from the declaration of 'readers '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
+ private System.Collections.ArrayList readers;\r
+ \r
+ public MultiFormatOneDReader(System.Collections.Hashtable hints)\r
+ {\r
+ System.Collections.ArrayList possibleFormats = hints == null?null:(System.Collections.ArrayList) hints[DecodeHintType.POSSIBLE_FORMATS];\r
+ bool useCode39CheckDigit = hints != null && hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT] != null;\r
+ readers = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));\r
+ if (possibleFormats != null)\r
+ {\r
+ if (possibleFormats.Contains(BarcodeFormat.EAN_13) || possibleFormats.Contains(BarcodeFormat.UPC_A) || possibleFormats.Contains(BarcodeFormat.EAN_8) || possibleFormats.Contains(BarcodeFormat.UPC_E))\r
+ {\r
+ readers.Add(new MultiFormatUPCEANReader(hints));\r
+ }\r
+ if (possibleFormats.Contains(BarcodeFormat.CODE_39))\r
+ {\r
+ readers.Add(new Code39Reader(useCode39CheckDigit));\r
+ }\r
+ if (possibleFormats.Contains(BarcodeFormat.CODE_128))\r
+ {\r
+ readers.Add(new Code128Reader());\r
+ }\r
+ if (possibleFormats.Contains(BarcodeFormat.ITF))\r
+ {\r
+ readers.Add(new ITFReader());\r
+ }\r
+ }\r
+ if ((readers.Count == 0))\r
+ {\r
+ readers.Add(new MultiFormatUPCEANReader(hints));\r
+ readers.Add(new Code39Reader());\r
+ readers.Add(new Code128Reader());\r
+ readers.Add(new ITFReader());\r
+ }\r
+ }\r
+ \r
+ public override Result decodeRow(int rowNumber, BitArray row, System.Collections.Hashtable hints)\r
+ {\r
+ int size = readers.Count;\r
+ for (int i = 0; i < size; i++)\r
+ {\r
+ OneDReader reader = (OneDReader) readers[i];\r
+ try\r
+ {\r
+ return reader.decodeRow(rowNumber, row, hints);\r
+ }\r
+ catch (ReaderException re)\r
+ {\r
+ // continue\r
+ }\r
+ }\r
+ \r
+ throw ReaderException.Instance;\r
+ }\r
+ }\r
}
\ No newline at end of file