New C# port from Suraj Supekar
[zxing.git] / csharp / Result.cs
diff --git a/csharp/Result.cs b/csharp/Result.cs
new file mode 100755 (executable)
index 0000000..b09d9ac
--- /dev/null
@@ -0,0 +1,129 @@
+/*\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
+*\r
+*      http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*/\r
+using System;\r
+namespace com.google.zxing\r
+{\r
+       \r
+       /// <summary> <p>Encapsulates the result of decoding a barcode within an image.</p>\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
+       public sealed class Result\r
+       {\r
+               /// <returns> raw text encoded by the barcode, if applicable, otherwise <code>null</code>\r
+               /// </returns>\r
+               public System.String Text\r
+               {\r
+                       get\r
+                       {\r
+                               return text;\r
+                       }\r
+                       \r
+               }\r
+               /// <returns> raw bytes encoded by the barcode, if applicable, otherwise <code>null</code>\r
+               /// </returns>\r
+               public sbyte[] RawBytes\r
+               {\r
+                       get\r
+                       {\r
+                               return rawBytes;\r
+                       }\r
+                       \r
+               }\r
+               /// <returns> points related to the barcode in the image. These are typically points\r
+               /// identifying finder patterns or the corners of the barcode. The exact meaning is\r
+               /// specific to the type of barcode that was decoded.\r
+               /// </returns>\r
+               public ResultPoint[] ResultPoints\r
+               {\r
+                       get\r
+                       {\r
+                               return resultPoints;\r
+                       }\r
+                       \r
+               }\r
+               /// <returns> {@link BarcodeFormat} representing the format of the barcode that was decoded\r
+               /// </returns>\r
+               public BarcodeFormat BarcodeFormat\r
+               {\r
+                       get\r
+                       {\r
+                               return format;\r
+                       }\r
+                       \r
+               }\r
+               /// <returns> {@link Hashtable} mapping {@link ResultMetadataType} keys to values. May be\r
+               /// <code>null</code>. This contains optional metadata about what was detected about the barcode,\r
+               /// like orientation.\r
+               /// </returns>\r
+               public System.Collections.Hashtable ResultMetadata\r
+               {\r
+                       get\r
+                       {\r
+                               return resultMetadata;\r
+                       }\r
+                       \r
+               }\r
+               \r
+               //UPGRADE_NOTE: Final was removed from the declaration of 'text '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
+               private System.String text;\r
+               //UPGRADE_NOTE: Final was removed from the declaration of 'rawBytes '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
+               private sbyte[] rawBytes;\r
+               //UPGRADE_NOTE: Final was removed from the declaration of 'resultPoints '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
+               private ResultPoint[] resultPoints;\r
+               //UPGRADE_NOTE: Final was removed from the declaration of 'format '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"\r
+               private BarcodeFormat format;\r
+               private System.Collections.Hashtable resultMetadata;\r
+               \r
+               public Result(System.String text, sbyte[] rawBytes, ResultPoint[] resultPoints, BarcodeFormat format)\r
+               {\r
+                       if (text == null && rawBytes == null)\r
+                       {\r
+                               throw new System.ArgumentException("Text and bytes are null");\r
+                       }\r
+                       this.text = text;\r
+                       this.rawBytes = rawBytes;\r
+                       this.resultPoints = resultPoints;\r
+                       this.format = format;\r
+                       this.resultMetadata = null;\r
+               }\r
+               \r
+               public void  putMetadata(ResultMetadataType type, System.Object value_Renamed)\r
+               {\r
+                       if (resultMetadata == null)\r
+                       {\r
+                               resultMetadata = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable(3));\r
+                       }\r
+                       resultMetadata[type] = value_Renamed;\r
+               }\r
+               \r
+               public override System.String ToString()\r
+               {\r
+                       if (text == null)\r
+                       {\r
+                               return "[" + rawBytes.Length + " bytes]";\r
+                       }\r
+                       else\r
+                       {\r
+                               return text;\r
+                       }\r
+               }\r
+       }\r
+}
\ No newline at end of file