public interface OleBlob extends Blob, Closeable
The main Blob methods will interact with the entire OLE field data
which, in most cases, contains additional wrapper information. In order to
access the ultimate "content" contained within the OLE data, the getContent()
method should be used. The type of this content may be a
variety of formats, so additional sub-interfaces are available to interact
with it. The most specific sub-interface can be determined by the OleBlob.ContentType
of the Content.
Once an OleBlob is no longer useful, it should be closed using
Blob.free()
or Closeable.close()
methods (after which, the instance will no
longer be functional).
Note, the OleBlob implementation is read-only (through the interface). In
order to modify blob contents, create a new OleBlob instance using OleBlob.Builder
and write it to the access database.
Example for interpreting an existing OLE field:
OleBlob oleBlob = null; try { oleBlob = row.getBlob("MyOleColumn"); Content content = oleBlob.getContent() if(content.getType() == OleBlob.ContentType.SIMPLE_PACKAGE) { FileOutputStream out = ...; ((SimplePackageContent)content).writeTo(out); out.closee(); } } finally { if(oleBlob != null) { oleBlob.close(); } }
Example for creating new, embedded ole data:
OleBlob oleBlob = null; try { oleBlob = new OleBlob.Builder() .setSimplePackage(new File("some_data.txt")) .toBlob(); db.addRow(1, oleBlob); } finally { if(oleBlob != null) { oleBlob.close(); } }
Example for creating new, linked ole data:
OleBlob oleBlob = null; try { oleBlob = new OleBlob.Builder() .setLink(new File("some_data.txt")) .toBlob(); db.addRow(1, oleBlob); } finally { if(oleBlob != null) { oleBlob.close(); } }
Modifier and Type | Interface and Description |
---|---|
static class |
OleBlob.Builder
Builder style class for constructing an OleBlob.
|
static interface |
OleBlob.CompoundContent
Sub-interface for Content which has the
OleBlob.ContentType.COMPOUND_STORAGE type. |
static interface |
OleBlob.Content |
static class |
OleBlob.ContentType
Enum describing the types of blob contents which are currently
supported/understood
|
static interface |
OleBlob.EmbeddedContent
Intermediate sub-interface for Content which has embedded content.
|
static interface |
OleBlob.LinkContent
Sub-interface for Content which has the
OleBlob.ContentType.LINK type. |
static interface |
OleBlob.OtherContent
Sub-interface for Content which has the
OleBlob.ContentType.OTHER type. |
static interface |
OleBlob.PackageContent
Intermediate sub-interface for Content which has a nested package.
|
static interface |
OleBlob.SimplePackageContent
Sub-interface for Content which has the
OleBlob.ContentType.SIMPLE_PACKAGE type. |
Modifier and Type | Method and Description |
---|---|
OleBlob.Content |
getContent()
Returns the decoded form of the blob contents, if understandable.
|
void |
writeTo(OutputStream out)
Writes the entire raw blob data to the given stream (this is the access
db internal format, which includes all wrapper information).
|
free, getBinaryStream, getBinaryStream, getBytes, length, position, position, setBinaryStream, setBytes, setBytes, truncate
void writeTo(OutputStream out) throws IOException
out
- stream to which the blob will be writtenIOException
OleBlob.Content getContent() throws IOException
IOException
Copyright © 2005–2024 OpenHMS. All rights reserved.