jdk/src/share/classes/sun/nio/cs/ext/EUC_JP.java
author sherman
Tue, 24 Jul 2012 12:17:39 -0700
changeset 13366 2f5fdf6d8c22
parent 7668 d4a77089c587
child 14342 8435a30053c1
permissions -rw-r--r--
6653797: Reimplement JDK charset repository charsets.jar Summary: Migrated all jis based charsets to new implementation Reviewed-by: okutsu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 5785
diff changeset
     2
 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
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: 3714
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3714
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3714
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3714
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3714
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.nio.cs.ext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.nio.ByteBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.nio.CharBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.nio.charset.Charset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.nio.charset.CharsetDecoder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.nio.charset.CharsetEncoder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.nio.charset.CoderResult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.nio.cs.HistoricallyNamedCharset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.nio.cs.Surrogate;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    36
import sun.nio.cs.SingleByte;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    37
import static sun.nio.cs.CharsetMapping.*;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
public class EUC_JP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    extends Charset
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    implements HistoricallyNamedCharset
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    public EUC_JP() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        super("EUC-JP", ExtendedCharsets.aliasesFor("EUC-JP"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    public String historicalName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        return "EUC_JP";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    public boolean contains(Charset cs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        return ((cs.name().equals("US-ASCII"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                || (cs instanceof JIS_X_0201)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
                || (cs instanceof JIS_X_0208)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                || (cs instanceof JIS_X_0212)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                || (cs instanceof EUC_JP));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public CharsetDecoder newDecoder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        return new Decoder(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public CharsetEncoder newEncoder() {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    64
        return new Encoder(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    67
    static class Decoder extends CharsetDecoder
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        implements DelegatableDecoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    70
        final static SingleByte.Decoder DEC0201 =
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    71
            (SingleByte.Decoder)new JIS_X_0201().newDecoder();
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    72
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    73
        final static DoubleByte.Decoder DEC0208 =
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    74
            (DoubleByte.Decoder)new JIS_X_0208().newDecoder();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    76
        final static DoubleByte.Decoder DEC0212 =
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    77
            (DoubleByte.Decoder)new JIS_X_0212().newDecoder();
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    78
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    79
        private final SingleByte.Decoder dec0201;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    80
        private final DoubleByte.Decoder dec0208;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    81
        private final DoubleByte.Decoder dec0212;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        protected Decoder(Charset cs) {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    84
            this(cs, 0.5f, 1.0f, DEC0201, DEC0208, DEC0212);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    86
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    87
        protected Decoder(Charset cs, float avgCpb, float maxCpb,
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    88
                          SingleByte.Decoder dec0201,
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    89
                          DoubleByte.Decoder dec0208,
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    90
                          DoubleByte.Decoder dec0212) {
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    91
            super(cs, avgCpb, maxCpb);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    92
            this.dec0201 = dec0201;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    93
            this.dec0208 = dec0208;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    94
            this.dec0212 = dec0212;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
    97
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        protected char decodeDouble(int byte1, int byte2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            if (byte1 == 0x8e) {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   100
                if (byte2 < 0x80)
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   101
                    return UNMAPPABLE_DECODING;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   102
                return dec0201.decode((byte)byte2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            }
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   104
            return dec0208.decodeDouble(byte1 - 0x80, byte2 - 0x80);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        private CoderResult decodeArrayLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                                            CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            byte[] sa = src.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            int sp = src.arrayOffset() + src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            int sl = src.arrayOffset() + src.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            assert (sp <= sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            sp = (sp <= sl ? sp : sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            char[] da = dst.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            int dp = dst.arrayOffset() + dst.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            int dl = dst.arrayOffset() + dst.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            assert (dp <= dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            dp = (dp <= dl ? dp : dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            int b1 = 0, b2 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            int inputSize = 0;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   124
            char outputChar = UNMAPPABLE_DECODING;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                while (sp < sl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                    b1 = sa[sp] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    inputSize = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                    if ((b1 & 0x80) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                        outputChar = (char)b1;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   132
                    } else {                        // Multibyte char
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   133
                        if (b1 == 0x8f) {           // JIS0212
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                            if (sp + 3 > sl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                               return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                            b1 = sa[sp + 1] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                            b2 = sa[sp + 2] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                            inputSize += 2;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   139
                            if (dec0212 == null)    // JIS02012 not supported
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   140
                                return CoderResult.unmappableForLength(inputSize);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   141
                            outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   142
                        } else {                     // JIS0201, JIS0208
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                            if (sp + 2 > sl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                               return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                            b2 = sa[sp + 1] & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                            inputSize++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                            outputChar = decodeDouble(b1, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                    }
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   150
                    if (outputChar == UNMAPPABLE_DECODING) { // can't be decoded
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                        return CoderResult.unmappableForLength(inputSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                    if (dp + 1 > dl)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                        return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                    da[dp++] = outputChar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                    sp += inputSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                src.position(sp - src.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                dst.position(dp - dst.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        private CoderResult decodeBufferLoop(ByteBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                                             CharBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            int mark = src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            int b1 = 0, b2 = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            int inputSize = 0;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   171
            char outputChar = UNMAPPABLE_DECODING;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                while (src.hasRemaining()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                    b1 = src.get() & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    inputSize = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    if ((b1 & 0x80) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                        outputChar = (char)b1;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   179
                    } else {                         // Multibyte char
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   180
                        if (b1 == 0x8f) {   // JIS0212
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                            if (src.remaining() < 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                               return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                            b1 = src.get() & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                            b2 = src.get() & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                            inputSize += 2;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   186
                            if (dec0212 == null)    // JIS02012 not supported
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   187
                                return CoderResult.unmappableForLength(inputSize);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   188
                            outputChar = dec0212.decodeDouble(b1-0x80, b2-0x80);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   189
                        } else {                     // JIS0201 JIS0208
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                            if (src.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                               return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                            b2 = src.get() & 0xff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                            inputSize++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                            outputChar = decodeDouble(b1, b2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                    }
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   197
                    if (outputChar == UNMAPPABLE_DECODING) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                        return CoderResult.unmappableForLength(inputSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                if (dst.remaining() < 1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                    return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                dst.put(outputChar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                mark += inputSize;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                src.position(mark);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        // Make some protected methods public for use by JISAutoDetect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        public CoderResult decodeLoop(ByteBuffer src, CharBuffer dst) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            if (src.hasArray() && dst.hasArray())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                return decodeArrayLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                return decodeBufferLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        public void implReset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            super.implReset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        public CoderResult implFlush(CharBuffer out) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            return super.implFlush(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   227
    static class Encoder extends CharsetEncoder {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   229
        final static SingleByte.Encoder ENC0201 =
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   230
            (SingleByte.Encoder)new JIS_X_0201().newEncoder();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   232
        final static DoubleByte.Encoder ENC0208 =
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   233
            (DoubleByte.Encoder)new JIS_X_0208().newEncoder();
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   234
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   235
        final static DoubleByte.Encoder ENC0212 =
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   236
            (DoubleByte.Encoder)new JIS_X_0212().newEncoder();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        private final Surrogate.Parser sgp = new Surrogate.Parser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   240
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   241
        private final SingleByte.Encoder enc0201;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   242
        private final DoubleByte.Encoder enc0208;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   243
        private final DoubleByte.Encoder enc0212;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   244
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        protected Encoder(Charset cs) {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   246
            this(cs, 3.0f, 3.0f, ENC0201, ENC0208, ENC0212);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   247
        }
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   248
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   249
        protected Encoder(Charset cs, float avgBpc, float maxBpc,
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   250
                          SingleByte.Encoder enc0201,
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   251
                          DoubleByte.Encoder enc0208,
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   252
                          DoubleByte.Encoder enc0212) {
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   253
            super(cs, avgBpc, maxBpc);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   254
            this.enc0201 = enc0201;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   255
            this.enc0208 = enc0208;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   256
            this.enc0212 = enc0212;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        public boolean canEncode(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            byte[]  encodedBytes = new byte[3];
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   261
            return encodeSingle(c, encodedBytes) != 0 ||
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   262
                   encodeDouble(c) != UNMAPPABLE_ENCODING;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        protected int encodeSingle(char inputChar, byte[] outputByte) {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   266
            int b = enc0201.encode(inputChar);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   267
            if (b == UNMAPPABLE_ENCODING)
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   268
                return 0;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   269
            if (b >= 0 && b < 128) {
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   270
                outputByte[0] = (byte)b;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            outputByte[0] = (byte)0x8e;
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   274
            outputByte[1] = (byte)b;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            return 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        protected int encodeDouble(char ch) {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   279
            int b = enc0208.encodeChar(ch);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   280
            if (b != UNMAPPABLE_ENCODING)
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   281
                return b + 0x8080;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   282
            if (enc0212 != null) {
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   283
                b = enc0212.encodeChar(ch);
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   284
                if (b != UNMAPPABLE_ENCODING)
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   285
                    b += 0x8F8080;
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   286
            }
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   287
            return b;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        private CoderResult encodeArrayLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                                            ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            char[] sa = src.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            int sp = src.arrayOffset() + src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            int sl = src.arrayOffset() + src.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            assert (sp <= sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            sp = (sp <= sl ? sp : sl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            byte[] da = dst.array();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            int dp = dst.arrayOffset() + dst.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            int dl = dst.arrayOffset() + dst.limit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            assert (dp <= dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            dp = (dp <= dl ? dp : dl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            int outputSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            byte[]  outputByte;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            int     inputSize = 0;                 // Size of input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            byte[]  tmpBuf = new byte[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                while (sp < sl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                    outputByte = tmpBuf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    char c = sa[sp];
3714
6a4eb8f53f91 6860431: Character.isSurrogate(char ch)
martin
parents: 2
diff changeset
   313
                    if (Character.isSurrogate(c)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                        if (sgp.parse(c, sa, sp, sl) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                            return sgp.error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                        return sgp.unmappableResult();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                    outputSize = encodeSingle(c, outputByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                    if (outputSize == 0) { // DoubleByte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                        int ncode = encodeDouble(c);
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   321
                        if (ncode != UNMAPPABLE_ENCODING) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                            if ((ncode & 0xFF0000) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                                outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                                outputByte[1] = (byte) (ncode & 0xff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                                outputSize = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                                outputByte[0] = (byte) 0x8f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                                outputByte[1] = (byte) ((ncode & 0xff00) >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                                outputByte[2] = (byte) (ncode & 0xff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                                outputSize = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                        } else {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   333
                            return CoderResult.unmappableForLength(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                    if (dl - dp < outputSize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                        return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                    // Put the byte in the output buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                    for (int i = 0; i < outputSize; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                        da[dp++] = outputByte[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                    sp++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                src.position(sp - src.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                dst.position(dp - dst.arrayOffset());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        private CoderResult encodeBufferLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                                             ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            int outputSize = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            byte[]  outputByte;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            int     inputSize = 0;                 // Size of input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            byte[]  tmpBuf = new byte[3];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            int mark = src.position();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                while (src.hasRemaining()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                    outputByte = tmpBuf;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                    char c = src.get();
3714
6a4eb8f53f91 6860431: Character.isSurrogate(char ch)
martin
parents: 2
diff changeset
   365
                    if (Character.isSurrogate(c)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                        if (sgp.parse(c, src) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                            return sgp.error();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                        return sgp.unmappableResult();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                    outputSize = encodeSingle(c, outputByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                    if (outputSize == 0) { // DoubleByte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                        int ncode = encodeDouble(c);
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   373
                        if (ncode != UNMAPPABLE_ENCODING) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                            if ((ncode & 0xFF0000) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                                outputByte[0] = (byte) ((ncode & 0xff00) >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                                outputByte[1] = (byte) (ncode & 0xff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                                outputSize = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                                outputByte[0] = (byte) 0x8f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                                outputByte[1] = (byte) ((ncode & 0xff00) >> 8);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                                outputByte[2] = (byte) (ncode & 0xff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                                outputSize = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                        } else {
13366
2f5fdf6d8c22 6653797: Reimplement JDK charset repository charsets.jar
sherman
parents: 7668
diff changeset
   385
                            return CoderResult.unmappableForLength(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    if (dst.remaining() < outputSize)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                        return CoderResult.OVERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                    // Put the byte in the output buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                    for (int i = 0; i < outputSize; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                        dst.put(outputByte[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                    mark++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                return CoderResult.UNDERFLOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                src.position(mark);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        protected CoderResult encodeLoop(CharBuffer src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                                         ByteBuffer dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            if (src.hasArray() && dst.hasArray())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                return encodeArrayLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                return encodeBufferLoop(src, dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
}