From: James Ahlborn Date: Wed, 3 Nov 2010 00:00:43 +0000 (+0000) Subject: some tweaks to codec support X-Git-Tag: jackcess-1.2.2~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f51db57df9f92d0320120d952d8fb85c08a927f9;p=jackcess.git some tweaks to codec support git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@494 f203690c-595d-4dc9-a70b-905162fa7fd2 --- 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); } /**