// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) braces deadcode fieldsfirst 
// Source File Name:   CharacterConverterJAEUC.java
// Class Version:      45.3

package oracle.sql.converter;

import java.io.PrintStream;
import java.sql.SQLException;
import java.util.Vector;

// Referenced classes of package oracle.sql.converter:
//            CharacterConverterLC, CharacterConverter

// flag ACC_SUPER is set
public class CharacterConverterJAEUC extends CharacterConverterLC
{
    // Constants:          111
    // Interfaces:         0
    // Fields:             1
    // Methods:            6
    // Class Attributes:   1


    static final int LEADINGCODE = 143;

    // Decompiling method: <init>  Signature: ()V
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 10 bytes, Code offset: 1379
    // Line Number Table found: 3 entries
    // Parameter  0 added: Name this Type Loracle/sql/converter/CharacterConverterJAEUC; At 0 10 Range 0 9 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type V At 0 10 Range 0 9 Init 0 fixed
    public CharacterConverterJAEUC()
    {
        super();
        m_groupId = 2;
        return;
    }

    // Decompiling method: extractCodepoints  Signature: (Ljava/util/Vector;)V
    // Max stack: 4, #locals: 7, #params: 2
    // Code length: 153 bytes, Code offset: 1435
    // Exception table: 2 entries
    //           start  11 end 38 handler 41 type SQLException
    //           start  68 end 136 handler 139 type SQLException
    // Line Number Table found: 28 entries
    // Parameter  0 added: Name this Type Loracle/sql/converter/CharacterConverterJAEUC; At 0 153 Range 0 152 Init 0 fixed
    // Parameter  1 added: Name vector Type Ljava/util/Vector; At 0 153 Range 0 152 Init 0
    // RetValue   7 added: Name <returnValue> Type V At 0 153 Range 0 152 Init 0 fixed
    // LocalVar   2 added: Name flag Type Z At 1 5 Range 1 5 Init 1
    // LocalVar   3 added: Name i Type I At 4 47 Range 4 50 Init 4
    // LocalVar   5 added: Name flag1 Type Z At 6 44 Range 6 49 Init 6
    // LocalVar   5 chged: Name j Oname flag1 Type I At 48 2 Range 6 49 Init 6
    // LocalVar   2 added: Name k Type I At 56 7 Range 56 62 Init 56
    // LocalVar   3 added: Name l Type I At 61 88 Range 61 148 Init 61
    // LocalVar   6 added: Name i1 Type I At 63 85 Range 63 147 Init 63
    // LocalVar   4 added: Name ai Type [I At 14 21 Range 14 34 Init 14
    // LocalVar   4 added: Name ai1 Type [I At 71 21 Range 71 91 Init 71
    // LocalVar   2 chged: Name j1 Oname flag Type I At 1 5 Range 1 5 Init 1
    // LocalVar   2 name k(I) merged out into j1(I)
    // LocalVar   3 name l(I) merged out into i(I)
    public void extractCodepoints(Vector vector)
    {
        int i = 0;
        int j = 65535;
        for(int k = i; k <= j; k++)
        {
            try
            {
                int ai[] = new int[2];
                ai[0] = k;
                ai[1] = toUnicode(k);
                vector.addElement(ai);
            }
            catch(SQLException _ex) { }
        }

        i = 0x8f0000;
        j = i + 65535;
        for(int l = i; l <= j; l++)
        {
            try
            {
                int ai1[] = new int[2];
                ai1[0] = l;
                ai1[1] = toUnicode(l);
                vector.addElement(ai1);
                System.out.println(Integer.toHexString(l) + " : " + Integer.toHexString(toUnicode(l)));
            }
            catch(SQLException _ex) { }
        }

        return;
    }

    // Decompiling method: toUnicode  Signature: (I)C
    // Max stack: 3, #locals: 6, #params: 2
    // Code length: 82 bytes, Code offset: 1750
    // Line Number Table found: 11 entries
    // Parameter  0 added: Name this Type Loracle/sql/converter/CharacterConverterJAEUC; At 0 82 Range 0 81 Init 0 fixed
    // Parameter  1 added: Name i Type I At 0 82 Range 0 81 Init 0
    // RetValue   6 added: Name <returnValue> Type C At 0 82 Range 0 81 Init 0 fixed
    // LocalVar   2 added: Name flag Type Z At 1 33 Range 1 33 Init 1
    // LocalVar   2 chged: Name j Oname flag Type I At 21 13 Range 1 33 Init 1
    // LocalVar   3 added: Name k Type I At 35 18 Range 35 52 Init 35
    // LocalVar   4 added: Name l Type I At 42 14 Range 42 55 Init 42
    // LocalVar   5 added: Name c Type C At 58 23 Range 58 80 Init 58
    char toUnicode(int i)
        throws SQLException
    {
        int j = 0;
        if((i >> 16 & 0xffff) == 143)
        {
            j = 1 << m_ucsL1KeyWidth;
        }
        int k = (i >> m_ucsL1KeyShift & m_ucsL1KeyMask) + j;
        int l = i & m_ucsL2KeyMask;
        char c = m_ucsCharLevel2[m_ucsCharLevel1[k] + l];
        if(c == m_ucsCharReplacement)
        {
            throw new SQLException("Cannot map Oracle character to Unicode.");
        } else
        {
            return c;
        }
    }

    // Decompiling method: toUnicodeString  Signature: ([BII)Ljava/lang/String;
    // Max stack: 5, #locals: 12, #params: 4
    // Code length: 235 bytes, Code offset: 1920
    // Line Number Table found: 35 entries
    // Parameter  0 added: Name this Type Loracle/sql/converter/CharacterConverterJAEUC; At 0 235 Range 0 234 Init 0 fixed
    // Parameter  1 added: Name abyte0 Type [B At 0 235 Range 0 234 Init 0
    // Parameter  2 added: Name i Type I At 0 235 Range 0 234 Init 0
    // Parameter  3 added: Name j Type I At 0 235 Range 0 234 Init 0
    // RetValue  12 added: Name <returnValue> Type Ljava/lang/String; At 0 235 Range 0 234 Init 0 fixed
    // LocalVar   4 added: Name ac Type [C At 3 225 Range 3 227 Init 3
    // LocalVar   5 added: Name flag Type Z At 6 225 Range 6 230 Init 6
    // LocalVar   5 chged: Name k Oname flag Type I At 229 2 Range 6 230 Init 6
    // LocalVar   6 added: Name l Type I At 18 136 Range 18 153 Init 18
    // LocalVar   8 added: Name flag Type Z At 21 128 Range 21 148 Init 21
    // LocalVar   9 added: Name byte0 Type B At 70 146 Range 70 215 Init 70
    // LocalVar   8 chged: Name i1 Oname flag Type I At 78 71 Range 21 148 Init 21
    // LocalVar  10 added: Name j1 Type I At 150 21 Range 150 170 Init 150
    // LocalVar  11 added: Name k1 Type I At 159 15 Range 159 173 Init 159
    // LocalVar   7 added: Name c Type C At 176 30 Range 176 205 Init 176
    // LocalVar   7 chged: Name l1 Oname c Type I At 204 2 Range 176 205 Init 176
    public String toUnicodeString(byte abyte0[], int i, int j)
        throws SQLException
    {
        char ac[] = new char[j];
        int k = 0;
        while(j > 0) 
        {
            int l = abyte0[i] & 0xff;
            int j1 = 0;
            byte byte0;
            if(l == 143)
            {
                if(j < 3)
                {
                    throw new SQLException("Cannot map Oracle character to Unicode.");
                }
                l = abyte0[i + 1] << 8 & 0xff00 | abyte0[i + 2] & 0xff;
                byte0 = 3;
                j1 = 1 << m_ucsL1KeyWidth;
            } else
            if(l > 127)
            {
                if(j < 2)
                {
                    throw new SQLException("Cannot map Oracle character to Unicode.");
                }
                l = abyte0[i] << 8 & 0xff00 | abyte0[i + 1] & 0xff;
                byte0 = 2;
            } else
            {
                byte0 = 1;
            }
            int k1 = (l >> m_ucsL1KeyShift & m_ucsL1KeyMask) + j1;
            int l1 = l & m_ucsL2KeyMask;
            int i1 = m_ucsCharLevel2[m_ucsCharLevel1[k1] + l1];
            if(i1 == m_ucsCharReplacement)
            {
                throw new SQLException("Cannot map Oracle character to Unicode.");
            }
            ac[k++] = (char)i1;
            j -= byte0;
            i += byte0;
        }
        return new String(ac, 0, k);
    }

    // Decompiling method: toUnicodeStringWithReplacement  Signature: ([BII)Ljava/lang/String;
    // Max stack: 5, #locals: 12, #params: 4
    // Code length: 191 bytes, Code offset: 2339
    // Line Number Table found: 32 entries
    // Parameter  0 added: Name this Type Loracle/sql/converter/CharacterConverterJAEUC; At 0 191 Range 0 190 Init 0 fixed
    // Parameter  1 added: Name abyte0 Type [B At 0 191 Range 0 190 Init 0
    // Parameter  2 added: Name i Type I At 0 191 Range 0 190 Init 0
    // Parameter  3 added: Name j Type I At 0 191 Range 0 190 Init 0
    // RetValue  12 added: Name <returnValue> Type Ljava/lang/String; At 0 191 Range 0 190 Init 0 fixed
    // LocalVar   4 added: Name ac Type [C At 3 181 Range 3 183 Init 3
    // LocalVar   5 added: Name flag Type Z At 6 181 Range 6 186 Init 6
    // LocalVar   5 chged: Name k Oname flag Type I At 185 2 Range 6 186 Init 6
    // LocalVar   6 added: Name l Type I At 18 116 Range 18 133 Init 18
    // LocalVar   8 added: Name flag Type Z At 21 108 Range 21 128 Init 21
    // LocalVar   9 added: Name byte0 Type B At 60 112 Range 60 171 Init 60
    // LocalVar   8 chged: Name i1 Oname flag Type I At 68 61 Range 21 128 Init 21
    // LocalVar  10 added: Name j1 Type I At 130 28 Range 130 157 Init 130
    // LocalVar  11 added: Name k1 Type I At 139 22 Range 139 160 Init 139
    // LocalVar   7 hasn't been used
    public String toUnicodeStringWithReplacement(byte abyte0[], int i, int j)
    {
        char ac[] = new char[j];
        int k = 0;
        while(j > 0) 
        {
            int l = abyte0[i] & 0xff;
            int i1 = 0;
            byte byte0;
            if(l == 143)
            {
                if(j < 3)
                {
                    break;
                }
                l = abyte0[i + 1] << 8 & 0xff00 | abyte0[i + 2] & 0xff;
                byte0 = 3;
                i1 = 1 << m_ucsL1KeyWidth;
            } else
            if(l > 127)
            {
                if(j < 2)
                {
                    break;
                }
                l = abyte0[i] << 8 & 0xff00 | abyte0[i + 1] & 0xff;
                byte0 = 2;
            } else
            {
                byte0 = 1;
            }
            int j1 = (l >> m_ucsL1KeyShift & m_ucsL1KeyMask) + i1;
            int k1 = l & m_ucsL2KeyMask;
            ac[k++] = m_ucsCharLevel2[m_ucsCharLevel1[j1] + k1];
            j -= byte0;
            i += byte0;
        }
        return new String(ac, 0, k);
    }

    // Decompiling method: toUnicodeWithReplacement  Signature: (I)C
    // Max stack: 3, #locals: 5, #params: 2
    // Code length: 59 bytes, Code offset: 2692
    // Line Number Table found: 8 entries
    // Parameter  0 added: Name this Type Loracle/sql/converter/CharacterConverterJAEUC; At 0 59 Range 0 58 Init 0 fixed
    // Parameter  1 added: Name i Type I At 0 59 Range 0 58 Init 0
    // RetValue   5 added: Name <returnValue> Type C At 0 59 Range 0 58 Init 0 fixed
    // LocalVar   2 added: Name flag Type Z At 1 33 Range 1 33 Init 1
    // LocalVar   2 chged: Name j Oname flag Type I At 21 13 Range 1 33 Init 1
    // LocalVar   3 added: Name k Type I At 35 18 Range 35 52 Init 35
    // LocalVar   4 added: Name l Type I At 42 14 Range 42 55 Init 42
    char toUnicodeWithReplacement(int i)
    {
        int j = 0;
        if((i >> 16 & 0xffff) == 143)
        {
            j = 1 << m_ucsL1KeyWidth;
        }
        int k = (i >> m_ucsL1KeyShift & m_ucsL1KeyMask) + j;
        int l = i & m_ucsL2KeyMask;
        return m_ucsCharLevel2[m_ucsCharLevel1[k] + l];
    }
}
