src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_Solaris.java.template
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     1
/*
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     2
 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     4
 *
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    10
 *
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    15
 * accompanied this code).
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    16
 *
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    20
 *
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    23
 * questions.
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    24
 */
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    25
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    26
package $PACKAGE$;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    27
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    28
import java.nio.charset.Charset;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    29
import java.nio.charset.CharsetDecoder;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    30
import java.nio.charset.CharsetEncoder;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    31
import sun.nio.cs.DoubleByte;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    32
import sun.nio.cs.HistoricallyNamedCharset;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    33
import java.util.Arrays;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    34
import static sun.nio.cs.CharsetMapping.*;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    35
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    36
public class Big5_Solaris extends Charset implements HistoricallyNamedCharset
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    37
{
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    38
    public Big5_Solaris() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    39
        super("x-Big5-Solaris", $ALIASES$);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    40
    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    41
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    42
    public String historicalName() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    43
        return "Big5_Solaris";
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    44
    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    45
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    46
    public boolean contains(Charset cs) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    47
        return ((cs.name().equals("US-ASCII"))
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    48
                || (cs instanceof Big5)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    49
                || (cs instanceof Big5_Solaris));
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    50
    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    51
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    52
    public CharsetDecoder newDecoder() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    53
        initb2c();
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 28969
diff changeset
    54
        return new  DoubleByte.Decoder(this, b2c, b2cSB, 0x40, 0xfe, true);
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    55
    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    56
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    57
    public CharsetEncoder newEncoder() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    58
        initc2b();
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 28969
diff changeset
    59
        return new DoubleByte.Encoder(this, c2b, c2bIndex, true);
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    60
    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    61
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    62
    static char[][] b2c;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    63
    static char[] b2cSB;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    64
    private static volatile boolean b2cInitialized = false;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    65
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    66
    static void initb2c() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    67
        if (b2cInitialized)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    68
            return;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    69
        synchronized (Big5_Solaris.class) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    70
            if (b2cInitialized)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    71
                return;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    72
            Big5.initb2c();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    73
            b2c = Big5.b2c.clone();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    74
            // Big5 Solaris implementation has 7 additional mappings
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    75
            int[] sol = new int[] {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    76
                0xF9D6, 0x7881,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    77
                0xF9D7, 0x92B9,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    78
                0xF9D8, 0x88CF,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    79
                0xF9D9, 0x58BB,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    80
                0xF9DA, 0x6052,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    81
                0xF9DB, 0x7CA7,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    82
                0xF9DC, 0x5AFA };
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    83
            if (b2c[0xf9] == DoubleByte.B2C_UNMAPPABLE) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    84
                b2c[0xf9] = new char[0xfe - 0x40 + 1];
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    85
                Arrays.fill(b2c[0xf9], UNMAPPABLE_DECODING);
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    86
            }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    87
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    88
            for (int i = 0; i < sol.length;) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    89
                b2c[0xf9][sol[i++] & 0xff - 0x40] = (char)sol[i++];
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    90
            }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    91
            b2cSB = Big5.b2cSB;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    92
            b2cInitialized = true;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    93
        }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    94
    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    95
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    96
    static char[] c2b;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    97
    static char[] c2bIndex;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    98
    private static volatile boolean c2bInitialized = false;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
    99
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   100
    static void initc2b() {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   101
        if (c2bInitialized)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   102
            return;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   103
        synchronized (Big5_Solaris.class) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   104
            if (c2bInitialized)
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   105
                return;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   106
            Big5.initc2b();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   107
            c2b = Big5.c2b.clone();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   108
            c2bIndex = Big5.c2bIndex.clone();
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   109
            int[] sol = new int[] {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   110
                0x7881, 0xF9D6,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   111
                0x92B9, 0xF9D7,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   112
                0x88CF, 0xF9D8,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   113
                0x58BB, 0xF9D9,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   114
                0x6052, 0xF9DA,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   115
                0x7CA7, 0xF9DB,
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   116
                0x5AFA, 0xF9DC };
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   117
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   118
            for (int i = 0; i < sol.length;) {
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   119
                int c = sol[i++];
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   120
                // no need to check c2bIndex[c >>8], we know it points
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   121
                // to the appropriate place.
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   122
                c2b[c2bIndex[c >> 8] + (c & 0xff)] = (char)sol[i++];
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   123
            }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   124
            c2bInitialized = true;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   125
        }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   126
    }
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents:
diff changeset
   127
}