Class LOBFile
java.lang.Object
org.apache.derby.impl.jdbc.LOBFile
- Direct Known Subclasses:
EncryptedLOBFile
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
FieldsModifier and TypeFieldDescriptionprivate final StorageRandomAccessFileAn object giving random access tostorageFile.private final StorageFileThe temporary file where the contents of the LOB should be stored. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidclose()Closes the file.(package private) longReturns the current position of the file pointer.(package private) StorageFileGet 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 Details
-
storageFile
The temporary file where the contents of the LOB should be stored. -
randomAccessFile
An object giving random access tostorageFile.
-
-
Constructor Details
-
LOBFile
LOBFile(StorageFile lobFile) throws FileNotFoundException Constructs LOBFile.- Parameters:
lobFile- StorageFile object for which the file will be created- Throws:
FileNotFoundException- if the file exists but is a directory or cannot be opened
-
-
Method Details
-
getStorageFile
StorageFile getStorageFile()Get theStorageFilewhich represents the file where the contents of the LOB are stored.- Returns:
- a
StorageFileinstance
-
length
Returns length of the file.- Returns:
- length of the file
- Throws:
IOException- if an I/O error occurs
-
seek
Sets the file pointer to a given position.- Parameters:
pos- new position- Throws:
IOException- if an I/O error occurs
-
write
Writes one bytes into the file.- Parameters:
b- int value of the byte- Throws:
IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
getFilePointer
Returns the current position of the file pointer.- Returns:
- file pointer
- Throws:
IOException- if an I/O error occurs
-
write
Writes 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:
IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
readByte
Reads one byte from file.- Returns:
- byte
- Throws:
IOException- if disk operation failsStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
read
Reads 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:
IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
close
Closes the file.- Throws:
IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
setLength
Sets the file length to a given size.- Parameters:
size- new size- Throws:
IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-
write
Writes a buffer completely into the file.- Parameters:
buf- buffer to write- Throws:
IOException- if an I/O error occursStandardException- it won't be thrown, it's in signature to allow subclasses to throw StandardException
-