Class LOBFile

  • Direct Known Subclasses:
    EncryptedLOBFile

    class LOBFile
    extends java.lang.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.
    • Constructor Summary

      Constructors 
      Constructor Description
      LOBFile​(StorageFile lobFile)
      Constructs LOBFile.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void close()
      Closes the file.
      (package private) long getFilePointer()
      Returns the current position of the file pointer.
      (package private) StorageFile getStorageFile()
      Get the StorageFile which represents the file where the contents of the LOB are stored.
      (package private) long length()
      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 readByte()
      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 Detail

      • storageFile

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

      • LOBFile

        LOBFile​(StorageFile lobFile)
         throws java.io.FileNotFoundException
        Constructs LOBFile.
        Parameters:
        lobFile - StorageFile object for which the file will be created
        Throws:
        java.io.FileNotFoundException - if the file exists but is a directory or cannot be opened
    • Method Detail

      • 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 java.io.IOException
        Returns length of the file.
        Returns:
        length of the file
        Throws:
        java.io.IOException - if an I/O error occurs
      • seek

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

        void write​(int b)
            throws java.io.IOException,
                   StandardException
        Writes one bytes into the file.
        Parameters:
        b - int value of the byte
        Throws:
        java.io.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 java.io.IOException
        Returns the current position of the file pointer.
        Returns:
        file pointer
        Throws:
        java.io.IOException - if an I/O error occurs
      • write

        void write​(byte[] b,
                   int off,
                   int len)
            throws java.io.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:
        java.io.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 java.io.IOException,
                     StandardException
        Reads one byte from file.
        Returns:
        byte
        Throws:
        java.io.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 java.io.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:
        java.io.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 java.io.IOException
        Closes the file.
        Throws:
        java.io.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 java.io.IOException,
                       StandardException
        Sets the file length to a given size.
        Parameters:
        size - new size
        Throws:
        java.io.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 java.io.IOException,
                   StandardException
        Writes a buffer completely into the file.
        Parameters:
        buf - buffer to write
        Throws:
        java.io.IOException - if an I/O error occurs
        StandardException - it won't be thrown, it's in signature to allow subclasses to throw StandardException