blob: e0469fe8bc49922123cfe4eff61e20a9c5553a0b [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26package sun.nio.cs;
27
28import java.nio.charset.Charset;
29import java.nio.charset.CharsetDecoder;
30import java.nio.charset.CharsetEncoder;
31import sun.nio.cs.StandardCharsets;
32import sun.nio.cs.SingleByteDecoder;
33import sun.nio.cs.SingleByteEncoder;
34import sun.nio.cs.HistoricallyNamedCharset;
35
36public class ISO_8859_7
37 extends Charset
38 implements HistoricallyNamedCharset
39{
40
41 public ISO_8859_7() {
42 super("ISO-8859-7", StandardCharsets.aliases_ISO_8859_7);
43 }
44
45 public String historicalName() {
46 return "ISO8859_7";
47 }
48
49 public boolean contains(Charset cs) {
50 return ((cs.name().equals("US-ASCII"))
51 || (cs instanceof ISO_8859_7));
52 }
53
54 public CharsetDecoder newDecoder() {
55 return new Decoder(this);
56 }
57
58 public CharsetEncoder newEncoder() {
59 return new Encoder(this);
60 }
61
62
63 /**
64 * These accessors are temporarily supplied while sun.io
65 * converters co-exist with the sun.nio.cs.{ext} charset coders
66 * These facilitate sharing of conversion tables between the
67 * two co-existing implementations. When sun.io converters
68 * are made extinct these will be unncessary and should be removed
69 */
70
71 public String getDecoderSingleByteMappings() {
72 return Decoder.byteToCharTable;
73
74 }
75
76 public short[] getEncoderIndex1() {
77 return Encoder.index1;
78
79 }
80 public String getEncoderIndex2() {
81 return Encoder.index2;
82
83 }
84
85 private static class Decoder extends SingleByteDecoder {
86 public Decoder(Charset cs) {
87 super(cs, byteToCharTable);
88 }
89
90 private final static String byteToCharTable =
91
92 "\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" + // 0x80 - 0x87
93 "\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" + // 0x88 - 0x8F
94 "\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" + // 0x90 - 0x97
95 "\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" + // 0x98 - 0x9F
96 "\u00A0\u2018\u2019\u00A3\u20AC\u20AF\u00A6\u00A7" + // 0xA0 - 0xA7
97 "\u00A8\u00A9\u037A\u00AB\u00AC\u00AD\uFFFD\u2015" + // 0xA8 - 0xAF
98 "\u00B0\u00B1\u00B2\u00B3\u0384\u0385\u0386\u00B7" + // 0xB0 - 0xB7
99 "\u0388\u0389\u038A\u00BB\u038C\u00BD\u038E\u038F" + // 0xB8 - 0xBF
100 "\u0390\u0391\u0392\u0393\u0394\u0395\u0396\u0397" + // 0xC0 - 0xC7
101 "\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F" + // 0xC8 - 0xCF
102 "\u03A0\u03A1\uFFFD\u03A3\u03A4\u03A5\u03A6\u03A7" + // 0xD0 - 0xD7
103 "\u03A8\u03A9\u03AA\u03AB\u03AC\u03AD\u03AE\u03AF" + // 0xD8 - 0xDF
104 "\u03B0\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7" + // 0xE0 - 0xE7
105 "\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF" + // 0xE8 - 0xEF
106 "\u03C0\u03C1\u03C2\u03C3\u03C4\u03C5\u03C6\u03C7" + // 0xF0 - 0xF7
107 "\u03C8\u03C9\u03CA\u03CB\u03CC\u03CD\u03CE\uFFFD" + // 0xF8 - 0xFF
108 "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" + // 0x00 - 0x07
109 "\b\t\n\u000B\f\r\u000E\u000F" + // 0x08 - 0x0F
110 "\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" + // 0x10 - 0x17
111 "\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" + // 0x18 - 0x1F
112 "\u0020\u0021\"\u0023\u0024\u0025\u0026\'" + // 0x20 - 0x27
113 "\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" + // 0x28 - 0x2F
114 "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" + // 0x30 - 0x37
115 "\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" + // 0x38 - 0x3F
116 "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" + // 0x40 - 0x47
117 "\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" + // 0x48 - 0x4F
118 "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" + // 0x50 - 0x57
119 "\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" + // 0x58 - 0x5F
120 "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" + // 0x60 - 0x67
121 "\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" + // 0x68 - 0x6F
122 "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" + // 0x70 - 0x77
123 "\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F"; // 0x78 - 0x7F
124 }
125
126 private static class Encoder extends SingleByteEncoder {
127 public Encoder(Charset cs) {
128 super(cs, index1, index2, 0xFF00, 0x00FF, 8);
129 }
130
131 private final static String index2 =
132
133 "\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007" +
134 "\b\t\n\u000B\f\r\u000E\u000F" +
135 "\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017" +
136 "\u0018\u0019\u001A\u001B\u001C\u001D\u001E\u001F" +
137 "\u0020\u0021\"\u0023\u0024\u0025\u0026\'" +
138 "\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F" +
139 "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037" +
140 "\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F" +
141 "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047" +
142 "\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F" +
143 "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057" +
144 "\u0058\u0059\u005A\u005B\\\u005D\u005E\u005F" +
145 "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067" +
146 "\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F" +
147 "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077" +
148 "\u0078\u0079\u007A\u007B\u007C\u007D\u007E\u007F" +
149 "\u0080\u0081\u0082\u0083\u0084\u0085\u0086\u0087" +
150 "\u0088\u0089\u008A\u008B\u008C\u008D\u008E\u008F" +
151 "\u0090\u0091\u0092\u0093\u0094\u0095\u0096\u0097" +
152 "\u0098\u0099\u009A\u009B\u009C\u009D\u009E\u009F" +
153 "\u00A0\u0000\u0000\u00A3\u0000\u0000\u00A6\u00A7" +
154 "\u00A8\u00A9\u0000\u00AB\u00AC\u00AD\u0000\u0000" +
155 "\u00B0\u00B1\u00B2\u00B3\u0000\u0000\u0000\u00B7" +
156 "\u0000\u0000\u0000\u00BB\u0000\u00BD\u0000\u0000" +
157 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
158 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
159 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
160 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
161 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
162 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
163 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
164 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
165 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
166 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
167 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
168 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
169 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
170 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
171 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
172 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
173 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
174 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
175 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
176 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
177 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
178 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
179 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
180 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
181 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
182 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
183 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
184 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
185 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
186 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
187 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
188 "\u0000\u0000\u0000\u0000\u0000\u0000\u00AA\u0000" +
189 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
190 "\u00B4\u00B5\u00B6\u0000\u00B8\u00B9\u00BA\u0000" +
191 "\u00BC\u0000\u00BE\u00BF\u00C0\u00C1\u00C2\u00C3" +
192 "\u00C4\u00C5\u00C6\u00C7\u00C8\u00C9\u00CA\u00CB" +
193 "\u00CC\u00CD\u00CE\u00CF\u00D0\u00D1\u0000\u00D3" +
194 "\u00D4\u00D5\u00D6\u00D7\u00D8\u00D9\u00DA\u00DB" +
195 "\u00DC\u00DD\u00DE\u00DF\u00E0\u00E1\u00E2\u00E3" +
196 "\u00E4\u00E5\u00E6\u00E7\u00E8\u00E9\u00EA\u00EB" +
197 "\u00EC\u00ED\u00EE\u00EF\u00F0\u00F1\u00F2\u00F3" +
198 "\u00F4\u00F5\u00F6\u00F7\u00F8\u00F9\u00FA\u00FB" +
199 "\u00FC\u00FD\u00FE\u0000\u0000\u0000\u0000\u0000" +
200 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
201 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
202 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
203 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
204 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
205 "\u0000\u0000\u0000\u0000\u00AF\u0000\u0000\u00A1" +
206 "\u00A2\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
207 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
208 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
209 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
210 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
211 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
212 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
213 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
214 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
215 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
216 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
217 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
218 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
219 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
220 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
221 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
222 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
223 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
224 "\u0000\u0000\u0000\u00A4\u0000\u0000\u00A5\u0000" +
225 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
226 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
227 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
228 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
229 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
230 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
231 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
232 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
233 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
234 "\u0000\u0000\u0000\u0000\u0000\u0000\u0000";
235
236 private final static short index1[] = {
237 0, 190, 190, 324, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
238 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
239 559, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
240 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
241 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
242 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
243 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
244 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
245 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
246 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
247 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
248 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
249 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
250 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
251 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
252 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
253 };
254 }
255}