Class LOBFile

java.lang.Object
org.apache.derby.impl.jdbc.LOBFile
Direct Known Subclasses:
EncryptedLOBFile

class LOBFile extends Object
LOBFile is a wrapper over StorageRandomAccessFile. The purpose of this class is to let the user of this class access StorageRandomAccessFile in plain and in encrypted for without having to change code.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    An object giving random access to storageFile.
    private final StorageFile
    The temporary file where the contents of the LOB should be stored.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs LOBFile.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Closes the file.
    (package private) long
    Returns the current position of the file pointer.
    (package private) StorageFile
    Get the StorageFile which represents the file where the contents of the LOB are stored.
    (package private) long
    Returns length of the file.
    (package private) int
    read(byte[] buff, int off, int len)
    Reads len number of bytes from the file starting from off position in the buffer.
    (package private) int
    Reads one byte from file.
    (package private) void
    seek(long pos)
    Sets the file pointer to a given position.
    (package private) void
    setLength(long size)
    Sets the file length to a given size.
    (package private) void
    write(byte[] buf)
    Writes a buffer completely into the file.
    (package private) void
    write(byte[] b, int off, int len)
    Writes a segment of bytes into the file.
    (package private) void
    write(int b)
    Writes one bytes into the file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • storageFile

      private final StorageFile storageFile
      The temporary file where the contents of the LOB should be stored.
    • randomAccessFile

      private final StorageRandomAccessFile randomAccessFile
      An object giving random access to storageFile.
  • Constructor Details

  • Method Details

    • getStorageFile

      StorageFile getStorageFile()
      Get the StorageFile which represents the file where the contents of the LOB are stored.
      Returns:
      a StorageFile instance
    • length

      long length() throws IOException
      Returns length of the file.
      Returns:
      length of the file
      Throws:
      IOException - if an I/O error occurs
    • seek

      void seek(long pos) throws IOException
      Sets the file pointer to a given position.
      Parameters:
      pos - new position
      Throws:
      IOException - if an I/O error occurs
    • write

      void write(int b) throws IOException, StandardException
      Writes one bytes into the file.
      Parameters:
      b - int value of the byte
      Throws:
      IOException - if an I/O error occurs
      StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException
    • getFilePointer

      long getFilePointer() throws IOException
      Returns the current position of the file pointer.
      Returns:
      file pointer
      Throws:
      IOException - if an I/O error occurs
    • write

      void write(byte[] b, int off, int len) throws IOException, StandardException
      Writes a segment of bytes into the file.
      Parameters:
      b - byte array containing bytes to write into the file
      off - starting position of segment
      len - number of bytes to be written
      Throws:
      IOException - if an I/O error occurs
      StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException
    • readByte

      int readByte() throws IOException, StandardException
      Reads one byte from file.
      Returns:
      byte
      Throws:
      IOException - if disk operation fails
      StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException
    • read

      int read(byte[] buff, int off, int len) throws IOException, StandardException
      Reads len number of bytes from the file starting from off position in the buffer.
      Parameters:
      buff - buffer
      off - starting position of buffer
      len - number of bytes
      Returns:
      number of bytes read
      Throws:
      IOException - if an I/O error occurs
      StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException
    • close

      void close() throws IOException
      Closes the file.
      Throws:
      IOException - if an I/O error occurs
      StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException
    • setLength

      void setLength(long size) throws IOException, StandardException
      Sets the file length to a given size.
      Parameters:
      size - new size
      Throws:
      IOException - if an I/O error occurs
      StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException
    • write

      void write(byte[] buf) throws IOException, StandardException
      Writes a buffer completely into the file.
      Parameters:
      buf - buffer to write
      Throws:
      IOException - if an I/O error occurs
      StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException