make/data/charsetmapping/DoubleByte-X.java.template
author jjg
Fri, 05 Jan 2018 16:49:50 -0800
changeset 48449 e2b8009bf42c
parent 47216 71c04702a3d5
permissions -rw-r--r--
8191637: Interface with defaults invalid compiler warning for Serializable Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21805
diff changeset
     2
 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
     4
 *
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    10
 *
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    15
 * accompanied this code).
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    16
 *
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
    23
 * questions.
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    24
 */
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    25
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    26
// -- This file was mechanically generated: Do not edit! -- //
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    27
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    28
package $PACKAGE$;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    29
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    30
import java.nio.charset.Charset;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    31
import java.nio.charset.CharsetDecoder;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    32
import java.nio.charset.CharsetEncoder;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    33
import java.util.Arrays;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    34
import sun.nio.cs.HistoricallyNamedCharset;
28969
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    35
import sun.nio.cs.DoubleByte;
f980bee32887 8073152: Update Standard/ExtendedCharsets to work with module system
sherman
parents: 23010
diff changeset
    36
import sun.nio.cs.*;
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    37
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    38
public class $NAME_CLZ$ extends Charset
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    39
                        $IMPLEMENTS$
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    40
{
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    41
    public $NAME_CLZ$() {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    42
        super("$NAME_CS$", $NAME_ALIASES$);
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    43
    }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    44
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    45
    $HISTORICALNAME$
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    46
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    47
    public boolean contains(Charset cs) {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    48
        $CONTAINS$
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    49
    }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    50
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    51
    public CharsetDecoder newDecoder() {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    52
        initb2c();
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 28969
diff changeset
    53
        return new  DoubleByte.Decoder$DECTYPE$(this, b2c, b2cSB, $B2MIN$, $B2MAX$, $ASCIICOMPATIBLE$);
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    54
    }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    55
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    56
    public CharsetEncoder newEncoder() {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    57
        initc2b();
33663
2cd62a4bd471 8141132: JEP 254: Compact Strings
thartmann
parents: 28969
diff changeset
    58
        return new DoubleByte.Encoder$ENCTYPE$(this, $ENC_REPLACEMENT$ c2b, c2bIndex, $ASCIICOMPATIBLE$);
2921
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    59
    }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    60
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    61
    $B2C$
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    62
    static char[][] b2c = new char[b2cStr.length][];
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    63
    static char[] b2cSB;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    64
    private static volatile boolean b2cInitialized = false;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    65
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    66
    static void initb2c() {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    67
        if (b2cInitialized)
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    68
            return;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    69
        synchronized (b2c) {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    70
            if (b2cInitialized)
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    71
                return;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    72
            for (int i = 0; i < b2cStr.length; i++) {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    73
                if (b2cStr[i] == null)
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    74
                    b2c[i] = DoubleByte.B2C_UNMAPPABLE;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    75
                else
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    76
                    b2c[i] = b2cStr[i].toCharArray();
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    77
            }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    78
            b2cSB = b2cSBStr.toCharArray();
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    79
            b2cInitialized = true;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    80
        }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    81
    }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    82
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    83
    static char[] c2b = new char[$C2BLENGTH$];
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    84
    static char[] c2bIndex = new char[0x100];
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    85
    private static volatile boolean c2bInitialized = false;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    86
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    87
    static void initc2b() {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    88
        if (c2bInitialized)
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    89
            return;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    90
        synchronized (c2b) {
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    91
            if (c2bInitialized)
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    92
                return;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    93
            $NONROUNDTRIP_B2C$
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    94
            $NONROUNDTRIP_C2B$
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    95
            DoubleByte.Encoder.initC2B(b2cStr, b2cSBStr, b2cNR, c2bNR,
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    96
                                       $B2MIN$, $B2MAX$,
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    97
                                       c2b, c2bIndex);
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    98
            c2bInitialized = true;
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
    99
        }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
   100
    }
d9d491a5a169 6843578: Re-implement IBM doublebyte charsets
sherman
parents:
diff changeset
   101
}