Package org.apache.derby.impl.jdbc
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 StorageRandomAccessFile
An object giving random access tostorageFile
.private final StorageFile
The temporary file where the contents of the LOB should be stored. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
close()
Closes the file.(package private) long
Returns the current position of the file pointer.(package private) StorageFile
Get theStorageFile
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.
-
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 theStorageFile
which represents the file where the contents of the LOB are stored.- Returns:
- a
StorageFile
instance
-
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
-