author | martin |
Wed, 28 Mar 2018 21:14:06 -0700 | |
changeset 49443 | e5679a6661d6 |
parent 48262 | daf3b49f4839 |
child 49556 | 809b178407cc |
permissions | -rw-r--r-- |
2 | 1 |
/* |
45894
995421c69f66
8184665: Skip name and alias checks for standard Charsets
redestad
parents:
42679
diff
changeset
|
2 |
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.nio.cs; |
|
27 |
||
28 |
import java.nio.ByteBuffer; |
|
29 |
import java.nio.CharBuffer; |
|
30 |
import java.nio.charset.Charset; |
|
31 |
import java.nio.charset.CharsetDecoder; |
|
32 |
import java.nio.charset.CharsetEncoder; |
|
33 |
import java.nio.charset.CoderResult; |
|
31671
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
34 |
import java.util.Objects; |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
35 |
|
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
36 |
import jdk.internal.HotSpotIntrinsicCandidate; |
2 | 37 |
|
47026
94c45ad89b9c
8186517: sun.nio.cs.StandardCharsets$Aliases and Classes can be lazily loaded
redestad
parents:
45894
diff
changeset
|
38 |
public class ISO_8859_1 |
2 | 39 |
extends Charset |
40 |
implements HistoricallyNamedCharset |
|
41 |
{ |
|
42 |
public ISO_8859_1() { |
|
47026
94c45ad89b9c
8186517: sun.nio.cs.StandardCharsets$Aliases and Classes can be lazily loaded
redestad
parents:
45894
diff
changeset
|
43 |
super("ISO-8859-1", StandardCharsets.aliases_ISO_8859_1()); |
2 | 44 |
} |
45 |
||
46 |
public String historicalName() { |
|
47 |
return "ISO8859_1"; |
|
48 |
} |
|
49 |
||
50 |
public boolean contains(Charset cs) { |
|
51 |
return ((cs instanceof US_ASCII) |
|
52 |
|| (cs instanceof ISO_8859_1)); |
|
53 |
} |
|
54 |
||
55 |
public CharsetDecoder newDecoder() { |
|
56 |
return new Decoder(this); |
|
57 |
} |
|
58 |
||
59 |
public CharsetEncoder newEncoder() { |
|
60 |
return new Encoder(this); |
|
61 |
} |
|
62 |
||
48262 | 63 |
private static class Decoder extends CharsetDecoder { |
64 |
||
2 | 65 |
private Decoder(Charset cs) { |
66 |
super(cs, 1.0f, 1.0f); |
|
67 |
} |
|
68 |
||
69 |
private CoderResult decodeArrayLoop(ByteBuffer src, |
|
70 |
CharBuffer dst) |
|
71 |
{ |
|
72 |
byte[] sa = src.array(); |
|
73 |
int sp = src.arrayOffset() + src.position(); |
|
74 |
int sl = src.arrayOffset() + src.limit(); |
|
75 |
assert (sp <= sl); |
|
76 |
sp = (sp <= sl ? sp : sl); |
|
77 |
char[] da = dst.array(); |
|
78 |
int dp = dst.arrayOffset() + dst.position(); |
|
79 |
int dl = dst.arrayOffset() + dst.limit(); |
|
80 |
assert (dp <= dl); |
|
81 |
dp = (dp <= dl ? dp : dl); |
|
82 |
||
83 |
try { |
|
84 |
while (sp < sl) { |
|
85 |
byte b = sa[sp]; |
|
86 |
if (dp >= dl) |
|
87 |
return CoderResult.OVERFLOW; |
|
88 |
da[dp++] = (char)(b & 0xff); |
|
89 |
sp++; |
|
90 |
} |
|
91 |
return CoderResult.UNDERFLOW; |
|
92 |
} finally { |
|
93 |
src.position(sp - src.arrayOffset()); |
|
94 |
dst.position(dp - dst.arrayOffset()); |
|
95 |
} |
|
96 |
} |
|
97 |
||
98 |
private CoderResult decodeBufferLoop(ByteBuffer src, |
|
99 |
CharBuffer dst) |
|
100 |
{ |
|
101 |
int mark = src.position(); |
|
102 |
try { |
|
103 |
while (src.hasRemaining()) { |
|
104 |
byte b = src.get(); |
|
105 |
if (!dst.hasRemaining()) |
|
106 |
return CoderResult.OVERFLOW; |
|
107 |
dst.put((char)(b & 0xff)); |
|
108 |
mark++; |
|
109 |
} |
|
110 |
return CoderResult.UNDERFLOW; |
|
111 |
} finally { |
|
112 |
src.position(mark); |
|
113 |
} |
|
114 |
} |
|
115 |
||
116 |
protected CoderResult decodeLoop(ByteBuffer src, |
|
117 |
CharBuffer dst) |
|
118 |
{ |
|
119 |
if (src.hasArray() && dst.hasArray()) |
|
120 |
return decodeArrayLoop(src, dst); |
|
121 |
else |
|
122 |
return decodeBufferLoop(src, dst); |
|
123 |
} |
|
124 |
} |
|
125 |
||
48262 | 126 |
private static class Encoder extends CharsetEncoder { |
127 |
||
2 | 128 |
private Encoder(Charset cs) { |
129 |
super(cs, 1.0f, 1.0f); |
|
130 |
} |
|
131 |
||
132 |
public boolean canEncode(char c) { |
|
133 |
return c <= '\u00FF'; |
|
134 |
} |
|
135 |
||
2294 | 136 |
public boolean isLegalReplacement(byte[] repl) { |
3055
54b677070c61
6847092: (cs) CharsetEncoder.isLegalReplacement of US_ASCII behaves differently since
sherman
parents:
2294
diff
changeset
|
137 |
return true; // we accept any byte value |
2294 | 138 |
} |
139 |
||
2 | 140 |
private final Surrogate.Parser sgp = new Surrogate.Parser(); |
141 |
||
31671
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
142 |
// Method possible replaced with a compiler intrinsic. |
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
143 |
private static int encodeISOArray(char[] sa, int sp, |
31671
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
144 |
byte[] da, int dp, int len) { |
42679
25fec8839946
8159035: com/sun/crypto/provider/Cipher/CTS/CTSMode.java test crashed due to unhandled case of cipher length value as 0
rraghavan
parents:
33663
diff
changeset
|
145 |
if (len <= 0) { |
25fec8839946
8159035: com/sun/crypto/provider/Cipher/CTS/CTSMode.java test crashed due to unhandled case of cipher length value as 0
rraghavan
parents:
33663
diff
changeset
|
146 |
return 0; |
25fec8839946
8159035: com/sun/crypto/provider/Cipher/CTS/CTSMode.java test crashed due to unhandled case of cipher length value as 0
rraghavan
parents:
33663
diff
changeset
|
147 |
} |
31671
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
148 |
encodeISOArrayCheck(sa, sp, da, dp, len); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
149 |
return implEncodeISOArray(sa, sp, da, dp, len); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
150 |
} |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
151 |
|
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
152 |
@HotSpotIntrinsicCandidate |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
153 |
private static int implEncodeISOArray(char[] sa, int sp, |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
154 |
byte[] da, int dp, int len) |
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
155 |
{ |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
156 |
int i = 0; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
157 |
for (; i < len; i++) { |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
158 |
char c = sa[sp++]; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
159 |
if (c > '\u00FF') |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
160 |
break; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
161 |
da[dp++] = (byte)c; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
162 |
} |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
163 |
return i; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
164 |
} |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
165 |
|
31671
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
166 |
private static void encodeISOArrayCheck(char[] sa, int sp, |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
167 |
byte[] da, int dp, int len) { |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
168 |
Objects.requireNonNull(sa); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
169 |
Objects.requireNonNull(da); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
170 |
|
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
171 |
if (sp < 0 || sp >= sa.length) { |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
172 |
throw new ArrayIndexOutOfBoundsException(sp); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
173 |
} |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
174 |
|
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
175 |
if (dp < 0 || dp >= da.length) { |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
176 |
throw new ArrayIndexOutOfBoundsException(dp); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
177 |
} |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
178 |
|
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
179 |
int endIndexSP = sp + len - 1; |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
180 |
if (endIndexSP < 0 || endIndexSP >= sa.length) { |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
181 |
throw new ArrayIndexOutOfBoundsException(endIndexSP); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
182 |
} |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
183 |
|
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
184 |
int endIndexDP = dp + len - 1; |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
185 |
if (endIndexDP < 0 || endIndexDP >= da.length) { |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
186 |
throw new ArrayIndexOutOfBoundsException(endIndexDP); |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
187 |
} |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
188 |
} |
362e0c0acece
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
25859
diff
changeset
|
189 |
|
2 | 190 |
private CoderResult encodeArrayLoop(CharBuffer src, |
191 |
ByteBuffer dst) |
|
192 |
{ |
|
193 |
char[] sa = src.array(); |
|
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
194 |
int soff = src.arrayOffset(); |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
195 |
int sp = soff + src.position(); |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
196 |
int sl = soff + src.limit(); |
2 | 197 |
assert (sp <= sl); |
198 |
sp = (sp <= sl ? sp : sl); |
|
199 |
byte[] da = dst.array(); |
|
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
200 |
int doff = dst.arrayOffset(); |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
201 |
int dp = doff + dst.position(); |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
202 |
int dl = doff + dst.limit(); |
2 | 203 |
assert (dp <= dl); |
204 |
dp = (dp <= dl ? dp : dl); |
|
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
205 |
int dlen = dl - dp; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
206 |
int slen = sl - sp; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
207 |
int len = (dlen < slen) ? dlen : slen; |
2 | 208 |
try { |
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
209 |
int ret = encodeISOArray(sa, sp, da, dp, len); |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
210 |
sp = sp + ret; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
211 |
dp = dp + ret; |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
212 |
if (ret != len) { |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
213 |
if (sgp.parse(sa[sp], sa, sp, sl) < 0) |
2 | 214 |
return sgp.error(); |
215 |
return sgp.unmappableResult(); |
|
216 |
} |
|
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
217 |
if (len < slen) |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
218 |
return CoderResult.OVERFLOW; |
2 | 219 |
return CoderResult.UNDERFLOW; |
220 |
} finally { |
|
15337
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
221 |
src.position(sp - soff); |
3fc0afb7ff5b
8006799: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() (jdk part of 6896617)
kvn
parents:
5506
diff
changeset
|
222 |
dst.position(dp - doff); |
2 | 223 |
} |
224 |
} |
|
225 |
||
226 |
private CoderResult encodeBufferLoop(CharBuffer src, |
|
227 |
ByteBuffer dst) |
|
228 |
{ |
|
229 |
int mark = src.position(); |
|
230 |
try { |
|
231 |
while (src.hasRemaining()) { |
|
232 |
char c = src.get(); |
|
233 |
if (c <= '\u00FF') { |
|
234 |
if (!dst.hasRemaining()) |
|
235 |
return CoderResult.OVERFLOW; |
|
236 |
dst.put((byte)c); |
|
237 |
mark++; |
|
238 |
continue; |
|
239 |
} |
|
240 |
if (sgp.parse(c, src) < 0) |
|
241 |
return sgp.error(); |
|
242 |
return sgp.unmappableResult(); |
|
243 |
} |
|
244 |
return CoderResult.UNDERFLOW; |
|
245 |
} finally { |
|
246 |
src.position(mark); |
|
247 |
} |
|
248 |
} |
|
249 |
||
250 |
protected CoderResult encodeLoop(CharBuffer src, |
|
251 |
ByteBuffer dst) |
|
252 |
{ |
|
253 |
if (src.hasArray() && dst.hasArray()) |
|
254 |
return encodeArrayLoop(src, dst); |
|
255 |
else |
|
256 |
return encodeBufferLoop(src, dst); |
|
257 |
} |
|
258 |
} |
|
259 |
} |