home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / sun / io / CharToByteSingleByte.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.5 KB  |  116 lines

  1. package sun.io;
  2.  
  3. public abstract class CharToByteSingleByte extends CharToByteConverter {
  4.    protected short[] index1;
  5.    protected String index2;
  6.    protected int mask1;
  7.    protected int mask2;
  8.    protected int shift;
  9.    private char highHalfZoneCode;
  10.  
  11.    public int flush(byte[] var1, int var2, int var3) throws MalformedInputException {
  12.       if (this.highHalfZoneCode != 0) {
  13.          this.highHalfZoneCode = 0;
  14.          super.badInputLength = 0;
  15.          throw new MalformedInputException();
  16.       } else {
  17.          super.byteOff = super.charOff = 0;
  18.          return 0;
  19.       }
  20.    }
  21.  
  22.    public int convert(char[] var1, int var2, int var3, byte[] var4, int var5, int var6) throws MalformedInputException, UnknownCharacterException, ConversionBufferFullException {
  23.       byte[] var11 = new byte[1];
  24.       super.charOff = var2;
  25.       super.byteOff = var5;
  26.       if (this.highHalfZoneCode != 0) {
  27.          char var14 = this.highHalfZoneCode;
  28.          this.highHalfZoneCode = 0;
  29.          if (var1[var2] >= '\udc00' && var1[var2] <= '\udfff') {
  30.             super.badInputLength = 1;
  31.             throw new UnknownCharacterException();
  32.          } else {
  33.             super.badInputLength = 0;
  34.             throw new MalformedInputException();
  35.          }
  36.       } else {
  37.          while(super.charOff < var3) {
  38.             byte[] var8 = var11;
  39.             char var7 = var1[super.charOff];
  40.             int var10 = 1;
  41.             byte var9 = 1;
  42.             if (var7 >= '\ud800' && var7 <= '\udbff') {
  43.                if (super.charOff + 1 >= var3) {
  44.                   this.highHalfZoneCode = var7;
  45.                   break;
  46.                }
  47.  
  48.                var7 = var1[super.charOff + 1];
  49.                if (var7 < '\udc00' || var7 > '\udfff') {
  50.                   super.badInputLength = 1;
  51.                   throw new MalformedInputException();
  52.                }
  53.  
  54.                if (!super.subMode) {
  55.                   super.badInputLength = 2;
  56.                   throw new UnknownCharacterException();
  57.                }
  58.  
  59.                var8 = super.subBytes;
  60.                var10 = super.subBytes.length;
  61.                var9 = 2;
  62.             } else {
  63.                if (var7 >= '\udc00' && var7 <= '\udfff') {
  64.                   super.badInputLength = 1;
  65.                   throw new MalformedInputException();
  66.                }
  67.  
  68.                var11[0] = this.getNative(var7);
  69.                if (var11[0] == 0 && var1[super.charOff] != 0) {
  70.                   if (!super.subMode) {
  71.                      super.badInputLength = 1;
  72.                      throw new UnknownCharacterException();
  73.                   }
  74.  
  75.                   var8 = super.subBytes;
  76.                   var10 = super.subBytes.length;
  77.                }
  78.             }
  79.  
  80.             if (super.byteOff + var10 > var6) {
  81.                throw new ConversionBufferFullException();
  82.             }
  83.  
  84.             for(int var12 = 0; var12 < var10; ++var12) {
  85.                var4[super.byteOff++] = var8[var12];
  86.             }
  87.  
  88.             super.charOff += var9;
  89.          }
  90.  
  91.          return super.byteOff - var5;
  92.       }
  93.    }
  94.  
  95.    public int getMaxBytesPerChar() {
  96.       return 1;
  97.    }
  98.  
  99.    public byte getNative(char var1) {
  100.       return (byte)this.index2.charAt(this.index1[(var1 & this.mask1) >> this.shift] + (var1 & this.mask2));
  101.    }
  102.  
  103.    public void reset() {
  104.       super.byteOff = super.charOff = 0;
  105.       this.highHalfZoneCode = 0;
  106.    }
  107.  
  108.    public boolean canConvert(char var1) {
  109.       if (this.index2.charAt(this.index1[(var1 & this.mask1) >> this.shift] + (var1 & this.mask2)) != 0) {
  110.          return true;
  111.       } else {
  112.          return var1 == 0;
  113.       }
  114.    }
  115. }
  116.