Interface OleBlob

  • All Superinterfaces:
    AutoCloseable, Blob, Closeable

    public interface OleBlob
    extends Blob, Closeable
    Extensions of the Blob interface with additional functionality for working with the OLE content from an access database. The ole data type in access has a wide range of functionality (including wrappers with nested wrappers with nested filesystems!), and jackcess only supports a small portion of it. That said, jackcess should support the bulk of the common functionality.

    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(); }
       }
    Author:
    James Ahlborn
    • Method Detail

      • writeTo

        void writeTo​(OutputStream out)
              throws IOException
        Writes the entire raw blob data to the given stream (this is the access db internal format, which includes all wrapper information).
        Parameters:
        out - stream to which the blob will be written
        Throws:
        IOException