HSQLDB-Specific Information:
Starting with 2.1, in addition to HSQLDB driver support for both client-side in-memory and remote SQL CLOB data implementations, this class is provided to expose efficient, relatively high-performance CLOB operations over client accessible files.Design Notes
Although it is possible to implement a transactional version of this class, the present implementation directly propagates changes to the underlying file such that changes become visible as soon as they are either implicitly or explicitly flushed to disk.
| Modifier and Type | Class and Description |
|---|---|
| protected class | |
| protected class |
| Modifier and Type | Field and Description |
|---|---|
| private static final FrameworkLogger | |
| private Charset | |
| private boolean | |
| private boolean | |
| private CharsetEncoder | |
| private String | |
| private final File | |
| private boolean | |
| private int | |
| private List | |
| public static final String | |
| public static final String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | JDBCClobFile(String
the name of the character encoding used to read and write
character data in the underlying file, as well as to determine
the character length of and character offsets into the underlying
file. Specify null to denote the platform encoding. encoding)Constructs a new JDBCClobFile instance backed by a File object created by File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX), using the given encoding to read and write file content. |
| public | JDBCClobFile(File
that is to back the new CLOB instance. file)Convenience constructor for |
| public | JDBCClobFile(File
that is to back the new CLOB instance. file, String the name of the character encoding used to read and write
character data in the underlying file, as well as to determine
the character length of and character offsets into the underlying
file. Specify null to denote the platform encoding. encoding)Constructs a new JDBCClobFile instance backed by the given File object using the given encoding to read and write file content. |
| Modifier and Type | Method and Description |
|---|---|
| protected static Charset | |
| protected void | |
| protected final void | |
| private static void | |
| private static void | |
| private static void | |
| private static void | |
| private static void | |
| private static void | |
| private void | |
| protected void | |
| private void | |
| public synchronized void | free()
Implements java. This method frees the |
| public InputStream | Returns: ajava.io.InputStream object containing the
CLOB dataImplements java. Retrieves the |
| public Reader | Returns: ajava.io.Reader object containing the
CLOB dataImplements java. Retrieves the |
| public Reader | Returns: Reader through which the partial Clob value can be read.the offset to the first character of the partial value to
be retrieved. The first character in the Clob is at position 1. pos, long the length in characters of the partial value to be retrieved. length)Implements java. Returns a |
| public String | getEncoding()
Returns: the name of the character encoding used to read and write character data in the underlying files, as well as to determine the character length and character offsets into the underlying file |
| public File | Returns: the file that backs this CLOB.Retrieves the canonical |
| public String | Returns: aString that is the specified substring in
the CLOB value designated by this Clob objectthe first character of the substring to be extracted.
The first character is at position 1. pos, final int the number of consecutive characters to be copied;
the value for length must be 0 or greater length)Implements java. Retrieves a copy of the specified substring
in the |
| public boolean | Returns: true if backing file deletion is attempted; otherwise false.Retrieves whether an attempt to delete the backing file
is made in response to invocation of |
| public long | Returns: length of theCLOB in charactersImplements java. Retrieves the number of characters
in the |
| public long | Returns: the position at which the substring appears or -1 if it is not present; the first position is 1the substring for which to search pattern, final long the position at which to begin searching; the first position
is 1 start)Retrieves the character position at which the specified char[]
|
| public long | Returns: the position at which the substring appears or -1 if it is not present; the first position is 1the substring for which to search searchstr, long the position at which to begin searching; the first position
is 1 start)Implements java. Retrieves the character position at which the specified substring
|
| public long | Returns: the position at which theClob object appears
or -1 if it is not present; the first position is 1the pattern, final long Clob object for which to searchthe position at which to begin searching; the first
position is 1 start)Implements java. Retrieves the character position at which the specified
|
| private long | Returns: the position at which the substring appears or -1 if it is not present; the first position is 1for which to search pattern, final long position at which to begin searching; the first
position is 1 start)Retrieves the character position at which the specified
|
| public OutputStream | Returns: the stream to which ASCII encoded characters can be writtenthe position at which to start writing to this
pos)CLOB object; The first position is 1Implements java. Retrieves a stream to be used to write Ascii characters to the
|
| public Writer | Returns: a stream to which Unicode encoded characters can be writtenthe position at which to start writing to the
pos)CLOB value; The first position is 1Implements java. Retrieves a stream to be used to write a stream of Unicode characters
to the |
| public void | setDeleteOnFree(boolean
the new value to assign deleteOnFree)Assigns whether an attempt to delete the backing file
is made in response to invocation of |
| protected final void | |
| public int | Returns: the number of characters writtenthe position at which to start writing to the pos, final String CLOB
value that this Clob object represents;
The first position is 1the string to be written to the str)CLOB
value that this Clob designatesImplements java. Writes the given Java |
| public int | Returns: the number of characters writtenthe position at which to start writing to this
pos, final String CLOB object; The first position is 1the string to be written to the str, final int CLOB
value that this Clob object representsthe offset into offset, final int str to start reading
the characters to be writtenthe number of characters to be written len)Implements java. Writes |
| public void | truncate(long
the length, in characters, to which the len)CLOB value
should be truncatedImplements java. Truncates the |
| LOG | back to summary |
|---|---|
| private static final FrameworkLogger LOG | |
| m_charset | back to summary |
|---|---|
| private Charset m_charset | |
| m_closed | back to summary |
|---|---|
| private boolean m_closed | |
| m_deleteOnFree | back to summary |
|---|---|
| private boolean m_deleteOnFree | |
| m_encoder | back to summary |
|---|---|
| private CharsetEncoder m_encoder | |
| m_encoding | back to summary |
|---|---|
| private String m_encoding | |
| m_file | back to summary |
|---|---|
| private final File m_file | |
| m_fixedWidthCharset | back to summary |
|---|---|
| private boolean m_fixedWidthCharset | |
| m_maxCharWidth | back to summary |
|---|---|
| private int m_maxCharWidth | |
| m_streams | back to summary |
|---|---|
| private List<Object> m_streams | |
| TEMP_FILE_PREFIX | back to summary |
|---|---|
| public static final String TEMP_FILE_PREFIX | |
| TEMP_FILE_SUFFIX | back to summary |
|---|---|
| public static final String TEMP_FILE_SUFFIX | |
| JDBCClobFile | back to summary |
|---|---|
| public JDBCClobFile() throws SQLException Convenience constructor for
| |
| JDBCClobFile | back to summary |
|---|---|
| public JDBCClobFile(String encoding) throws SQLException Constructs a new JDBCClobFile instance backed by a File object created by File.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX), using the given encoding to read and write file content.
| |
| JDBCClobFile | back to summary |
|---|---|
| public JDBCClobFile(File file) throws SQLException Convenience constructor for
| |
| JDBCClobFile | back to summary |
|---|---|
| public JDBCClobFile(File file, String encoding) throws SQLException Constructs a new JDBCClobFile instance backed by the given File object using the given encoding to read and write file content.
| |
| charsetForName | back to summary |
|---|---|
| protected static Charset charsetForName(final String charsetName) throws UnsupportedEncodingException | |
| checkClosed | back to summary |
|---|---|
| protected void checkClosed() throws SQLException | |
| checkIsFile | back to summary |
|---|---|
| protected final void checkIsFile(final boolean checkExists) throws SQLException | |
| closeSafely | back to summary |
|---|---|
| private static void closeSafely(final RandomAccessFile target) | |
| closeSafely | back to summary |
|---|---|
| private static void closeSafely(final InputStream target) | |
| closeSafely | back to summary |
|---|---|
| private static void closeSafely(final OutputStream target) | |
| closeSafely | back to summary |
|---|---|
| private static void closeSafely(final Reader target) | |
| closeSafely | back to summary |
|---|---|
| private static void closeSafely(final Writer target) | |
| closeSafely | back to summary |
|---|---|
| private static void closeSafely(final Scanner target) | |
| closeSafely | back to summary |
|---|---|
| private void closeSafely(final Object target) | |
| createFile | back to summary |
|---|---|
| protected void createFile() throws SQLException | |
| fillSpace | back to summary |
|---|---|
private void fillSpace(final long startPos, long endPos) throws SQLException
| |
| free | back to summary |
|---|---|
| public synchronized void free() throws SQLException Implements java. This method frees the
After
| |
| getAsciiStream | back to summary |
|---|---|
| public InputStream getAsciiStream() throws SQLException Implements java. Retrieves the
| |
| getCharacterStream | back to summary |
|---|---|
| public Reader getCharacterStream() throws SQLException Implements java. Retrieves the
| |
| getCharacterStream | back to summary |
|---|---|
| public Reader getCharacterStream(long pos, long length) throws SQLException Implements java. Returns a
| |
| getEncoding | back to summary |
|---|---|
public String getEncoding()
| |
| getFile | back to summary |
|---|---|
| public File getFile() Retrieves the canonical
| |
| getSubString | back to summary |
|---|---|
| public String getSubString(final long pos, final int length) throws SQLException Implements java. Retrieves a copy of the specified substring
in the
| |
| isDeleteOnFree | back to summary |
|---|---|
| public boolean isDeleteOnFree() Retrieves whether an attempt to delete the backing file
is made in response to invocation of
| |
| length | back to summary |
|---|---|
| public long length() throws SQLException Implements java. Retrieves the number of characters
in the
| |
| position | back to summary |
|---|---|
| public long position(final char[] pattern, final long start) throws SQLException Retrieves the character position at which the specified char[]
| |
| position | back to summary |
|---|---|
| public long position(String searchstr, long start) throws SQLException Implements java. Retrieves the character position at which the specified substring
| |
| position | back to summary |
|---|---|
| public long position(final Clob pattern, final long start) throws SQLException Implements java. Retrieves the character position at which the specified
| |
| position0 | back to summary |
|---|---|
| private long position0(final String pattern, final long start) throws SQLException Retrieves the character position at which the specified
| |
| setAsciiStream | back to summary |
|---|---|
| public OutputStream setAsciiStream(long pos) throws SQLException Implements java. Retrieves a stream to be used to write Ascii characters to the
Note If the value specified for
| |
| setCharacterStream | back to summary |
|---|---|
| public Writer setCharacterStream(final long pos) throws SQLException Implements java. Retrieves a stream to be used to write a stream of Unicode characters
to the Note If the value specified for HSQLDB-Specific Information: When the value specified forpos is greater then the
length+1, an SQLException is thrown.
| |
| setDeleteOnFree | back to summary |
|---|---|
| public void setDeleteOnFree(boolean deleteOnFree) Assigns whether an attempt to delete the backing file
is made in response to invocation of
| |
| setEncoding | back to summary |
|---|---|
| protected final void setEncoding(final String encoding) throws UnsupportedEncodingException | |
| setString | back to summary |
|---|---|
| public int setString(final long pos, final String str) throws SQLException Implements java. Writes the given Java Note If the value specified for
| |
| setString | back to summary |
|---|---|
| public int setString(final long pos, final String str, final int offset, final int len) throws SQLException Implements java. Writes Note If the value specified for
| |
| truncate | back to summary |
|---|---|
| public void truncate(long len) throws SQLException Implements java. Truncates the Note If the value specified for
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private ByteBuffer | |
| private CharBuffer | |
| private long | |
| private final Reader | |
| private long |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract java. Implements java. Closes the stream and releases any system resources associated with it. |
| public long | |
| public int | read(final char[] cbuf, final int off, int len)
Implements abstract java. Reads characters into a portion of an array. |
| CHARBUFFER_CAPACTIY | back to summary |
|---|---|
| private static final int CHARBUFFER_CAPACTIY | |
| m_byteBuffer | back to summary |
|---|---|
| private ByteBuffer m_byteBuffer | |
| m_charBuffer | back to summary |
|---|---|
| private CharBuffer m_charBuffer | |
| m_filePointer | back to summary |
|---|---|
| private long m_filePointer | |
| m_reader | back to summary |
|---|---|
| private final Reader m_reader | |
| m_remaining | back to summary |
|---|---|
| private long m_remaining | |
| ReaderAdapter | back to summary |
|---|---|
| protected ReaderAdapter(final File file, final long pos, final long length) throws IOException, NullPointerException, IllegalArgumentException, SecurityException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements abstract java. Implements java. Doc from java. Closes the stream and releases any system resources associated with it. Once the stream has been closed, further read(), ready(), mark(), reset(), or skip() invocations will throw an IOException. Closing a previously closed stream has no effect.
| |
| getFilePointer | back to summary |
|---|---|
| public long getFilePointer() | |
| read | back to summary |
|---|---|
| public int read(final char[] cbuf, final int off, int len) throws IOException Implements abstract java. Doc from java. Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached. If
| |
| Modifier and Type | Field and Description |
|---|---|
| protected final Writer |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract java. Implements java. Closes the stream, flushing it first. |
| public void | flush()
Implements abstract java. Implements java. Flushes the stream. |
| public void | write(char[] cbuf, int off, int len)
Implements abstract java. Writes a portion of an array of characters. |
| m_writer | back to summary |
|---|---|
| protected final Writer m_writer | |
| WriterAdapter | back to summary |
|---|---|
| protected WriterAdapter(final File file, final long pos) throws IOException, SecurityException, NullPointerException, IllegalArgumentException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements abstract java. Implements java. Doc from java. Closes the stream, flushing it first. Once the stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously closed stream has no effect.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements abstract java. Implements java. Doc from java. Flushes the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams. If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.
| |
| write | back to summary |
|---|---|
| public void write(char[] cbuf, int off, int len) throws IOException Implements abstract java. Doc from java. Writes a portion of an array of characters.
| |