jdk/make/tools/CharsetMapping/DoubleByte-X.java
changeset 4341 2af5eacd4b24
parent 4335 365eb4449319
child 4342 9f3aa1172803
equal deleted inserted replaced
4335:365eb4449319 4341:2af5eacd4b24
     1 /*
       
     2  * Copyright 2009 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 // -- This file was mechanically generated: Do not edit! -- //
       
    27 
       
    28 package $PACKAGE$;
       
    29 
       
    30 import java.nio.charset.Charset;
       
    31 import java.nio.charset.CharsetDecoder;
       
    32 import java.nio.charset.CharsetEncoder;
       
    33 import java.util.Arrays;
       
    34 import sun.nio.cs.HistoricallyNamedCharset;
       
    35 import sun.nio.cs.ext.DoubleByte;
       
    36 
       
    37 public class $NAME_CLZ$ extends Charset
       
    38                         $IMPLEMENTS$
       
    39 {
       
    40     public $NAME_CLZ$() {
       
    41         super("$NAME_CS$", $NAME_ALIASES$);
       
    42     }
       
    43 
       
    44     $HISTORICALNAME$
       
    45 
       
    46     public boolean contains(Charset cs) {
       
    47         $CONTAINS$
       
    48     }
       
    49 
       
    50     public CharsetDecoder newDecoder() {
       
    51         initb2c();
       
    52         return new  DoubleByte.Decoder$DECTYPE$(this, b2c, b2cSB, $B2MIN$, $B2MAX$);
       
    53     }
       
    54 
       
    55     public CharsetEncoder newEncoder() {
       
    56         initc2b();
       
    57         return new DoubleByte.Encoder$ENCTYPE$(this, c2b, c2bIndex);
       
    58     }
       
    59 
       
    60     $B2C$
       
    61     static char[][] b2c = new char[b2cStr.length][];
       
    62     static char[] b2cSB;
       
    63     private static volatile boolean b2cInitialized = false;
       
    64 
       
    65     static void initb2c() {
       
    66         if (b2cInitialized)
       
    67             return;
       
    68         synchronized (b2c) {
       
    69             if (b2cInitialized)
       
    70                 return;
       
    71             for (int i = 0; i < b2cStr.length; i++) {
       
    72                 if (b2cStr[i] == null)
       
    73                     b2c[i] = DoubleByte.B2C_UNMAPPABLE;
       
    74                 else
       
    75                     b2c[i] = b2cStr[i].toCharArray();
       
    76             }
       
    77             b2cSB = b2cSBStr.toCharArray();
       
    78             b2cInitialized = true;
       
    79         }
       
    80     }
       
    81 
       
    82     static char[] c2b = new char[$C2BLENGTH$];
       
    83     static char[] c2bIndex = new char[0x100];
       
    84     private static volatile boolean c2bInitialized = false;
       
    85 
       
    86     static void initc2b() {
       
    87         if (c2bInitialized)
       
    88             return;
       
    89         synchronized (c2b) {
       
    90             if (c2bInitialized)
       
    91                 return;
       
    92             $NONROUNDTRIP_B2C$
       
    93             $NONROUNDTRIP_C2B$
       
    94             DoubleByte.Encoder.initC2B(b2cStr, b2cSBStr, b2cNR, c2bNR,
       
    95                                        $B2MIN$, $B2MAX$,
       
    96                                        c2b, c2bIndex);
       
    97             c2bInitialized = true;
       
    98         }
       
    99     }
       
   100 }