package com.healthmarketscience.jackcess;
+import java.io.IOException;
import java.util.Date;
import java.util.Map;
import java.math.BigDecimal;
import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey;
+import com.healthmarketscience.jackcess.util.OleBlob;
/**
/**
* Convenience method which gets the value for the row with the given name,
- * casting it to a ComplexValueForeignKey (DataType COMPLEX_TYPE).
+ * casting it to a {@link ComplexValueForeignKey} (DataType COMPLEX_TYPE).
*/
public ComplexValueForeignKey getForeignKey(String name);
+
+ /**
+ * Convenience method which gets the value for the row with the given name,
+ * converting it to an {@link OleBlob} (DataTypes OLE).
+ * </p>
+ * Note, <i>the OleBlob should be closed after use</i>.
+ */
+ public OleBlob getBlob(String name) throws IOException;
}
package com.healthmarketscience.jackcess.impl;
+import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Date;
import java.math.BigDecimal;
import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.complex.ComplexValueForeignKey;
+import com.healthmarketscience.jackcess.util.OleBlob;
/**
return (ComplexValueForeignKey)get(name);
}
+ public OleBlob getBlob(String name) throws IOException {
+ byte[] bytes = getBytes(name);
+ return ((bytes != null) ? OleBlob.Builder.fromInternalData(bytes) : null);
+ }
+
@Override
public String toString() {
return CustomToStringStyle.valueBuilder("Row[" + _id + "]")
import com.healthmarketscience.jackcess.impl.OleUtil;
/**
- * Extentions of the Blob interface with additional functionality for working
+ * 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
* <p/>
* <b>Example for interpreting an existing OLE field:</b>
* <pre>
- * byte[] oleBytes = row.getBytes("MyOleColumn");
* OleBlob oleBlob = null;
* try {
- * oleBlob = OleBlob.Builder.fromInternalData(oleBlob);
+ * oleBlob = row.getBlob("MyOleColumn");
* Content content = oleBlob.getContent()
* if(content.getType() == OleBlob.ContentType.SIMPLE_PACKAGE) {
* FileOutputStream out = ...;
for(Row row : t) {
try {
- blob = OleBlob.Builder.fromInternalData(
- row.getBytes("ole"));
+ blob = row.getBlob("ole");
OleBlob.Content content = blob.getContent();
assertSame(blob, content.getBlob());
assertSame(content, blob.getContent());
try {
String name = row.getString("name");
- oleBlob = OleBlob.Builder.fromInternalData(row.getBytes("ole_data"));
+ oleBlob = row.getBlob("ole_data");
OleBlob.Content content = oleBlob.getContent();
Attachment attach = null;
if(content.getType() != OleBlob.ContentType.LINK) {