-/*\r
+/*\r
+* Copyright 2007 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
-\r
using System;\r
namespace com.google.zxing\r
{\r
+ \r
+ /// <summary> The general exception class throw when something goes wrong during decoding of a barcode.\r
+ /// This includes, but is not limited to, failing checksums / error correction algorithms, being\r
+ /// unable to locate finder timing patterns, and so on.\r
+ /// \r
+ /// </summary>\r
+ /// <author> Sean Owen\r
+ /// </author>\r
+ /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
+ /// </author>\r
\r
- /// <summary> The general exception class throw when something goes wrong during decoding of a barcode.\r
- /// This includes, but is not limited to, failing checksums / error correction algorithms, being\r
- /// unable to locate finder timing patterns, and so on.\r
- /// \r
- /// </summary>\r
- /// <author> srowen@google.com (Sean Owen)\r
- /// </author>\r
- //[Serializable]\r
- public sealed class ReaderException : System.Exception\r
- {\r
-\r
- private static ReaderException instance = new ReaderException();\r
-\r
- public ReaderException() {\r
- // do nothing\r
- }\r
-\r
- public ReaderException(System.String message): base(message)\r
- {\r
- }\r
- }\r
+ [Serializable]\r
+ public sealed class ReaderException:System.Exception\r
+ {\r
+ public static ReaderException Instance\r
+ {\r
+ get\r
+ {\r
+ // Exception e = new Exception();\r
+ // // Take the stack frame before this one.\r
+ // StackTraceElement stack = e.getStackTrace()[1];\r
+ // String key = stack.getClassName() + "." + stack.getMethodName() + "(), line " +\r
+ // stack.getLineNumber();\r
+ // if (throwers.containsKey(key)) {\r
+ // Integer value = throwers.get(key);\r
+ // value++;\r
+ // throwers.put(key, value);\r
+ // } else {\r
+ // throwers.put(key, 1);\r
+ // }\r
+ // exceptionCount++;\r
+ \r
+ return instance;\r
+ }\r
+ \r
+ }\r
+ \r
+ // TODO: Currently we throw up to 400 ReaderExceptions while scanning a single 240x240 image before\r
+ // rejecting it. This involves a lot of overhead and memory allocation, and affects both performance\r
+ // and latency on continuous scan clients. In the future, we should change all the decoders not to\r
+ // throw exceptions for routine events, like not finding a barcode on a given row. Instead, we\r
+ // should return error codes back to the callers, and simply delete this class. In the mean time, I\r
+ // have altered this class to be as lightweight as possible, by ignoring the exception string, and\r
+ // by disabling the generation of stack traces, which is especially time consuming. These are just\r
+ // temporary measures, pending the big cleanup.\r
+ \r
+ //UPGRADE_NOTE: Final was removed from the declaration of 'instance '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
+ private static readonly ReaderException instance = new ReaderException();\r
+ \r
+ // EXCEPTION TRACKING SUPPORT\r
+ // Identifies who is throwing exceptions and how often. To use:\r
+ //\r
+ // 1. Uncomment these lines and the code below which uses them.\r
+ // 2. Uncomment the two corresponding lines in j2se/CommandLineRunner.decode()\r
+ // 3. Change core to build as Java 1.5 temporarily\r
+ // private static int exceptionCount = 0;\r
+ // private static Map<String,Integer> throwers = new HashMap<String,Integer>(32);\r
+ \r
+ private ReaderException()\r
+ {\r
+ // do nothing\r
+ }\r
+ \r
+ // public static int getExceptionCountAndReset() {\r
+ // int temp = exceptionCount;\r
+ // exceptionCount = 0;\r
+ // return temp;\r
+ // }\r
+ //\r
+ // public static String getThrowersAndReset() {\r
+ // StringBuilder builder = new StringBuilder(1024);\r
+ // Object[] keys = throwers.keySet().toArray();\r
+ // for (int x = 0; x < keys.length; x++) {\r
+ // String key = (String) keys[x];\r
+ // Integer value = throwers.get(key);\r
+ // builder.append(key);\r
+ // builder.append(": ");\r
+ // builder.append(value);\r
+ // builder.append("\n");\r
+ // }\r
+ // throwers.clear();\r
+ // return builder.toString();\r
+ // }\r
+ \r
+ // Prevent stack traces from being taken\r
+ // srowen says: huh, my IDE is saying this is not an override. native methods can't be overridden?\r
+ // This, at least, does not hurt. Because we use a singleton pattern here, it doesn't matter anyhow.\r
+ //UPGRADE_NOTE: Exception 'java.lang.Throwable' was converted to 'System.Exception' which has different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1100'"\r
+ //UPGRADE_NOTE: The equivalent of method 'java.lang.Throwable.fillInStackTrace' is not an override method. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1143'"\r
+ public System.Exception fillInStackTrace()\r
+ {\r
+ return null;\r
+ }\r
+ }\r
}
\ No newline at end of file