jdk/src/share/classes/sun/nio/cs/ext/IBM1140.java
changeset 1750 637e3c4c99f8
parent 1749 ff917d84bdf3
parent 1748 a5c82afe054b
child 1755 b144aadaeb0d
equal deleted inserted replaced
1749:ff917d84bdf3 1750:637e3c4c99f8
     1 /*
       
     2  * Copyright 2003-2004 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 
       
    26 package sun.nio.cs.ext;
       
    27 
       
    28 
       
    29 import java.nio.charset.Charset;
       
    30 import java.nio.charset.CharsetDecoder;
       
    31 import java.nio.charset.CharsetEncoder;
       
    32 import sun.nio.cs.StandardCharsets;
       
    33 import sun.nio.cs.SingleByteDecoder;
       
    34 import sun.nio.cs.SingleByteEncoder;
       
    35 import sun.nio.cs.HistoricallyNamedCharset;
       
    36 
       
    37 public class IBM1140
       
    38     extends Charset
       
    39     implements HistoricallyNamedCharset
       
    40 {
       
    41 
       
    42     public IBM1140() {
       
    43         super("IBM01140", ExtendedCharsets.aliasesFor("IBM01140"));
       
    44     }
       
    45 
       
    46     public String historicalName() {
       
    47         return "Cp1140";
       
    48     }
       
    49 
       
    50     public boolean contains(Charset cs) {
       
    51         return (cs instanceof IBM1140);
       
    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      * These accessors are temporarily supplied while sun.io
       
    64      * converters co-exist with the sun.nio.cs.{ext} charset coders
       
    65      * These facilitate sharing of conversion tables between the
       
    66      * two co-existing implementations. When sun.io converters
       
    67      * are made extinct these will be unncessary and should be removed
       
    68      */
       
    69 
       
    70     public short[] getEncoderIndex1() {
       
    71         return Encoder.index1;
       
    72     }
       
    73 
       
    74     public String getEncoderIndex2() {
       
    75         return Encoder.index2;
       
    76     }
       
    77 
       
    78     private static class Decoder extends IBM037.Decoder {
       
    79             public Decoder(Charset cs) {
       
    80                 super(cs);
       
    81             }
       
    82 
       
    83             public char decode(int byteIndex) {
       
    84                 return (byteIndex == (byte)0x9F) ? '\u20AC' : super.decode(byteIndex);
       
    85             }
       
    86     }
       
    87 
       
    88     private static class Encoder extends SingleByteEncoder {
       
    89             public Encoder(Charset cs) {
       
    90                 super(cs, index1, index2, 0xFF00, 0x00FF, 8);
       
    91             }
       
    92 
       
    93     private final static String index2 =
       
    94 
       
    95         "\u0000\u0001\u0002\u0003\u0037\u002D\u002E\u002F" +
       
    96         "\u0016\u0005\u0025\u000B\f\r\u000E\u000F" +
       
    97         "\u0010\u0011\u0012\u0013\u003C\u003D\u0032\u0026" +
       
    98         "\u0018\u0019\u003F\'\u001C\u001D\u001E\u001F" +
       
    99         "\u0040\u005A\u007F\u007B\u005B\u006C\u0050\u007D" +
       
   100         "\u004D\u005D\\\u004E\u006B\u0060\u004B\u0061" +
       
   101         "\u00F0\u00F1\u00F2\u00F3\u00F4\u00F5\u00F6\u00F7" +
       
   102         "\u00F8\u00F9\u007A\u005E\u004C\u007E\u006E\u006F" +
       
   103         "\u007C\u00C1\u00C2\u00C3\u00C4\u00C5\u00C6\u00C7" +
       
   104         "\u00C8\u00C9\u00D1\u00D2\u00D3\u00D4\u00D5\u00D6" +
       
   105         "\u00D7\u00D8\u00D9\u00E2\u00E3\u00E4\u00E5\u00E6" +
       
   106         "\u00E7\u00E8\u00E9\u00BA\u00E0\u00BB\u00B0\u006D" +
       
   107         "\u0079\u0081\u0082\u0083\u0084\u0085\u0086\u0087" +
       
   108         "\u0088\u0089\u0091\u0092\u0093\u0094\u0095\u0096" +
       
   109         "\u0097\u0098\u0099\u00A2\u00A3\u00A4\u00A5\u00A6" +
       
   110         "\u00A7\u00A8\u00A9\u00C0\u004F\u00D0\u00A1\u0007" +
       
   111         "\u0020\u0021\"\u0023\u0024\u0015\u0006\u0017" +
       
   112         "\u0028\u0029\u002A\u002B\u002C\t\n\u001B" +
       
   113         "\u0030\u0031\u001A\u0033\u0034\u0035\u0036\b" +
       
   114         "\u0038\u0039\u003A\u003B\u0004\u0014\u003E\u00FF" +
       
   115         "\u0041\u00AA\u004A\u00B1\u0000\u00B2\u006A\u00B5" +
       
   116         "\u00BD\u00B4\u009A\u008A\u005F\u00CA\u00AF\u00BC" +
       
   117         "\u0090\u008F\u00EA\u00FA\u00BE\u00A0\u00B6\u00B3" +
       
   118         "\u009D\u00DA\u009B\u008B\u00B7\u00B8\u00B9\u00AB" +
       
   119         "\u0064\u0065\u0062\u0066\u0063\u0067\u009E\u0068" +
       
   120         "\u0074\u0071\u0072\u0073\u0078\u0075\u0076\u0077" +
       
   121         "\u00AC\u0069\u00ED\u00EE\u00EB\u00EF\u00EC\u00BF" +
       
   122         "\u0080\u00FD\u00FE\u00FB\u00FC\u00AD\u00AE\u0059" +
       
   123         "\u0044\u0045\u0042\u0046\u0043\u0047\u009C\u0048" +
       
   124         "\u0054\u0051\u0052\u0053\u0058\u0055\u0056\u0057" +
       
   125         "\u008C\u0049\u00CD\u00CE\u00CB\u00CF\u00CC\u00E1" +
       
   126         "\u0070\u00DD\u00DE\u00DB\u00DC\u008D\u008E\u00DF" +
       
   127         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   128         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   129         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   130         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   131         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   132         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   133         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   134         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   135         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   136         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   137         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   138         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   139         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   140         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   141         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   142         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   143         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   144         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   145         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   146         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   147         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   148         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   149         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   150         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   151         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   152         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   153         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   154         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   155         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   156         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   157         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   158         "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" +
       
   159         "\u009F\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";
       
   170 
       
   171     private final static short index1[] = {
       
   172         0, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   173         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   174         340, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   175         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   176         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   177         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   178         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   179         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   180         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   181         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   182         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   183         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   184         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   185         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   186         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   187         256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
       
   188     };
       
   189 
       
   190     }
       
   191 }