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

package oracle.jdbc.driver;

import java.sql.SQLException;
import java.util.Map;
import oracle.jdbc.OracleTypes;
import oracle.jdbc.dbaccess.DBError;
import oracle.sql.*;

// Referenced classes of package oracle.jdbc.driver:
//            OracleResultSetImpl, BaseResultSet, OracleConnection, OraclePreparedStatement

// flag ACC_SUPER is set
public class ArrayLocatorResultSet extends OracleResultSetImpl
{
    // Constants:          147
    // Interfaces:         0
    // Fields:             5
    // Methods:            6
    // Class Attributes:   1


    static int COUNT_UNLIMITED = -1;
    Map m_map;
    long m_beginIdx;
    int m_count;
    long m_idx;

    // Decompiling method: <init>  Signature: (Loracle/jdbc/driver/OracleConnection;Loracle/sql/ArrayDescriptor;[BJILjava/util/Map;)V
    // Max stack: 5, #locals: 10, #params: 8
    // Code length: 179 bytes, Code offset: 2218
    // Line Number Table found: 26 entries
    // Parameter  0 added: Name this Type Loracle/jdbc/driver/ArrayLocatorResultSet; At 0 179 Range 0 178 Init 0 fixed
    // Parameter  1 added: Name oracleconnection Type Loracle/jdbc/driver/OracleConnection; At 0 179 Range 0 178 Init 0
    // Parameter  2 added: Name arraydescriptor Type Loracle/sql/ArrayDescriptor; At 0 179 Range 0 178 Init 0
    // Parameter  3 added: Name abyte0 Type [B At 0 179 Range 0 178 Init 0
    // Parameter  4 added: Name l Type J At 0 179 Range 0 178 Init 0
    // Parameter  6 added: Name i Type I At 0 179 Range 0 178 Init 0
    // Parameter  7 added: Name map Type Ljava/util/Map; At 0 179 Range 0 178 Init 0
    // RetValue  10 added: Name <returnValue> Type V At 0 179 Range 0 178 Init 0 fixed
    // LocalVar   8 added: Name obj Type A At 49 2 Range 49 50 Init 49
    // LocalVar   9 added: Name array Type Loracle/sql/ARRAY; At 61 102 Range 61 162 Init 61
    // LocalVar   8 added: Name oraclepreparedstatement Type Loracle/jdbc/driver/OraclePreparedStatement; At 120 55 Range 120 174 Init 120
    // LocalVar   8 chged: Name oraclepreparedstatement1 Oname obj Type Loracle/jdbc/driver/OraclePreparedStatement; At 49 2 Range 49 50 Init 49
    // LocalVar   8 name oraclepreparedstatement(Loracle/jdbc/driver/OraclePreparedStatement;) merged out into oraclepreparedstatement1(Loracle/jdbc/driver/OraclePreparedStatement;)
    public ArrayLocatorResultSet(OracleConnection oracleconnection, ArrayDescriptor arraydescriptor, byte abyte0[], long l, int i, Map map)
        throws SQLException
    {
        super(oracleconnection, null);
        if(arraydescriptor == null || oracleconnection == null)
        {
            DBError.check_error(1, "Invalid arguments");
        }
        close_statement_on_close = true;
        m_count = i;
        m_idx = 0L;
        m_beginIdx = l;
        m_map = map;
        OraclePreparedStatement oraclepreparedstatement = null;
        ARRAY array = new ARRAY(arraydescriptor, oracleconnection, null);
        array.setLocator(abyte0);
        if(arraydescriptor.getBaseType() == 2002 || arraydescriptor.getBaseType() == 2008)
        {
            oraclepreparedstatement = (OraclePreparedStatement)oracleconnection.prepareStatement("SELECT ROWNUM, SYS_NC_ROWINFO$ FROM TABLE( CAST(? AS " + arraydescriptor.getName() + ") )");
        } else
        {
            oraclepreparedstatement = (OraclePreparedStatement)oracleconnection.prepareStatement("SELECT ROWNUM, COLUMN_VALUE FROM TABLE( CAST(? AS " + arraydescriptor.getName() + ") )");
        }
        oraclepreparedstatement.setArray(1, array);
        oraclepreparedstatement.executeQuery();
        statement = oraclepreparedstatement;
        return;
    }

    // Decompiling method: <init>  Signature: (Loracle/jdbc/driver/OracleConnection;Loracle/sql/ArrayDescriptor;[BLjava/util/Map;)V
    // Max stack: 8, #locals: 5, #params: 5
    // Code length: 14 bytes, Code offset: 2545
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/jdbc/driver/ArrayLocatorResultSet; At 0 14 Range 0 13 Init 0 fixed
    // Parameter  1 added: Name oracleconnection Type Loracle/jdbc/driver/OracleConnection; At 0 14 Range 0 13 Init 0
    // Parameter  2 added: Name arraydescriptor Type Loracle/sql/ArrayDescriptor; At 0 14 Range 0 13 Init 0
    // Parameter  3 added: Name abyte0 Type [B At 0 14 Range 0 13 Init 0
    // Parameter  4 added: Name map Type Ljava/util/Map; At 0 14 Range 0 13 Init 0
    // RetValue   5 added: Name <returnValue> Type V At 0 14 Range 0 13 Init 0 fixed
    public ArrayLocatorResultSet(OracleConnection oracleconnection, ArrayDescriptor arraydescriptor, byte abyte0[], Map map)
        throws SQLException
    {
        this(oracleconnection, arraydescriptor, abyte0, 0L, COUNT_UNLIMITED, map);
        return;
    }

    // Decompiling method: findColumn  Signature: (Ljava/lang/String;)I
    // Max stack: 2, #locals: 2, #params: 2
    // Code length: 40 bytes, Code offset: 2611
    // Line Number Table found: 9 entries
    // Parameter  0 added: Name this Type Loracle/jdbc/driver/ArrayLocatorResultSet; At 0 40 Range 0 39 Init 0 fixed
    // Parameter  1 added: Name s Type Ljava/lang/String; At 0 40 Range 0 39 Init 0
    // RetValue   2 added: Name <returnValue> Type I At 0 40 Range 0 39 Init 0 fixed
    public synchronized int findColumn(String s)
        throws SQLException
    {
        connection.trace("ResultSet.findColumn");
        if(s.equalsIgnoreCase("index"))
        {
            return 1;
        }
        if(s.equalsIgnoreCase("value"))
        {
            return 2;
        } else
        {
            DBError.check_error(6, "get_column_index");
            return 0;
        }
    }

    // Decompiling method: getObject  Signature: (I)Ljava/lang/Object;
    // Max stack: 3, #locals: 2, #params: 2
    // Code length: 10 bytes, Code offset: 2731
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/jdbc/driver/ArrayLocatorResultSet; At 0 10 Range 0 9 Init 0 fixed
    // Parameter  1 added: Name i Type I At 0 10 Range 0 9 Init 0
    // RetValue   2 added: Name <returnValue> Type Ljava/lang/Object; At 0 10 Range 0 9 Init 0 fixed
    public synchronized Object getObject(int i)
        throws SQLException
    {
        return getObject(i, m_map);
    }

    // Decompiling method: next  Signature: ()Z
    // Max stack: 6, #locals: 1, #params: 1
    // Code length: 100 bytes, Code offset: 2789
    // Line Number Table found: 12 entries
    // Parameter  0 added: Name this Type Loracle/jdbc/driver/ArrayLocatorResultSet; At 0 100 Range 0 99 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Z At 0 100 Range 0 99 Init 0 fixed
    public synchronized boolean next()
        throws SQLException
    {
        if(m_idx < m_beginIdx)
        {
            while(m_idx < m_beginIdx) 
            {
                m_idx++;
                if(!super.next())
                {
                    return false;
                }
            }
            return true;
        }
        if(m_count == COUNT_UNLIMITED)
        {
            return super.next();
        }
        if(m_idx < (m_beginIdx + (long)m_count) - 1L)
        {
            m_idx++;
            return super.next();
        } else
        {
            return false;
        }
    }

    // Decompiling method: <clinit>  Signature: ()V
    // Max stack: 1, #locals: 0, #params: 0
    // Code length: 5 bytes, Code offset: 2171
    // Line Number Table found: 2 entries
    // RetValue   0 added: Name <returnValue> Type V At 0 5 Range 0 4 Init 0 fixed
    static 
    {
        /* COUNT_UNLIMITED = -1; */
    }
}
