summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2010-11-03 00:00:43 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2010-11-03 00:00:43 +0000
commitf51db57df9f92d0320120d952d8fb85c08a927f9 (patch)
tree7985be7f9457645a068f61cf4f0d337743d5f2ab /src
parenta311b66878b79e8027e2bc51b41e99a94223e13c (diff)
downloadjackcess-f51db57df9f92d0320120d952d8fb85c08a927f9.tar.gz
jackcess-f51db57df9f92d0320120d952d8fb85c08a927f9.zip
some tweaks to codec support
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@494 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r--src/java/com/healthmarketscience/jackcess/CodecProvider.java4
-rw-r--r--src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java4
-rw-r--r--src/java/com/healthmarketscience/jackcess/PageChannel.java6
3 files changed, 9 insertions, 5 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/CodecProvider.java b/src/java/com/healthmarketscience/jackcess/CodecProvider.java
index 055797c..bb891cd 100644
--- a/src/java/com/healthmarketscience/jackcess/CodecProvider.java
+++ b/src/java/com/healthmarketscience/jackcess/CodecProvider.java
@@ -20,6 +20,7 @@ USA
package com.healthmarketscience.jackcess;
import java.io.IOException;
+import java.nio.charset.Charset;
/**
* Interface for a provider which can generate CodecHandlers for various types
@@ -40,9 +41,10 @@ public interface CodecProvider
* PageChannel.
*
* @param channel the PageChannel for a Database
+ * @param charset the Charset for the Database
*
* @return a new CodecHandler, may not be {@code null}
*/
- public CodecHandler createHandler(PageChannel channel)
+ public CodecHandler createHandler(PageChannel channel, Charset charset)
throws IOException;
}
diff --git a/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java b/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java
index c730939..1e88b4e 100644
--- a/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java
+++ b/src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java
@@ -21,6 +21,7 @@ package com.healthmarketscience.jackcess;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
/**
* Default implementation of CodecProvider which does not have any actual
@@ -50,7 +51,7 @@ public class DefaultCodecProvider implements CodecProvider
* This implementation returns DUMMY_HANDLER for databases with no encoding
* and UNSUPPORTED_HANDLER for databases with any encoding.
*/
- public CodecHandler createHandler(PageChannel channel)
+ public CodecHandler createHandler(PageChannel channel, Charset charset)
throws IOException
{
JetFormat format = channel.getFormat();
@@ -69,6 +70,7 @@ public class DefaultCodecProvider implements CodecProvider
case MSISAM:
// always encoded, we don't handle it
return UNSUPPORTED_HANDLER;
+
default:
throw new RuntimeException("Unknown codec type " + format.CODEC_TYPE);
}
diff --git a/src/java/com/healthmarketscience/jackcess/PageChannel.java b/src/java/com/healthmarketscience/jackcess/PageChannel.java
index 8f8346b..7d79d80 100644
--- a/src/java/com/healthmarketscience/jackcess/PageChannel.java
+++ b/src/java/com/healthmarketscience/jackcess/PageChannel.java
@@ -95,13 +95,13 @@ public class PageChannel implements Channel, Flushable {
public void initialize(Database database, CodecProvider codecProvider)
throws IOException
{
+ // initialize page en/decoding support
+ _codecHandler = codecProvider.createHandler(this, database.getCharset());
+
// note the global usage map is a special map where any page outside of
// the current range is assumed to be "on"
_globalUsageMap = UsageMap.read(database, PAGE_GLOBAL_USAGE_MAP,
ROW_GLOBAL_USAGE_MAP, true);
-
- // initialize page en/decoding support
- _codecHandler = codecProvider.createHandler(this);
}
/**