// 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:   OpaqueDescriptor.java
// Class Version:      45.3

package oracle.sql;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintStream;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.SQLException;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleTypes;
import oracle.jdbc.dbaccess.DBError;
import oracle.jdbc.oracore.OracleNamedType;
import oracle.jdbc.oracore.OracleTypeADT;
import oracle.jdbc.oracore.OracleTypeOPAQUE;

// Referenced classes of package oracle.sql:
//            TypeDescriptor, Datum, OPAQUE, SQLName

// flag ACC_SUPER is set
public class OpaqueDescriptor extends TypeDescriptor
    implements Serializable
{
    // Constants:          241
    // Interfaces:         1
    // Fields:             2
    // Methods:            18
    // Class Attributes:   1


    static final boolean DEBUG = false;
    static final long serialVersionUID = 0xe122c1707c9af97L;

    // Decompiling method: <init>  Signature: (Ljava/lang/String;Ljava/sql/Connection;)V
    // Max stack: 3, #locals: 3, #params: 3
    // Code length: 11 bytes, Code offset: 3263
    // Line Number Table found: 3 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 11 Range 0 10 Init 0 fixed
    // Parameter  1 added: Name s Type Ljava/lang/String; At 0 11 Range 0 10 Init 0
    // Parameter  2 added: Name connection Type Ljava/sql/Connection; At 0 11 Range 0 10 Init 0
    // RetValue   3 added: Name <returnValue> Type V At 0 11 Range 0 10 Init 0 fixed
    public OpaqueDescriptor(String s, Connection connection)
        throws SQLException
    {
        super(s, connection);
        initPickler();
        return;
    }

    // Decompiling method: <init>  Signature: (Loracle/jdbc/oracore/OracleTypeADT;Ljava/sql/Connection;)V
    // Max stack: 3, #locals: 3, #params: 3
    // Code length: 7 bytes, Code offset: 3330
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 7 Range 0 6 Init 0 fixed
    // Parameter  1 added: Name oracletypeadt Type Loracle/jdbc/oracore/OracleTypeADT; At 0 7 Range 0 6 Init 0
    // Parameter  2 added: Name connection Type Ljava/sql/Connection; At 0 7 Range 0 6 Init 0
    // RetValue   3 added: Name <returnValue> Type V At 0 7 Range 0 6 Init 0 fixed
    public OpaqueDescriptor(OracleTypeADT oracletypeadt, Connection connection)
        throws SQLException
    {
        super(oracletypeadt, connection);
        return;
    }

    // Decompiling method: <init>  Signature: (Loracle/sql/SQLName;Ljava/sql/Connection;)V
    // Max stack: 3, #locals: 3, #params: 3
    // Code length: 11 bytes, Code offset: 3389
    // Line Number Table found: 3 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 11 Range 0 10 Init 0 fixed
    // Parameter  1 added: Name sqlname Type Loracle/sql/SQLName; At 0 11 Range 0 10 Init 0
    // Parameter  2 added: Name connection Type Ljava/sql/Connection; At 0 11 Range 0 10 Init 0
    // RetValue   3 added: Name <returnValue> Type V At 0 11 Range 0 10 Init 0 fixed
    public OpaqueDescriptor(SQLName sqlname, Connection connection)
        throws SQLException
    {
        super(sqlname, connection);
        initPickler();
        return;
    }

    // Decompiling method: <init>  Signature: (Loracle/sql/SQLName;Loracle/jdbc/oracore/OracleTypeOPAQUE;Ljava/sql/Connection;)V
    // Max stack: 4, #locals: 4, #params: 4
    // Code length: 8 bytes, Code offset: 3456
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 8 Range 0 7 Init 0 fixed
    // Parameter  1 added: Name sqlname Type Loracle/sql/SQLName; At 0 8 Range 0 7 Init 0
    // Parameter  2 added: Name oracletypeopaque Type Loracle/jdbc/oracore/OracleTypeOPAQUE; At 0 8 Range 0 7 Init 0
    // Parameter  3 added: Name connection Type Ljava/sql/Connection; At 0 8 Range 0 7 Init 0
    // RetValue   4 added: Name <returnValue> Type V At 0 8 Range 0 7 Init 0 fixed
    public OpaqueDescriptor(SQLName sqlname, OracleTypeOPAQUE oracletypeopaque, Connection connection)
        throws SQLException
    {
        super(sqlname, oracletypeopaque, connection);
        return;
    }

    // Decompiling method: createDescriptor  Signature: (Ljava/lang/String;Ljava/sql/Connection;)Loracle/sql/OpaqueDescriptor;
    // Max stack: 4, #locals: 5, #params: 2
    // Code length: 86 bytes, Code offset: 3516
    // Line Number Table found: 10 entries
    // Parameter  0 added: Name s Type Ljava/lang/String; At 0 86 Range 0 85 Init 0
    // Parameter  1 added: Name connection Type Ljava/sql/Connection; At 0 86 Range 0 85 Init 0
    // RetValue   5 added: Name <returnValue> Type Loracle/sql/OpaqueDescriptor; At 0 86 Range 0 85 Init 0 fixed
    // LocalVar   2 added: Name sqlname Type Loracle/sql/SQLName; At 34 31 Range 34 64 Init 34
    // LocalVar   3 added: Name s1 Type Ljava/lang/String; At 39 37 Range 39 75 Init 39
    // LocalVar   4 added: Name opaquedescriptor Type Loracle/sql/OpaqueDescriptor; At 53 32 Range 53 84 Init 53
    public static OpaqueDescriptor createDescriptor(String s, Connection connection)
        throws SQLException
    {
        if(s == null || s.length() == 0 || connection == null)
        {
            DBError.check_error(60, "Invalid arguments");
        }
        SQLName sqlname = new SQLName(s, (OracleConnection)connection);
        String s1 = sqlname.getName();
        OpaqueDescriptor opaquedescriptor = (OpaqueDescriptor)((OracleConnection)connection).getDescriptor(s1);
        if(opaquedescriptor == null)
        {
            opaquedescriptor = new OpaqueDescriptor(sqlname, connection);
            ((OracleConnection)connection).putDescriptor(s1, opaquedescriptor);
        }
        return opaquedescriptor;
    }

    // Decompiling method: descType  Signature: ()Ljava/lang/String;
    // Max stack: 3, #locals: 2, #params: 1
    // Code length: 15 bytes, Code offset: 3686
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 15 Range 0 14 Init 0 fixed
    // RetValue   2 added: Name <returnValue> Type Ljava/lang/String; At 0 15 Range 0 14 Init 0 fixed
    // LocalVar   1 added: Name stringbuffer Type Ljava/lang/StringBuffer; At 7 3 Range 7 9 Init 7
    public String descType()
        throws SQLException
    {
        StringBuffer stringbuffer = new StringBuffer();
        return descType(stringbuffer, 0);
    }

    // Decompiling method: descType  Signature: (Ljava/lang/StringBuffer;I)Ljava/lang/String;
    // Max stack: 4, #locals: 6, #params: 3
    // Code length: 146 bytes, Code offset: 3753
    // Line Number Table found: 8 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 146 Range 0 145 Init 0 fixed
    // Parameter  1 added: Name stringbuffer Type Ljava/lang/StringBuffer; At 0 146 Range 0 145 Init 0
    // Parameter  2 added: Name i Type I At 0 146 Range 0 145 Init 0
    // RetValue   6 added: Name <returnValue> Type Ljava/lang/String; At 0 146 Range 0 145 Init 0 fixed
    // LocalVar   3 added: Name s Type Ljava/lang/String; At 2 59 Range 2 60 Init 2
    // LocalVar   4 added: Name flag Type Z At 4 30 Range 4 33 Init 4
    // LocalVar   4 chged: Name j Oname flag Type I At 32 2 Range 4 33 Init 4
    // LocalVar   5 added: Name s1 Type Ljava/lang/String; At 57 2 Range 57 58 Init 57
    String descType(StringBuffer stringbuffer, int i)
        throws SQLException
    {
        String s = "";
        for(int j = 0; j < i; j++)
        {
            s = s + "  ";
        }

        String s1 = s + "  ";
        stringbuffer.append(s);
        stringbuffer.append(getTypeName());
        stringbuffer.append(" maxLen=" + getMaxLength() + " isTrusted=" + isTrustedLibrary() + " hasUnboundedSize=" + hasUnboundedSize() + " hasFixedSize=" + hasFixedSize());
        stringbuffer.append("\n");
        return stringbuffer.toString();
    }

    // Decompiling method: getMaxLength  Signature: ()J
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 22 bytes, Code offset: 3975
    // Line Number Table found: 5 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 22 Range 0 21 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type J At 0 22 Range 0 21 Init 0 fixed
    public long getMaxLength()
        throws SQLException
    {
        return hasUnboundedSize() ? 0L : ((OracleTypeOPAQUE)m_pickler).getMaxLength();
    }

    // Decompiling method: getTypeCode  Signature: ()I
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 4 bytes, Code offset: 4061
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 4 Range 0 3 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type I At 0 4 Range 0 3 Init 0 fixed
    public int getTypeCode()
    {
        return 2007;
    }

    // Decompiling method: hasFixedSize  Signature: ()Z
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4103
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Z At 0 11 Range 0 10 Init 0 fixed
    public boolean hasFixedSize()
        throws SQLException
    {
        return ((OracleTypeOPAQUE)m_pickler).isFixedSized();
    }

    // Decompiling method: hasUnboundedSize  Signature: ()Z
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4162
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Z At 0 11 Range 0 10 Init 0 fixed
    public boolean hasUnboundedSize()
        throws SQLException
    {
        return ((OracleTypeOPAQUE)m_pickler).isUnboundedSized();
    }

    // Decompiling method: initPickler  Signature: ()V
    // Max stack: 5, #locals: 2, #params: 1
    // Code length: 107 bytes, Code offset: 4221
    // Exception table: 1 entries
    //           start  0 end 61 handler 64 type Exception
    // Line Number Table found: 13 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 107 Range 0 106 Init 0 fixed
    // RetValue   2 added: Name <returnValue> Type V At 0 107 Range 0 106 Init 0 fixed
    // LocalVar   1 added: Name exception Type Ljava/lang/Exception; At 64 9 Range 64 72 Init 64
    private void initPickler()
        throws SQLException
    {
        try
        {
            m_pickler = new OracleTypeADT(getName(), m_conn);
            ((OracleTypeADT)m_pickler).init((oracle.jdbc.driver.OracleConnection)m_conn);
            m_pickler = (OracleTypeOPAQUE)((OracleTypeADT)m_pickler).cleanup();
            m_pickler.setDescriptor(this);
        }
        catch(Exception exception)
        {
            if(exception instanceof SQLException)
            {
                throw (SQLException)exception;
            }
            DBError.throwSqlException(60, "Unable to resolve type \"" + getName() + "\"");
        }
        return;
    }

    // Decompiling method: isModeledInC  Signature: ()Z
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4432
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Z At 0 11 Range 0 10 Init 0 fixed
    public boolean isModeledInC()
        throws SQLException
    {
        return ((OracleTypeOPAQUE)m_pickler).isModeledInC();
    }

    // Decompiling method: isTrustedLibrary  Signature: ()Z
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4491
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Z At 0 11 Range 0 10 Init 0 fixed
    public boolean isTrustedLibrary()
        throws SQLException
    {
        return ((OracleTypeOPAQUE)m_pickler).isTrustedLibrary();
    }

    // Decompiling method: readObject  Signature: (Ljava/io/ObjectInputStream;)V
    // Max stack: 2, #locals: 2, #params: 2
    // Code length: 15 bytes, Code offset: 4550
    // Line Number Table found: 3 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 15 Range 0 14 Init 0 fixed
    // Parameter  1 added: Name objectinputstream Type Ljava/io/ObjectInputStream; At 0 15 Range 0 14 Init 0
    // RetValue   2 added: Name <returnValue> Type V At 0 15 Range 0 14 Init 0 fixed
    private void readObject(ObjectInputStream objectinputstream)
        throws IOException, ClassNotFoundException
    {
        if(TypeDescriptor.DEBUG_SERIALIZATION)
        {
            System.out.println("OpaqueDescriptor::readObject");
        }
        return;
    }

    // Decompiling method: toBytes  Signature: (Loracle/sql/OPAQUE;Z)[B
    // Max stack: 2, #locals: 6, #params: 3
    // Code length: 47 bytes, Code offset: 4623
    // Exception table: 1 entries
    //           start  12 end 26 handler 26 type any
    // Line Number Table found: 7 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 47 Range 0 46 Init 0 fixed
    // Parameter  1 added: Name opaque Type Loracle/sql/OPAQUE; At 0 47 Range 0 46 Init 0
    // Parameter  2 added: Name flag Type Z At 0 47 Range 0 46 Init 0
    // RetValue   6 added: Name <returnValue> Type [B At 0 47 Range 0 46 Init 0 fixed
    // LocalVar   3 added: Name abyte0 Type [B At 20 5 Range 20 24 Init 20
    // LocalVar   5 added: Name local Type @ At 34 13 Range 34 46 Init 34
    // LocalVar   4 added: Name exception Type Ljava.lang.Exception; At 26 7 Range 26 32 Init 26
    byte[] toBytes(OPAQUE opaque, boolean flag)
        throws SQLException
    {
        if(opaque.shareBytes() != null)
        {
            return opaque.shareBytes();
        }
        try
        {
            byte abyte0[] = m_pickler.linearize(opaque);
            return abyte0;
        }
        finally
        {
            if(!flag)
            {
                opaque.setShareBytes(null);
            }
        }
    }

    // Decompiling method: toValue  Signature: (Loracle/sql/OPAQUE;Z)[B
    // Max stack: 7, #locals: 6, #params: 3
    // Code length: 59 bytes, Code offset: 4750
    // Exception table: 1 entries
    //           start  12 end 38 handler 38 type any
    // Line Number Table found: 8 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 59 Range 0 58 Init 0 fixed
    // Parameter  1 added: Name opaque Type Loracle/sql/OPAQUE; At 0 59 Range 0 58 Init 0
    // Parameter  2 added: Name flag Type Z At 0 59 Range 0 58 Init 0
    // RetValue   6 added: Name <returnValue> Type [B At 0 59 Range 0 58 Init 0 fixed
    // LocalVar   3 added: Name abyte0 Type [B At 32 5 Range 32 36 Init 32
    // LocalVar   5 added: Name local Type @ At 46 13 Range 46 58 Init 46
    // LocalVar   4 added: Name exception Type Ljava.lang.Exception; At 38 7 Range 38 44 Init 38
    byte[] toValue(OPAQUE opaque, boolean flag)
        throws SQLException
    {
        if(opaque.m_value != null)
        {
            return opaque.m_value;
        }
        try
        {
            m_pickler.unlinearize(opaque.shareBytes(), 0L, opaque, 1, null);
            byte abyte0[] = opaque.m_value;
            return abyte0;
        }
        finally
        {
            if(!flag)
            {
                opaque.m_value = null;
            }
        }
    }

    // Decompiling method: writeObject  Signature: (Ljava/io/ObjectOutputStream;)V
    // Max stack: 2, #locals: 2, #params: 2
    // Code length: 15 bytes, Code offset: 4893
    // Line Number Table found: 3 entries
    // Parameter  0 added: Name this Type Loracle/sql/OpaqueDescriptor; At 0 15 Range 0 14 Init 0 fixed
    // Parameter  1 added: Name objectoutputstream Type Ljava/io/ObjectOutputStream; At 0 15 Range 0 14 Init 0
    // RetValue   2 added: Name <returnValue> Type V At 0 15 Range 0 14 Init 0 fixed
    private void writeObject(ObjectOutputStream objectoutputstream)
        throws IOException
    {
        if(TypeDescriptor.DEBUG_SERIALIZATION)
        {
            System.out.println("OpaqueDescriptor::writeObject");
        }
        return;
    }
}
