aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/healthmarketscience
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2014-05-07 03:34:34 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2014-05-07 03:34:34 +0000
commit6f5cf0bdb1958430be42ef3c64b4645a16985b9e (patch)
tree714071dfca919572495f5d117fa0992b8ad90b59 /src/main/java/com/healthmarketscience
parent903e35369a7c7ceea4a73858e4744e17ee8c8eb8 (diff)
downloadjackcess-6f5cf0bdb1958430be42ef3c64b4645a16985b9e.tar.gz
jackcess-6f5cf0bdb1958430be42ef3c64b4645a16985b9e.zip
add getBlob convenience method
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@861 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/Row.java12
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/RowImpl.java7
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/util/OleBlob.java5
3 files changed, 20 insertions, 4 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/Row.java b/src/main/java/com/healthmarketscience/jackcess/Row.java
index e5d797d..08eaa62 100644
--- a/src/main/java/com/healthmarketscience/jackcess/Row.java
+++ b/src/main/java/com/healthmarketscience/jackcess/Row.java
@@ -19,11 +19,13 @@ USA
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;
/**
@@ -102,7 +104,15 @@ public interface Row extends Map<String,Object>
/**
* 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;
}
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/RowImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/RowImpl.java
index 34071ad..dcd4d20 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/RowImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/RowImpl.java
@@ -19,12 +19,14 @@ USA
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;
/**
@@ -103,6 +105,11 @@ public class RowImpl extends LinkedHashMap<String,Object> implements Row
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 + "]")
diff --git a/src/main/java/com/healthmarketscience/jackcess/util/OleBlob.java b/src/main/java/com/healthmarketscience/jackcess/util/OleBlob.java
index 18ae5b7..54f63af 100644
--- a/src/main/java/com/healthmarketscience/jackcess/util/OleBlob.java
+++ b/src/main/java/com/healthmarketscience/jackcess/util/OleBlob.java
@@ -31,7 +31,7 @@ import java.sql.Blob;
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
@@ -56,10 +56,9 @@ import com.healthmarketscience.jackcess.impl.OleUtil;
* <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 = ...;