/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*/
package sun.nio.cs.ext;
import java.nio.CharBuffer;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import sun.nio.cs.HistoricallyNamedCharset;
public class IBM964
extends Charset
implements HistoricallyNamedCharset
{
public IBM964() {
super("x-IBM964", ExtendedCharsets.aliasesFor("x-IBM964"));
}
public String historicalName() {
return "Cp964";
}
public boolean contains(Charset cs) {
return (cs instanceof IBM964);
}
public CharsetDecoder newDecoder() {
return new Decoder(this);
}
public CharsetEncoder newEncoder() {
return new Encoder(this);
}
/**
* These accessors are temporarily supplied while sun.io
* converters co-exist with the sun.nio.cs.{ext} charset coders
* These facilitate sharing of conversion tables between the
* two co-existing implementations. When sun.io converters
* are made extinct these will be unncessary and should be removed
*/
public String getDecoderSingleByteMappings() {
return Decoder.byteToCharTable;
}
public String getDecoderMappingTableG1() {
return Decoder.mappingTableG1;
}
public String getDecoderMappingTableG2a2() {
return Decoder.mappingTableG2a2;
}
public String getDecoderMappingTableG2ac() {
return Decoder.mappingTableG2ac;
}
public String getDecoderMappingTableG2ad() {
return Decoder.mappingTableG2ad;
}
public short[] getEncoderIndex1() {
return Encoder.index1;
}
public String getEncoderIndex2() {
return Encoder.index2;
}
public String getEncoderIndex2a() {
return Encoder.index2a;
}
public String getEncoderIndex2b() {
return Encoder.index2b;
}
public String getEncoderIndex2c() {
return Encoder.index2c;
}
protected static class Decoder extends CharsetDecoder {
private final int SS2 = 0x8E;
private final int SS3 = 0x8F;
private String mappingTableG2;
public Decoder(Charset cs) {
super(cs, 1.0f, 1.0f);
}
private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
byte[] sa = src.array();
int sp = src.arrayOffset() + src.position();
int sl = src.arrayOffset() + src.limit();
assert (sp <= sl);
sp = (sp <= sl ? sp : sl);
char[] da = dst.array();
int dp = dst.arrayOffset() + dst.position();
int dl = dst.arrayOffset() + dst.limit();
assert (dp <= dl);
dp = (dp <= dl ? dp : dl);
try {
while (sp < sl) {
int byte1, byte2;
int inputSize = 1;
char outputChar = '\uFFFD';
byte1 = sa[sp] & 0xff;
if (byte1 == SS2) {
if (sl - sp < 4) {
return CoderResult.UNDERFLOW;
}
byte1 = sa[sp + 1] & 0xff;
inputSize = 2;
if ( byte1 == 0xa2)
mappingTableG2 = mappingTableG2a2;
else if ( byte1 == 0xac)
mappingTableG2 = mappingTableG2ac;
else if ( byte1 == 0xad)
mappingTableG2 = mappingTableG2ad;
else
return CoderResult.malformedForLength(2);
byte1 = sa[sp + 2] & 0xff;
if ( byte1 < 0xa1 || byte1 > 0xfe) {
return CoderResult.malformedForLength(3);
}
byte2 = sa[sp + 3] & 0xff;
if ( byte2 < 0xa1 || byte2 > 0xfe) {
return CoderResult.malformedForLength(4);
}
inputSize = 4;
outputChar = mappingTableG2.charAt(((byte1 - 0xa1) * 94) + byte2 - 0xa1);
} else if(byte1 == SS3 ) {
return CoderResult.malformedForLength(1);
} else if ( byte1 <= 0x9f ) { // valid single byte
outputChar = byteToCharTable.charAt(byte1);
} else if (byte1 < 0xa1 || byte1 > 0xfe) { // invalid range?
return CoderResult.malformedForLength(1);
} else { // G1
if (sl - sp < 2) {
return CoderResult.UNDERFLOW;
}
byte2 = sa[sp + 1] & 0xff;
inputSize = 2;
if ( byte2 < 0xa1 || byte2 > 0xfe) {
return CoderResult.malformedForLength(2);
}
outputChar = mappingTableG1.charAt(((byte1 - 0xa1) * 94) + byte2 - 0xa1);
}
if (outputChar == '\uFFFD')
return CoderResult.unmappableForLength(inputSize);
if (dl - dp < 1)
return CoderResult.OVERFLOW;
da[dp++] = outputChar;
sp += inputSize;
}
return CoderResult.UNDERFLOW;
} finally {
src.position(sp - src.arrayOffset());
dst.position(dp - dst.arrayOffset());
}
}
private CoderResult decodeBufferLoop(ByteBuffer src, CharBuffer dst) {
int mark = src.position();
try {
while (src.hasRemaining()) {
int byte1, byte2;
int inputSize = 1;
char outputChar = '\uFFFD';
byte1 = src.get() & 0xff;
if (byte1 == SS2) {
if (src.remaining() < 3)
return CoderResult.UNDERFLOW;
byte1 = src.get() & 0xff;
inputSize = 2;
if ( byte1 == 0xa2)
mappingTableG2 = mappingTableG2a2;
else if ( byte1 == 0xac)
mappingTableG2 = mappingTableG2ac;
else if ( byte1 == 0xad)
mappingTableG2 = mappingTableG2ad;
else
return CoderResult.malformedForLength(2);
byte1 = src.get() & 0xff;
if ( byte1 < 0xa1 || byte1 > 0xfe)
return CoderResult.malformedForLength(3);
byte2 = src.get() & 0xff;
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jdk 源码 保护 sun com.sum nio misc 等 rc.jar 中的源码 (2000个子文件)
mlib_v_ImageFilters.c 410KB
mlib_ImageColorTrue2Index.c 234KB
pnggccrd.c 231KB
mlib_ImageFilters.c 166KB
check_code.c 161KB
cmstypes.c 156KB
pngrtran.c 143KB
pngvcrd.c 141KB
awt_ImagingLib.c 128KB
mlib_c_ImageLookUp_f.c 107KB
awt_MToolkit.c 105KB
imageioJPEG.c 102KB
mpi.c 101KB
mlib_v_ImageChannelExtract_1.c 93KB
pngrutil.c 91KB
util.c 89KB
gtk2_interface.c 89KB
ProcessPath.c 89KB
cmspack.c 86KB
TwoStacksPlainDatagramSocketImpl.c 84KB
pngwutil.c 84KB
awt_wm.c 80KB
PlainDatagramSocketImpl.c 78KB
mlib_ImageConv_16ext.c 76KB
mlib_ImageConv_u16ext.c 76KB
mlib_ImageConv_8ext.c 76KB
java_crw_demo.c 75KB
mlib_v_ImageAffine_BC_S16.c 75KB
hprof_init.c 75KB
mlib_v_ImageAffine_BC_U16.c 74KB
XlibWrapper.c 71KB
mlib_v_ImageLookUpSIU8U8Func.c 69KB
threadControl.c 68KB
cmscgats.c 68KB
java.c 68KB
p11_convert.c 67KB
mlib_ImageConv_8nw.c 65KB
mlib_ImageConv_16nw.c 65KB
mlib_ImageConv_u16nw.c 65KB
deflate.c 64KB
awt_GraphicsEnv.c 63KB
java.c 62KB
awt_InputMethod.c 61KB
vis_IntArgbPre_Mask.c 60KB
vis_FourByteAbgr.c 60KB
XWindow.c 58KB
JPLISAgent.c 58KB
java_md.c 57KB
hprof_io.c 56KB
mlib_v_ImageAffineIndex_BC.c 56KB
mlib_v_ImageAffine_BC.c 56KB
eventHandler.c 56KB
vis_AlphaMaskBlit.c 56KB
mlib_v_ImageConv_8nw.c 55KB
mlib_v_ImageChannelExtract_43.c 54KB
cmsopt.c 54KB
X11SurfaceData.c 54KB
mlib_v_ImageChannelInsert_1.c 52KB
mlib_v_ImageLookUpU8S16Func.c 52KB
mlib_v_ImageLookUpSIU8S16Func.c 51KB
mlib_v_ImageConvIndex3_8_16nw.c 51KB
mlib_v_ImageConvIndex3_8_8nw.c 51KB
freetypeScaler.c 50KB
cmsio0.c 50KB
mlib_v_ImageLookUpU8U16Func.c 50KB
mlib_v_ImageLookUpSIU8U16Func.c 49KB
pngwrite.c 49KB
inflate.c 49KB
jquant2.c 49KB
mlib_v_ImageChannelInsert_34.c 48KB
multiVis.c 48KB
PLATFORM_API_WinOS_Ports.c 48KB
GSSLibStub.c 48KB
X11Color.c 47KB
pngread.c 47KB
java_md.c 47KB
pngtest.c 47KB
pngpread.c 47KB
mlib_v_ImageLookUpU8U8Func.c 47KB
cmslut.c 47KB
cmsps2.c 47KB
java_md.c 47KB
fontpath.c 46KB
NetworkInterface.c 46KB
hprof_util.c 46KB
mlib_v_ImageConvMxN_8ext.c 46KB
vis_ByteGray_FromRgb.c 45KB
ShapeSpanIterator.c 45KB
mlib_v_ImageConvClearEdge.c 45KB
trees.c 44KB
libjvm_db.c 44KB
net_util_md.c 44KB
debugInit.c 43KB
vis_UshortGray_FromRgb.c 43KB
OGLTextRenderer.c 43KB
mlib_ImageAffineEdge.c 43KB
jdmarker.c 42KB
WindowsNativeDispatcher.c 42KB
jmemmgr.c 42KB
java_md.c 42KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
functionAndClass
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页