home *** CD-ROM | disk | FTP | other *** search
- package sun.io;
-
- public abstract class ByteToCharISO2022 extends ByteToCharConverter {
- protected String[] SODesignator;
- protected String[] SS2Designator;
- protected String[] SS3Designator;
- protected ByteToCharConverter[] SOConverter;
- protected ByteToCharConverter[] SS2Converter;
- protected ByteToCharConverter[] SS3Converter;
- private static final byte ISO_ESC = 27;
- private static final byte ISO_SI = 15;
- private static final byte ISO_SO = 14;
- private static final byte ISO_SS2_7 = 78;
- private static final byte ISO_SS3_7 = 79;
- private static final byte MSB = -128;
- private static final char REPLACE_CHAR = '�';
- private static final byte maximumDesignatorLength = 3;
- private static final byte SOFlag = 0;
- private static final byte SS2Flag = 1;
- private static final byte SS3Flag = 2;
- // $FF: renamed from: G0 byte
- private static final byte field_0 = 0;
- // $FF: renamed from: G1 byte
- private static final byte field_1 = 1;
- private ByteToCharConverter[] tmpConverter;
- private int curSODes;
- private int curSS2Des;
- private int curSS3Des;
- private boolean shiftout;
- private byte[] remainByte = new byte[10];
- private int remainIndex = -1;
- private byte state;
- private byte firstByte;
-
- public void reset() {
- boolean var1 = false;
- this.shiftout = false;
- this.state = 0;
- this.firstByte = 0;
- this.curSODes = 0;
- this.curSS2Des = 0;
- this.curSS3Des = 0;
- super.charOff = super.byteOff = 0;
- this.remainIndex = -1;
-
- for(int var2 = 0; var2 < this.remainByte.length; ++var2) {
- this.remainByte[var2] = 0;
- }
-
- }
-
- public int flush(char[] var1, int var2, int var3) throws MalformedInputException {
- if (this.state != 0) {
- super.badInputLength = 0;
- throw new MalformedInputException();
- } else {
- this.reset();
- return 0;
- }
- }
-
- private byte[] savetyGetSrc(byte[] var1, int var2, int var3, int var4) {
- byte[] var6;
- if (var2 <= var3 - var4 + 1) {
- var6 = new byte[var4];
- } else {
- var6 = new byte[var3 - var2];
- }
-
- for(int var5 = 0; var5 < var6.length; ++var5) {
- var6[var5] = var1[var2 + var5];
- }
-
- return var6;
- }
-
- private char getUnicode(byte var1, byte var2, byte var3) {
- var1 = (byte)(var1 | -128);
- var2 = (byte)(var2 | -128);
- byte[] var4 = new byte[]{var1, var2};
- char[] var5 = new char[1];
- boolean var6 = false;
- int var7 = 0;
- switch (var3) {
- case 0:
- var7 = this.curSODes;
- this.tmpConverter = this.SOConverter;
- break;
- case 1:
- var7 = this.curSS2Des;
- this.tmpConverter = this.SS2Converter;
- break;
- case 2:
- var7 = this.curSS3Des;
- this.tmpConverter = this.SS3Converter;
- }
-
- for(int var11 = 0; var11 < this.tmpConverter.length; ++var11) {
- if (var7 == var11) {
- try {
- this.tmpConverter[var11].convert(var4, 0, 2, var5, 0, 1);
- } catch (Exception var8) {
- }
-
- return var5[0];
- }
- }
-
- return '�';
- }
-
- public final int convert(byte[] var1, int var2, int var3, char[] var4, int var5, int var6) throws ConversionBufferFullException {
- int var8 = 0;
- super.charOff = var5;
- super.byteOff = var2;
-
- while(super.byteOff < var3) {
- if (super.charOff >= var6) {
- throw new ConversionBufferFullException();
- }
-
- if (this.remainIndex < 0) {
- this.remainByte[0] = var1[super.byteOff];
- this.remainIndex = 0;
- ++super.byteOff;
- }
-
- switch (this.remainByte[0]) {
- case 14:
- this.shiftout = true;
- if (this.remainIndex > 0) {
- System.arraycopy(this.remainByte, 1, this.remainByte, 0, this.remainIndex);
- }
-
- --this.remainIndex;
- break;
- case 15:
- this.shiftout = false;
- if (this.remainIndex > 0) {
- System.arraycopy(this.remainByte, 1, this.remainByte, 0, this.remainIndex);
- }
-
- --this.remainIndex;
- break;
- case 27:
- byte[] var9 = this.savetyGetSrc(var1, super.byteOff, var3, 3 - this.remainIndex);
- System.arraycopy(var9, 0, this.remainByte, this.remainIndex + 1, var9.length);
- this.remainIndex += var9.length;
- super.byteOff += var9.length;
- if (var9.length < 3 - this.remainIndex) {
- break;
- }
-
- String var10 = new String(this.remainByte, 1, this.remainIndex);
-
- int var7;
- for(var7 = 0; var7 < this.SODesignator.length; ++var7) {
- if (var10.indexOf(this.SODesignator[var7]) == 0) {
- this.curSODes = var7;
- var8 = this.SODesignator[var7].length();
- break;
- }
- }
-
- if (var7 == this.SODesignator.length) {
- for(var7 = 0; var7 < this.SS2Designator.length; ++var7) {
- if (var10.indexOf(this.SS2Designator[var7]) == 0) {
- this.curSS2Des = var7;
- var8 = this.SS2Designator[var7].length();
- break;
- }
- }
-
- if (var7 == this.SS2Designator.length) {
- for(var7 = 0; var7 < this.SS3Designator.length; ++var7) {
- if (var10.indexOf(this.SS3Designator[var7]) == 0) {
- this.curSS3Des = var7;
- var8 = this.SS3Designator[var7].length();
- break;
- }
- }
-
- if (var7 == this.SS3Designator.length) {
- switch (this.remainByte[1]) {
- case 78:
- var4[super.charOff] = this.getUnicode(this.remainByte[2], this.remainByte[3], (byte)1);
- ++super.charOff;
- var8 = 3;
- break;
- case 79:
- var4[super.charOff] = this.getUnicode(this.remainByte[2], this.remainByte[3], (byte)2);
- ++super.charOff;
- var8 = 3;
- break;
- default:
- var8 = 0;
- }
- }
- }
- }
-
- if (this.remainIndex <= var8) {
- this.remainIndex = -1;
- } else {
- for(var7 = 0; var7 < this.remainIndex - var8; ++var7) {
- this.remainByte[var7] = this.remainByte[var8 + 1 + var7];
- }
-
- this.remainIndex = var7 - 1;
- }
- break;
- default:
- if (!this.shiftout) {
- var4[super.charOff] = (char)this.remainByte[0];
- ++super.charOff;
- } else {
- switch (this.state) {
- case 0:
- this.firstByte = this.remainByte[0];
- this.state = 1;
- break;
- case 1:
- var4[super.charOff] = this.getUnicode(this.firstByte, this.remainByte[0], (byte)0);
- ++super.charOff;
- this.state = 0;
- }
- }
-
- if (this.remainIndex > 0) {
- System.arraycopy(this.remainByte, 1, this.remainByte, 0, this.remainIndex);
- }
-
- --this.remainIndex;
- }
- }
-
- return super.charOff - var5;
- }
- }
-