2 * Copyright 2008 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.common
\r
20 /// <summary> Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1
\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 CharacterSetECI:ECI
\r
30 public System.String EncodingName
\r
34 return encodingName;
\r
39 private static System.Collections.Hashtable VALUE_TO_ECI;
\r
40 private static System.Collections.Hashtable NAME_TO_ECI;
\r
42 private static void initialize()
\r
44 VALUE_TO_ECI = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable(29));
\r
45 NAME_TO_ECI = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable(29));
\r
46 // TODO figure out if these values are even right!
\r
47 addCharacterSet(0, "Cp437");
\r
48 addCharacterSet(1, new System.String[]{"ISO8859_1", "ISO-8859-1"});
\r
49 addCharacterSet(2, "Cp437");
\r
50 addCharacterSet(3, new System.String[]{"ISO8859_1", "ISO-8859-1"});
\r
51 addCharacterSet(4, "ISO8859_2");
\r
52 addCharacterSet(5, "ISO8859_3");
\r
53 addCharacterSet(6, "ISO8859_4");
\r
54 addCharacterSet(7, "ISO8859_5");
\r
55 addCharacterSet(8, "ISO8859_6");
\r
56 addCharacterSet(9, "ISO8859_7");
\r
57 addCharacterSet(10, "ISO8859_8");
\r
58 addCharacterSet(11, "ISO8859_9");
\r
59 addCharacterSet(12, "ISO8859_10");
\r
60 addCharacterSet(13, "ISO8859_11");
\r
61 addCharacterSet(15, "ISO8859_13");
\r
62 addCharacterSet(16, "ISO8859_14");
\r
63 addCharacterSet(17, "ISO8859_15");
\r
64 addCharacterSet(18, "ISO8859_16");
\r
65 addCharacterSet(20, new System.String[]{"SJIS", "Shift_JIS"});
\r
68 //UPGRADE_NOTE: Final was removed from the declaration of 'encodingName '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
\r
69 private System.String encodingName;
\r
71 private CharacterSetECI(int value_Renamed, System.String encodingName):base(value_Renamed)
\r
73 this.encodingName = encodingName;
\r
76 private static void addCharacterSet(int value_Renamed, System.String encodingName)
\r
78 CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingName);
\r
79 VALUE_TO_ECI[(System.Int32) value_Renamed] = eci; // can't use valueOf
\r
80 NAME_TO_ECI[encodingName] = eci;
\r
83 private static void addCharacterSet(int value_Renamed, System.String[] encodingNames)
\r
85 CharacterSetECI eci = new CharacterSetECI(value_Renamed, encodingNames[0]);
\r
86 VALUE_TO_ECI[(System.Int32) value_Renamed] = eci; // can't use valueOf
\r
87 for (int i = 0; i < encodingNames.Length; i++)
\r
89 NAME_TO_ECI[encodingNames[i]] = eci;
\r
93 /// <param name="value">character set ECI value
\r
95 /// <returns> {@link CharacterSetECI} representing ECI of given value, or null if it is legal but
\r
98 /// <throws> IllegalArgumentException if ECI value is invalid </throws>
\r
99 public static CharacterSetECI getCharacterSetECIByValue(int value_Renamed)
\r
101 if (VALUE_TO_ECI == null)
\r
105 if (value_Renamed < 0 || value_Renamed >= 900)
\r
107 throw new System.ArgumentException("Bad ECI value: " + value_Renamed);
\r
109 return (CharacterSetECI) VALUE_TO_ECI[(System.Int32) value_Renamed];
\r
112 /// <param name="name">character set ECI encoding name
\r
114 /// <returns> {@link CharacterSetECI} representing ECI for character encoding, or null if it is legal
\r
115 /// but unsupported
\r
117 public static CharacterSetECI getCharacterSetECIByName(System.String name)
\r
119 if (NAME_TO_ECI == null)
\r
123 return (CharacterSetECI) NAME_TO_ECI[name];
\r