Package org.apache.derby.impl.jdbc
Class LOBFile
- java.lang.Object
-
- org.apache.derby.impl.jdbc.LOBFile
-
- Direct Known Subclasses:
EncryptedLOBFile
class LOBFile extends java.lang.ObjectLOBFile 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 private StorageRandomAccessFilerandomAccessFileAn object giving random access tostorageFile.private StorageFilestorageFileThe temporary file where the contents of the LOB should be stored.
-
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) voidclose()Closes the file.(package private) longgetFilePointer()Returns the current position of the file pointer.(package private) StorageFilegetStorageFile()Get theStorageFilewhich represents the file where the contents of the LOB are stored.(package private) longlength()Returns length of the file.(package private) intread(byte[] buff, int off, int len)Reads len number of bytes from the file starting from off position in the buffer.(package private) intreadByte()Reads one byte from file.(package private) voidseek(long pos)Sets the file pointer to a given position.(package private) voidsetLength(long size)Sets the file length to a given size.(package private) voidwrite(byte[] buf)Writes a buffer completely into the file.(package private) voidwrite(byte[] b, int off, int len)Writes a segment of bytes into the file.(package private) voidwrite(int b)Writes one bytes into the file.
-
-
-
Field Detail
-
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 tostorageFile.
-
-
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 theStorageFilewhich represents the file where the contents of the LOB are stored.- Returns:
- a
StorageFileinstance
-
length
long length() throws java.io.IOExceptionReturns 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, StandardExceptionWrites one bytes into the file.- Parameters:
b- int value of the byte- Throws:
java.io.IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
getFilePointer
long getFilePointer() throws java.io.IOExceptionReturns 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, StandardExceptionWrites a segment of bytes into the file.- Parameters:
b- byte array containing bytes to write into the fileoff- starting position of segmentlen- number of bytes to be written- Throws:
java.io.IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
readByte
int readByte() throws java.io.IOException, StandardExceptionReads one byte from file.- Returns:
- byte
- Throws:
java.io.IOException- if disk operation failsStandardException- 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, StandardExceptionReads len number of bytes from the file starting from off position in the buffer.- Parameters:
buff- bufferoff- starting position of bufferlen- number of bytes- Returns:
- number of bytes read
- Throws:
java.io.IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
close
void close() throws java.io.IOExceptionCloses the file.- Throws:
java.io.IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
setLength
void setLength(long size) throws java.io.IOException, StandardExceptionSets the file length to a given size.- Parameters:
size- new size- Throws:
java.io.IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
write
void write(byte[] buf) throws java.io.IOException, StandardExceptionWrites a buffer completely into the file.- Parameters:
buf- buffer to write- Throws:
java.io.IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
-