--- /dev/null
+/*\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
+using com.google.zxing;\r
+using com.google.zxing.common;\r
+\r
+namespace com.google.zxing.qrcode.decoder\r
+{\r
+ public sealed class ErrorCorrectionLevel\r
+ { \r
+ // No, we can't use an enum here. J2ME doesn't support it.\r
+ /**\r
+ * L = ~7% correction\r
+ */\r
+ public static ErrorCorrectionLevel L = new ErrorCorrectionLevel(0, 0x01, "L");\r
+ /**\r
+ * M = ~15% correction\r
+ */\r
+ public static ErrorCorrectionLevel M = new ErrorCorrectionLevel(1, 0x00, "M");\r
+ /**\r
+ * Q = ~25% correction\r
+ */\r
+ public static ErrorCorrectionLevel Q = new ErrorCorrectionLevel(2, 0x03, "Q");\r
+ /**\r
+ * H = ~30% correction\r
+ */\r
+ public static ErrorCorrectionLevel H = new ErrorCorrectionLevel(3, 0x02, "H");\r
+\r
+ private static ErrorCorrectionLevel[] FOR_BITS = {M, L, H, Q};\r
+\r
+ private int Ordinal;\r
+ private int bits;\r
+ private string name;\r
+\r
+ private ErrorCorrectionLevel(int ordinal, int bits, string name) {\r
+ this.Ordinal = ordinal;\r
+ this.bits = bits;\r
+ this.name = name;\r
+ }\r
+\r
+ public int ordinal() {\r
+ return Ordinal;\r
+ }\r
+\r
+ public int getBits() {\r
+ return bits;\r
+ }\r
+\r
+ public string getName() {\r
+ return name;\r
+ }\r
+\r
+ public string toString() {\r
+ return name;\r
+ }\r
+\r
+ /**\r
+ * @param bits int containing the two bits encoding a QR Code's error correction level\r
+ * @return {@link ErrorCorrectionLevel} representing the encoded error correction level\r
+ */\r
+ public static ErrorCorrectionLevel forBits(int bits) {\r
+ if (bits < 0 || bits >= FOR_BITS.Length) {\r
+ throw new ArgumentException();\r
+ }\r
+ return FOR_BITS[bits];\r
+ }\r
+ }\r
+}
\ No newline at end of file