aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2021-01-21 01:15:35 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2021-01-21 01:15:35 +0000
commit5468f8ffce2edb2a786aecdf5d07ecab6969af1c (patch)
treee042d2f137b1475c422382ab8f30bfa2d43fd603 /src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
parent02e1648130171296b27231dbd780eb32e44edc5f (diff)
parent65d69efe9f464d306dfc5783bc891baee812ef48 (diff)
downloadjackcess-5468f8ffce2edb2a786aecdf5d07ecab6969af1c.tar.gz
jackcess-5468f8ffce2edb2a786aecdf5d07ecab6969af1c.zip
merge modules branch
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1356 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java')
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java53
1 files changed, 19 insertions, 34 deletions
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
index 07c798b..ff221a7 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java
@@ -29,9 +29,6 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.SQLException;
import java.time.DateTimeException;
import java.time.Duration;
import java.time.Instant;
@@ -441,7 +438,7 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
}
@Override
- public int getSQLType() throws SQLException {
+ public int getSQLType() throws IOException {
return _type.getSQLType();
}
@@ -860,10 +857,8 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
// too big)
buffer.putLong(decVal.movePointRight(4).longValueExact());
} catch(ArithmeticException e) {
- throw (IOException)
- new IOException(withErrorContext(
- "Currency value '" + inValue + "' out of range"))
- .initCause(e);
+ throw new IOException(
+ withErrorContext("Currency value '" + inValue + "' out of range"), e);
}
}
@@ -936,10 +931,8 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
}
buffer.put(intValBytes);
} catch(ArithmeticException e) {
- throw (IOException)
- new IOException(withErrorContext(
- "Numeric value '" + inValue + "' out of range"))
- .initCause(e);
+ throw new IOException(
+ withErrorContext("Numeric value '" + inValue + "' out of range"), e);
}
}
@@ -1836,14 +1829,8 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
return null;
} else if(value instanceof CharSequence) {
return (CharSequence)value;
- } else if(value instanceof Clob) {
- try {
- Clob c = (Clob)value;
- // note, start pos is 1-based
- return c.getSubString(1L, (int)c.length());
- } catch(SQLException e) {
- throw (IOException)(new IOException(e.getMessage())).initCause(e);
- }
+ } else if(SqlHelper.INSTANCE.isClob(value)) {
+ return SqlHelper.INSTANCE.getClobString(value);
} else if(value instanceof Reader) {
char[] buf = new char[8 * 1024];
StringBuilder sout = new StringBuilder();
@@ -1869,18 +1856,10 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
return null;
} else if(value instanceof byte[]) {
return (byte[])value;
- } else if(value instanceof OleUtil.OleBlobImpl) {
- return ((OleUtil.OleBlobImpl)value).getBytes();
- } else if(value instanceof Blob) {
- try {
- Blob b = (Blob)value;
- // note, start pos is 1-based
- return b.getBytes(1L, (int)b.length());
- } catch(SQLException e) {
- throw (IOException)(new IOException(e.getMessage())).initCause(e);
- }
- } else if(value instanceof RawData) {
- return ((RawData)value).getBytes();
+ } else if(value instanceof InMemoryBlob) {
+ return ((InMemoryBlob)value).getBytes();
+ } else if(SqlHelper.INSTANCE.isBlob(value)) {
+ return SqlHelper.INSTANCE.getBlobBytes(value);
}
ByteArrayOutputStream bout = new ByteArrayOutputStream();
@@ -2302,7 +2281,7 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
/**
* Wrapper for raw column data which can be re-written.
*/
- private static class RawData implements Serializable
+ private static final class RawData implements Serializable, InMemoryBlob
{
private static final long serialVersionUID = 0L;
@@ -2312,7 +2291,8 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
_bytes = bytes;
}
- private byte[] getBytes() {
+ @Override
+ public byte[] getBytes() {
return _bytes;
}
@@ -2788,4 +2768,9 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl>, DateTimeConte
return LocalDateTime.ofInstant(inst, db.getZoneId());
}
}
+
+ /** internal interface for types which hold bytes in memory */
+ static interface InMemoryBlob {
+ public byte[] getBytes() throws IOException;
+ }
}