2 * Copyright 2007 ZXing authors
\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
8 * http://www.apache.org/licenses/LICENSE-2.0
\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
17 namespace com.google.zxing.qrcode.decoder
\r
20 /// <summary> <p>See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels
\r
21 /// defined by the QR code standard.</p>
\r
24 /// <author> Sean Owen
\r
26 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
28 public sealed class ErrorCorrectionLevel
\r
38 public System.String Name
\r
47 // No, we can't use an enum here. J2ME doesn't support it.
\r
49 /// <summary> L = ~7% correction</summary>
\r
50 //UPGRADE_NOTE: Final was removed from the declaration of 'L '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
51 public static readonly ErrorCorrectionLevel L = new ErrorCorrectionLevel(0, 0x01, "L");
\r
52 /// <summary> M = ~15% correction</summary>
\r
53 //UPGRADE_NOTE: Final was removed from the declaration of 'M '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
54 public static readonly ErrorCorrectionLevel M = new ErrorCorrectionLevel(1, 0x00, "M");
\r
55 /// <summary> Q = ~25% correction</summary>
\r
56 //UPGRADE_NOTE: Final was removed from the declaration of 'Q '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
57 public static readonly ErrorCorrectionLevel Q = new ErrorCorrectionLevel(2, 0x03, "Q");
\r
58 /// <summary> H = ~30% correction</summary>
\r
59 //UPGRADE_NOTE: Final was removed from the declaration of 'H '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
60 public static readonly ErrorCorrectionLevel H = new ErrorCorrectionLevel(3, 0x02, "H");
\r
62 //UPGRADE_NOTE: Final was removed from the declaration of 'FOR_BITS '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
63 private static readonly ErrorCorrectionLevel[] FOR_BITS = new ErrorCorrectionLevel[]{M, L, H, Q};
\r
65 //UPGRADE_NOTE: Final was removed from the declaration of 'ordinal '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
66 private int ordinal_Renamed_Field;
\r
67 //UPGRADE_NOTE: Final was removed from the declaration of 'bits '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
69 //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
70 private System.String name;
\r
72 private ErrorCorrectionLevel(int ordinal, int bits, System.String name)
\r
74 this.ordinal_Renamed_Field = ordinal;
\r
79 public int ordinal()
\r
81 return ordinal_Renamed_Field;
\r
84 public override System.String ToString()
\r
89 /// <param name="bits">int containing the two bits encoding a QR Code's error correction level
\r
91 /// <returns> {@link ErrorCorrectionLevel} representing the encoded error correction level
\r
93 public static ErrorCorrectionLevel forBits(int bits)
\r
95 if (bits < 0 || bits >= FOR_BITS.Length)
\r
97 throw new System.ArgumentException();
\r
99 return FOR_BITS[bits];
\r