oracle.sql
Class BFILE

java.lang.Object
  |
  +--oracle.sql.Datum
        |
        +--oracle.sql.BFILE

public class BFILE
extends Datum

This class will implements the java.sql.Bfile interface in JDBC 2.0 It provides the native implementation of the Bfile methods.


Method Summary
 java.io.InputStream asciiStreamValue()
          Convert to an ascii stream representation of the datum object
 void closeFile()
          Close the FILE.
 boolean fileExists()
          Find out if a given BFILE (whose locator) points to a file that actually exists on the server's filesystem.
 java.io.InputStream getBinaryStream()
          Retrieve the entire BFILE as a stream.
 byte[] getBytes(long pos, int length)
          Return a copy of the contents of the BFILE at the requested position.
 int getBytes(long pos, int length, byte[] buf)
          Copy the contents of the BFILE at the requested position to suppied buffer.
 OracleConnection getConnection()
          Get connection object.
 java.lang.String getDirAlias()
          Gets the Bfile's directory alias.
 java.lang.String getName()
          Gets the Bfile's file name.
 boolean isConvertibleTo(java.lang.Class jClass)
          Test whether this data object can be converted to the specified Java data type.
 boolean isFileOpen()
          Find out whether a BFILE was opened with the give BFILE.
 long length()
          The length of the BFILE in bytes.
 void openFile()
          Open the FILE.
 long position(BFILE pattern, long start)
          Determine the byte position at which the given pattern
 long position(byte[] pattern, long start)
          Determine the byte position at which the given byte pattern
 java.lang.Object toJdbc()
          Convert this data object into its default Java object type.
 
Methods inherited from class oracle.sql.Datum
bigDecimalValue, binaryStreamValue, booleanValue, byteValue, characterStreamValue, dateValue, doubleValue, equals, floatValue, getBytes, getLength, getStream, intValue, longValue, makeJdbcArray, setBytes, setShareBytes, shareBytes, stringValue, timestampValue, timeValue
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

length

public long length()
            throws java.sql.SQLException
The length of the BFILE in bytes.
Returns:
length of the BFILE in bytes

getBytes

public byte[] getBytes(long pos,
                       int length)
                throws java.sql.SQLException
Return a copy of the contents of the BFILE at the requested position.
Parameters:
pos - is the first byte of the bfile to be extracted.(1-based)
length - is the number of consecutive bytes to be copied.
Returns:
a byte array containing a portion of the BFILE

getBytes

public int getBytes(long pos,
                    int length,
                    byte[] buf)
             throws java.sql.SQLException
Copy the contents of the BFILE at the requested position to suppied buffer.
Parameters:
pos - is the first byte of the bfile to be extracted. (1-based)
length - is the number of consecutive bytes to be copied.
buf - is the buffer to had the extracted bytes.
Returns:
a byte array containing a portion of the BFILE

getBinaryStream

public java.io.InputStream getBinaryStream()
                                    throws java.sql.SQLException
Retrieve the entire BFILE as a stream.
Returns:
a stream containing the BFILE data

position

public long position(byte[] pattern,
                     long start)
              throws java.sql.SQLException
Determine the byte position at which the given byte pattern
Parameters:
pattern - is the pattern to search for.
start - is the position at which to begin searching. (1-based)
Returns:
the position at which the pattern appears, else -1.

position

public long position(BFILE pattern,
                     long start)
              throws java.sql.SQLException
Determine the byte position at which the given pattern
Parameters:
searchstr - is the pattern to search for.
start - is the position at which to begin searching. (1-based)
Returns:
the position at which the pattern appears, else -1.

getName

public java.lang.String getName()
                         throws java.sql.SQLException
Gets the Bfile's file name.
Parameters:
bfile - The Bfile for which to get the file name.
Returns:
The file name.
Throws:
java.sql.SQLException -  

getDirAlias

public java.lang.String getDirAlias()
                             throws java.sql.SQLException
Gets the Bfile's directory alias.
Parameters:
bfile - The Bfile for which to get the directory alias.
Returns:
The directory alias name.
Throws:
java.sql.SQLException -  

openFile

public void openFile()
              throws java.sql.SQLException
Open the FILE.
Parameters:
bfile - The BFILE object to be opened.
Throws:
java.sql.SQLException -  

isFileOpen

public boolean isFileOpen()
                   throws java.sql.SQLException
Find out whether a BFILE was opened with the give BFILE.
Parameters:
bfile - The Bfile to be tested.
Returns:
true if the BFILE was opened, false if it was not opened.
Throws:
java.sql.SQLException -  

fileExists

public boolean fileExists()
                   throws java.sql.SQLException
Find out if a given BFILE (whose locator) points to a file that actually exists on the server's filesystem.
Parameters:
bfile - The Bfile to be tested.
Returns:
true if the physical file exists, false if it does not exist.
Throws:
java.sql.SQLException -  

closeFile

public void closeFile()
               throws java.sql.SQLException
Close the FILE.
Parameters:
bfile - The Bfile to be closed.
Throws:
java.sql.SQLException -  

getConnection

public OracleConnection getConnection()
                               throws java.sql.SQLException
Get connection object.

toJdbc

public java.lang.Object toJdbc()
                        throws java.sql.SQLException
Convert this data object into its default Java object type.
Returns:
this object.
Throws:
java.sql.SQLException - if any of the lower layer code throws an exception.
Overrides:
toJdbc in class Datum

isConvertibleTo

public boolean isConvertibleTo(java.lang.Class jClass)
Test whether this data object can be converted to the specified Java data type.
Parameters:
jClass - specifies the Java data type to test against.
Returns:
true if this data object is convertible to the specified Java class, and a corresponding xxxValue() method is available; otherwise, a false is returned.
Overrides:
isConvertibleTo in class Datum

asciiStreamValue

public java.io.InputStream asciiStreamValue()
                                     throws java.sql.SQLException
Convert to an ascii stream representation of the datum object
Returns:
ascii stream representation of the datum object
Throws:
SQLException, - if no ascii stream representation exists
Overrides:
asciiStreamValue in class Datum