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

package oracle.sql;

import java.io.InputStream;
import java.io.Reader;
import java.sql.Connection;
import java.sql.SQLException;
import oracle.jdbc.dbaccess.DBError;
import oracle.jdbc.driver.OracleConnection;
import oracle.jdbc.driver.OracleDriver;

// Referenced classes of package oracle.sql:
//            Datum, BfileDBAccess

// flag ACC_SUPER is set
public class BFILE extends Datum
{
    // Constants:          191
    // Interfaces:         0
    // Fields:             5
    // Methods:            31
    // Class Attributes:   1


    static final int MAX_CHUNK_SIZE = 32512;
    public static final int MODE_READONLY = 0;
    public static final int MODE_READWRITE = 1;
    oracle.jdbc.internal.OracleConnection m_conn;
    BfileDBAccess m_dbaccess;

    // Decompiling method: <init>  Signature: ()V
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 5 bytes, Code offset: 2552
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 5 Range 0 4 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type V At 0 5 Range 0 4 Init 0 fixed
    protected BFILE()
    {
        super();
        return;
    }

    // Decompiling method: <init>  Signature: (Loracle/jdbc/OracleConnection;)V
    // Max stack: 3, #locals: 2, #params: 2
    // Code length: 7 bytes, Code offset: 2595
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 7 Range 0 6 Init 0 fixed
    // Parameter  1 added: Name oracleconnection Type Loracle/jdbc/OracleConnection; At 0 7 Range 0 6 Init 0
    // RetValue   2 added: Name <returnValue> Type V At 0 7 Range 0 6 Init 0 fixed
    public BFILE(oracle.jdbc.OracleConnection oracleconnection)
        throws SQLException
    {
        this(oracleconnection, null);
        return;
    }

    // Decompiling method: <init>  Signature: (Loracle/jdbc/OracleConnection;[B)V
    // Max stack: 2, #locals: 3, #params: 3
    // Code length: 41 bytes, Code offset: 2654
    // Line Number Table found: 7 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 41 Range 0 40 Init 0 fixed
    // Parameter  1 added: Name oracleconnection Type Loracle/jdbc/OracleConnection; At 0 41 Range 0 40 Init 0
    // Parameter  2 added: Name abyte0 Type [B At 0 41 Range 0 40 Init 0
    // RetValue   3 added: Name <returnValue> Type V At 0 41 Range 0 40 Init 0 fixed
    public BFILE(oracle.jdbc.OracleConnection oracleconnection, byte abyte0[])
        throws SQLException
    {
        super(abyte0);
        if(oracleconnection != null)
        {
            m_conn = (oracle.jdbc.internal.OracleConnection)oracleconnection;
        } else
        {
            DBError.check_error(8, "Connection is null");
        }
        m_dbaccess = m_conn.createBfileDBAccess();
        return;
    }

    // Decompiling method: asciiStreamValue  Signature: ()Ljava/io/InputStream;
    // Max stack: 3, #locals: 1, #params: 1
    // Code length: 12 bytes, Code offset: 2767
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 12 Range 0 11 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/io/InputStream; At 0 12 Range 0 11 Init 0 fixed
    public InputStream asciiStreamValue()
        throws SQLException
    {
        return getDBAccess().newConversionInputStream(this, 2);
    }

    // Decompiling method: binaryStreamValue  Signature: ()Ljava/io/InputStream;
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 5 bytes, Code offset: 2827
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 5 Range 0 4 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/io/InputStream; At 0 5 Range 0 4 Init 0 fixed
    public InputStream binaryStreamValue()
        throws SQLException
    {
        return getBinaryStream();
    }

    // Decompiling method: characterStreamValue  Signature: ()Ljava/io/Reader;
    // Max stack: 3, #locals: 1, #params: 1
    // Code length: 13 bytes, Code offset: 2880
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 13 Range 0 12 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/io/Reader; At 0 13 Range 0 12 Init 0 fixed
    public Reader characterStreamValue()
        throws SQLException
    {
        return getDBAccess().newConversionReader(this, 8);
    }

    // Decompiling method: close  Signature: ()V
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 2941
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type V At 0 11 Range 0 10 Init 0 fixed
    public void close()
        throws SQLException
    {
        getDBAccess().close(this);
        return;
    }

    // Decompiling method: closeFile  Signature: ()V
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 3004
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type V At 0 11 Range 0 10 Init 0 fixed
    public void closeFile()
        throws SQLException
    {
        getDBAccess().closeFile(this);
        return;
    }

    // Decompiling method: fileExists  Signature: ()Z
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 3067
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; 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 fileExists()
        throws SQLException
    {
        return getDBAccess().fileExists(this);
    }

    // Decompiling method: getBinaryStream  Signature: ()Ljava/io/InputStream;
    // Max stack: 5, #locals: 1, #params: 1
    // Code length: 15 bytes, Code offset: 3126
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 15 Range 0 14 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/io/InputStream; At 0 15 Range 0 14 Init 0 fixed
    public InputStream getBinaryStream()
        throws SQLException
    {
        return getDBAccess().newInputStream(this, 32512, 0L);
    }

    // Decompiling method: getBinaryStream  Signature: (J)Ljava/io/InputStream;
    // Max stack: 5, #locals: 3, #params: 3
    // Code length: 15 bytes, Code offset: 3189
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 15 Range 0 14 Init 0 fixed
    // Parameter  1 added: Name l Type J At 0 15 Range 0 14 Init 0
    // RetValue   3 added: Name <returnValue> Type Ljava/io/InputStream; At 0 15 Range 0 14 Init 0 fixed
    public InputStream getBinaryStream(long l)
        throws SQLException
    {
        return getDBAccess().newInputStream(this, 32512, l);
    }

    // Decompiling method: getBytes  Signature: (JI)[B
    // Max stack: 6, #locals: 8, #params: 4
    // Code length: 87 bytes, Code offset: 3252
    // Line Number Table found: 13 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 87 Range 0 86 Init 0 fixed
    // Parameter  1 added: Name l Type J At 0 87 Range 0 86 Init 0
    // Parameter  3 added: Name i Type I At 0 87 Range 0 86 Init 0
    // RetValue   8 added: Name <returnValue> Type [B At 0 87 Range 0 86 Init 0 fixed
    // LocalVar   4 added: Name l1 Type J At 25 2 Range 25 26 Init 25
    // LocalVar   6 added: Name abyte0 Type [B At 30 40 Range 30 69 Init 30
    // LocalVar   4 added: Name l2 Type J At 41 35 Range 41 75 Init 41
    // LocalVar   7 added: Name abyte1 Type [B At 66 16 Range 66 81 Init 66
    // LocalVar   4 name l2(J) merged out into l1(J)
    public byte[] getBytes(long l, int i)
        throws SQLException
    {
        if(l < 1L || i < 0)
        {
            DBError.check_error(68, null);
        }
        if(i == 0)
        {
            return new byte[0];
        }
        long l1 = 0L;
        byte abyte0[] = new byte[i];
        l1 = getBytes(l, i, abyte0);
        if(l1 > 0L)
        {
            if(l1 == (long)i)
            {
                return abyte0;
            } else
            {
                byte abyte1[] = new byte[(int)l1];
                System.arraycopy(abyte0, 0, abyte1, 0, (int)l1);
                return abyte1;
            }
        } else
        {
            return new byte[0];
        }
    }

    // Decompiling method: getBytes  Signature: (JI[B)I
    // Max stack: 6, #locals: 5, #params: 5
    // Code length: 15 bytes, Code offset: 3435
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 15 Range 0 14 Init 0 fixed
    // Parameter  1 added: Name l Type J At 0 15 Range 0 14 Init 0
    // Parameter  3 added: Name i Type I At 0 15 Range 0 14 Init 0
    // Parameter  4 added: Name abyte0 Type [B At 0 15 Range 0 14 Init 0
    // RetValue   5 added: Name <returnValue> Type I At 0 15 Range 0 14 Init 0 fixed
    public int getBytes(long l, int i, byte abyte0[])
        throws SQLException
    {
        return getDBAccess().getBytes(this, l, i, abyte0);
    }

    // Decompiling method: getConnection  Signature: ()Loracle/jdbc/driver/OracleConnection;
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 16 bytes, Code offset: 3498
    // Exception table: 1 entries
    //           start  0 end 8 handler 8 type ClassCastException
    // Line Number Table found: 5 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 16 Range 0 15 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Loracle/jdbc/driver/OracleConnection; At 0 16 Range 0 15 Init 0 fixed
    public OracleConnection getConnection()
        throws SQLException
    {
        try
        {
            return (OracleConnection)getJavaSqlConnection();
        }
        catch(ClassCastException _ex)
        {
            DBError.throwSqlException(103);
        }
        return null;
    }

    // Decompiling method: getDBAccess  Signature: ()Loracle/sql/BfileDBAccess;
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 25 bytes, Code offset: 3592
    // Line Number Table found: 5 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 25 Range 0 24 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Loracle/sql/BfileDBAccess; At 0 25 Range 0 24 Init 0 fixed
    public BfileDBAccess getDBAccess()
        throws SQLException
    {
        if(m_dbaccess == null)
        {
            m_dbaccess = getConnection().createBfileDBAccess();
        }
        return m_dbaccess;
    }

    // Decompiling method: getDirAlias  Signature: ()Ljava/lang/String;
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 3681
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/lang/String; At 0 11 Range 0 10 Init 0 fixed
    public String getDirAlias()
        throws SQLException
    {
        return getDBAccess().getDirAlias(this);
    }

    // Decompiling method: getJavaSqlConnection  Signature: ()Ljava/sql/Connection;
    // Max stack: 3, #locals: 1, #params: 1
    // Code length: 29 bytes, Code offset: 3740
    // Line Number Table found: 5 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 29 Range 0 28 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/sql/Connection; At 0 29 Range 0 28 Init 0 fixed
    public Connection getJavaSqlConnection()
        throws SQLException
    {
        if(m_conn == null)
        {
            m_conn = (oracle.jdbc.internal.OracleConnection)(new OracleDriver()).defaultConnection();
        }
        return m_conn;
    }

    // Decompiling method: getLocator  Signature: ()[B
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 5 bytes, Code offset: 3833
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 5 Range 0 4 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type [B At 0 5 Range 0 4 Init 0 fixed
    public byte[] getLocator()
    {
        return getBytes();
    }

    // Decompiling method: getName  Signature: ()Ljava/lang/String;
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 3876
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/lang/String; At 0 11 Range 0 10 Init 0 fixed
    public String getName()
        throws SQLException
    {
        return getDBAccess().getName(this);
    }

    // Decompiling method: isConvertibleTo  Signature: (Ljava/lang/Class;)Z
    // Max stack: 2, #locals: 3, #params: 2
    // Code length: 29 bytes, Code offset: 3935
    // Line Number Table found: 4 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 29 Range 0 28 Init 0 fixed
    // Parameter  1 added: Name class1 Type Ljava/lang/Class; At 0 29 Range 0 28 Init 0
    // RetValue   3 added: Name <returnValue> Type Z At 0 29 Range 0 28 Init 0 fixed
    // LocalVar   2 added: Name s Type Ljava/lang/String; At 4 11 Range 4 14 Init 4
    public boolean isConvertibleTo(Class class1)
    {
        String s = class1.getName();
        return s.compareTo("java.io.InputStream") == 0 || s.compareTo("java.io.Reader") == 0;
    }

    // Decompiling method: isFileOpen  Signature: ()Z
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4014
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; 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 isFileOpen()
        throws SQLException
    {
        return getDBAccess().isFileOpen(this);
    }

    // Decompiling method: isOpen  Signature: ()Z
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4073
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; 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 isOpen()
        throws SQLException
    {
        return getDBAccess().isOpen(this);
    }

    // Decompiling method: length  Signature: ()J
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4132
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type J At 0 11 Range 0 10 Init 0 fixed
    public long length()
        throws SQLException
    {
        return getDBAccess().length(this);
    }

    // Decompiling method: makeJdbcArray  Signature: (I)Ljava/lang/Object;
    // Max stack: 1, #locals: 2, #params: 2
    // Code length: 5 bytes, Code offset: 4191
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 5 Range 0 4 Init 0 fixed
    // Parameter  1 added: Name i Type I At 0 5 Range 0 4 Init 0
    // RetValue   2 added: Name <returnValue> Type Ljava/lang/Object; At 0 5 Range 0 4 Init 0 fixed
    public Object makeJdbcArray(int i)
    {
        return new BFILE[i];
    }

    // Decompiling method: open  Signature: ()V
    // Max stack: 3, #locals: 1, #params: 1
    // Code length: 12 bytes, Code offset: 4234
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 12 Range 0 11 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type V At 0 12 Range 0 11 Init 0 fixed
    public void open()
        throws SQLException
    {
        getDBAccess().open(this, 0);
        return;
    }

    // Decompiling method: open  Signature: (I)V
    // Max stack: 3, #locals: 2, #params: 2
    // Code length: 21 bytes, Code offset: 4298
    // Line Number Table found: 4 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 21 Range 0 20 Init 0 fixed
    // Parameter  1 added: Name i Type I At 0 21 Range 0 20 Init 0
    // RetValue   2 added: Name <returnValue> Type V At 0 21 Range 0 20 Init 0 fixed
    public void open(int i)
        throws SQLException
    {
        if(i != 0)
        {
            DBError.throwSqlException(102);
        }
        getDBAccess().open(this, i);
        return;
    }

    // Decompiling method: openFile  Signature: ()V
    // Max stack: 2, #locals: 1, #params: 1
    // Code length: 11 bytes, Code offset: 4379
    // Line Number Table found: 2 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 11 Range 0 10 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type V At 0 11 Range 0 10 Init 0 fixed
    public void openFile()
        throws SQLException
    {
        getDBAccess().openFile(this);
        return;
    }

    // Decompiling method: position  Signature: (Loracle/sql/BFILE;J)J
    // Max stack: 5, #locals: 4, #params: 4
    // Code length: 13 bytes, Code offset: 4442
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 13 Range 0 12 Init 0 fixed
    // Parameter  1 added: Name bfile Type Loracle/sql/BFILE; At 0 13 Range 0 12 Init 0
    // Parameter  2 added: Name l Type J At 0 13 Range 0 12 Init 0
    // RetValue   4 added: Name <returnValue> Type J At 0 13 Range 0 12 Init 0 fixed
    public long position(BFILE bfile, long l)
        throws SQLException
    {
        return getDBAccess().position(this, bfile, l);
    }

    // Decompiling method: position  Signature: ([BJ)J
    // Max stack: 5, #locals: 4, #params: 4
    // Code length: 13 bytes, Code offset: 4503
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 13 Range 0 12 Init 0 fixed
    // Parameter  1 added: Name abyte0 Type [B At 0 13 Range 0 12 Init 0
    // Parameter  2 added: Name l Type J At 0 13 Range 0 12 Init 0
    // RetValue   4 added: Name <returnValue> Type J At 0 13 Range 0 12 Init 0 fixed
    public long position(byte abyte0[], long l)
        throws SQLException
    {
        return getDBAccess().position(this, abyte0, l);
    }

    // Decompiling method: setLocator  Signature: ([B)V
    // Max stack: 2, #locals: 2, #params: 2
    // Code length: 6 bytes, Code offset: 4564
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 6 Range 0 5 Init 0 fixed
    // Parameter  1 added: Name abyte0 Type [B At 0 6 Range 0 5 Init 0
    // RetValue   2 added: Name <returnValue> Type V At 0 6 Range 0 5 Init 0 fixed
    public void setLocator(byte abyte0[])
    {
        setBytes(abyte0);
        return;
    }

    // Decompiling method: toJdbc  Signature: ()Ljava/lang/Object;
    // Max stack: 1, #locals: 1, #params: 1
    // Code length: 2 bytes, Code offset: 4608
    // Line Number Table found: 1 entries
    // Parameter  0 added: Name this Type Loracle/sql/BFILE; At 0 2 Range 0 1 Init 0 fixed
    // RetValue   1 added: Name <returnValue> Type Ljava/lang/Object; At 0 2 Range 0 1 Init 0 fixed
    public Object toJdbc()
        throws SQLException
    {
        return this;
    }
}
