final class LOBStreamControl
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
private int |
bufferSize |
|
private EmbedConnection |
conn |
|
private byte[] |
dataBytes |
|
private static int |
DEFAULT_BUF_SIZE |
|
private boolean |
isBytes |
|
private static int |
MAX_BUF_SIZE |
|
private LOBFile |
tmpFile |
|
private long |
updateCount |
Constructor | Description |
---|---|
LOBStreamControl(EmbedConnection conn) |
Creates an empty LOBStreamControl.
|
LOBStreamControl(EmbedConnection conn,
byte[] data) |
Creates a LOBStreamControl and initializes with a bytes array.
|
Modifier and Type | Method | Description |
---|---|---|
(package private) void |
copyData(java.io.InputStream inStream,
long length) |
Copies bytes from stream to local storage.
|
(package private) long |
copyUtf8Data(java.io.InputStream utf8Stream,
long charLength) |
Copies UTF-8 encoded chars from a stream to local storage.
|
private void |
deleteFile(StorageFile file) |
|
protected void |
finalize() |
|
private static java.lang.Object |
findService(java.lang.String factoryInterface,
java.lang.String serviceName) |
Privileged service lookup.
|
private static java.lang.Object |
findServiceModule(java.lang.Object serviceModule,
java.lang.String factoryInterface) |
Privileged startup.
|
(package private) void |
free() |
Invalidates all the variables and closes file handle if open.
|
(package private) java.io.InputStream |
getInputStream(long pos) |
returns input stream linked with this object.
|
(package private) long |
getLength() |
Returns length of data.
|
(package private) java.io.OutputStream |
getOutputStream(long pos) |
returns output stream linked with this object
|
(package private) long |
getUpdateCount() |
Returns the running sequence number to check if the lob is updated since
last access.
|
private void |
init(byte[] b,
long len) |
|
private void |
isValidOffset(int off,
int length) |
|
private void |
isValidPostion(long pos) |
|
(package private) int |
read(byte[] buff,
int off,
int len,
long pos) |
Reads bytes starting from 'position' into bytes array.
|
(package private) int |
read(long pos) |
Reads one byte.
|
private int |
readBytes(byte[] b,
int off,
int len,
long pos) |
|
private void |
releaseTempFile(LOBFile file) |
Close and release all resources held by a temporary file.
|
(package private) long |
replaceBytes(byte[] buf,
long stPos,
long endPos) |
Replaces a block of bytes in the middle of the LOB with a another block
of bytes, which may be of a different size.
|
(package private) void |
truncate(long size) |
Resets the size.
|
private long |
updateData(byte[] bytes,
int offset,
int len,
long pos) |
|
(package private) long |
write(byte[] b,
int off,
int len,
long pos) |
Writes
len bytes from the specified byte array to the LOB. |
(package private) long |
write(int b,
long pos) |
Writes one byte.
|
private LOBFile tmpFile
private byte[] dataBytes
private boolean isBytes
private final int bufferSize
private final EmbedConnection conn
private long updateCount
private static final int DEFAULT_BUF_SIZE
private static final int MAX_BUF_SIZE
LOBStreamControl(EmbedConnection conn)
conn
- Connection for this lobLOBStreamControl(EmbedConnection conn, byte[] data) throws java.io.IOException, StandardException
conn
- Connection for this lobdata
- initial valuejava.io.IOException
StandardException
private void init(byte[] b, long len) throws java.io.IOException, StandardException
java.io.IOException
StandardException
private long updateData(byte[] bytes, int offset, int len, long pos) throws StandardException
StandardException
private void isValidPostion(long pos) throws java.io.IOException, StandardException
java.io.IOException
StandardException
private void isValidOffset(int off, int length) throws StandardException
StandardException
long write(int b, long pos) throws java.io.IOException, StandardException
b
- bytepos
- java.io.IOException
- if writing to the LOB file failsStandardException
- if encrypting/decrypting the LOB file failslong write(byte[] b, int off, int len, long pos) throws java.io.IOException, StandardException
len
bytes from the specified byte array to the LOB.b
- byte arrayoff
- offset from where to read from the byte arraylen
- number of bytes to be writtenpos
- starting positionjava.io.IOException
- if writing to the LOB failsStandardException
- if writing to the LOB failsjava.lang.IndexOutOfBoundsException
- if len
is larger than
b.length - off
int read(long pos) throws java.io.IOException, StandardException
pos
- position from where to readjava.io.IOException
- if reading the LOB file failsStandardException
- if decrypting an encrypted LOB file failsprivate int readBytes(byte[] b, int off, int len, long pos)
int read(byte[] buff, int off, int len, long pos) throws java.io.IOException, StandardException
buff
- array into the bytes will be copiedoff
- offset from where the array has to be populatedlen
- number of bytes to readpos
- initial position before readingjava.io.IOException
- if reading the LOB file failsStandardException
- if decrypting an encrypted LOB file failsjava.io.InputStream getInputStream(long pos)
pos
- initial postionjava.io.OutputStream getOutputStream(long pos)
pos
- initial postionlong getLength() throws java.io.IOException
java.io.IOException
void truncate(long size) throws java.io.IOException, StandardException
size
- new size should be smaller than existing sizejava.io.IOException
StandardException
void copyData(java.io.InputStream inStream, long length) throws java.io.IOException, StandardException
Note that specifying the length as Long.MAX_VALUE
results in
reading data from the stream until EOF is reached, but no length checking
will be performed.
inStream
- the stream to copy fromlength
- number of bytes to be copied, or Long.MAX_VALUE
to
copy everything until EOF is reachedjava.io.IOException
- if reading or writing a LOB file failsStandardException
- if encrypting or decrypting a LOB file failslong copyUtf8Data(java.io.InputStream utf8Stream, long charLength) throws java.io.IOException, StandardException
Note that specifying the length as Long.MAX_VALUE
results in
reading data from the stream until EOF is reached, but no length checking
will be performed.
utf8Stream
- the stream to copy fromcharLength
- number of chars to be copied, or Long.MAX_VALUE
to copy everything until EOF is reachedjava.io.EOFException
- if EOF is reached prematurelyjava.io.IOException
- thrown on a number of error conditionsStandardException
- if reading, writing or truncating the
LOBStreamControl
-object failsjava.io.UTFDataFormatException
- if an invalid UTF-8 encoding is detectedprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
private void deleteFile(StorageFile file)
void free() throws java.io.IOException
java.io.IOException
- if closing the file failsprivate void releaseTempFile(LOBFile file) throws java.io.IOException
LOBFile
s in EmbedConnection
.file
- the temporary filejava.io.IOException
- if the file cannot be closed or deletedlong replaceBytes(byte[] buf, long stPos, long endPos) throws java.io.IOException, StandardException
The new byte array may not be be of same length as the original, thus it may result in resizing the total lob.
buf
- byte array which will be written inplace of old blockstPos
- inclusive starting position of current blockendPos
- exclusive end position of current blockjava.io.IOException
- if writing to the temporary file failsStandardException
long getUpdateCount()
private static java.lang.Object findServiceModule(java.lang.Object serviceModule, java.lang.String factoryInterface) throws StandardException
StandardException
private static java.lang.Object findService(java.lang.String factoryInterface, java.lang.String serviceName)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.