Add minimal support for FNC1 mode in QR Code
[zxing.git] / core / src / com / google / zxing / qrcode / decoder / CharacterSetECI.java
1 /*
2  * Copyright 2008 ZXing authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package com.google.zxing.qrcode.decoder;
18
19 import java.util.Hashtable;
20
21 /**
22  * Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1.
23  *
24  * @author srowen@google.com (Sean Owen)
25  */
26 final class CharacterSetECI extends ECI {
27
28   private static final Hashtable VALUE_TO_ECI;
29   static {
30     VALUE_TO_ECI = new Hashtable(29);
31     // TODO figure out if these values are even right!
32     addCharacterSet(0, "Cp437");
33     addCharacterSet(1, "ISO8859_1");
34     addCharacterSet(2, "Cp437");
35     addCharacterSet(3, "ISO8859_1");
36     addCharacterSet(4, "ISO8859_2");
37     addCharacterSet(5, "ISO8859_3");
38     addCharacterSet(6, "ISO8859_4");
39     addCharacterSet(7, "ISO8859_5");
40     addCharacterSet(8, "ISO8859_6");
41     addCharacterSet(9, "ISO8859_7");
42     addCharacterSet(10, "ISO8859_8");
43     addCharacterSet(11, "ISO8859_9");
44     addCharacterSet(12, "ISO8859_10");
45     addCharacterSet(13, "ISO8859_11");
46     addCharacterSet(15, "ISO8859_13");
47     addCharacterSet(16, "ISO8859_14");
48     addCharacterSet(17, "ISO8859_15");
49     addCharacterSet(18, "ISO8859_16");
50     addCharacterSet(20, "SJIS");
51   }
52
53   private final String encodingName;
54
55   private CharacterSetECI(int value, String encodingName) {
56     super(value);
57     this.encodingName = encodingName;
58   }
59
60   String getEncodingName() {
61     return encodingName;
62   }
63
64   private static void addCharacterSet(int value, String encodingName) {
65     VALUE_TO_ECI.put(new Integer(value), new CharacterSetECI(value, encodingName));
66   }
67
68   static CharacterSetECI getCharacterSetECIByValue(int value) {
69     CharacterSetECI eci = (CharacterSetECI) VALUE_TO_ECI.get(new Integer(value));
70     if (eci == null) {
71       throw new IllegalArgumentException("Unsupported value: " + value);
72     }
73     return eci;
74   }
75
76 }