]> source.dussan.org Git - jackcess.git/commitdiff
some tweaks to codec support
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 3 Nov 2010 00:00:43 +0000 (00:00 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 3 Nov 2010 00:00:43 +0000 (00:00 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@494 f203690c-595d-4dc9-a70b-905162fa7fd2

src/java/com/healthmarketscience/jackcess/CodecProvider.java
src/java/com/healthmarketscience/jackcess/DefaultCodecProvider.java
src/java/com/healthmarketscience/jackcess/PageChannel.java

index 055797c46a3d2b2a98292784f2a5ff48e5512006..bb891cdc1723373a38013d21f2004edf65739ad0 100644 (file)
@@ -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;
 }
index c7309394b8300ad934a7b89dad126208f889f608..1e88b4e51cecca3221e2ba88fe05850a42013e43 100644 (file)
@@ -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);
     }
index 8f8346b3f206c0f67b2f5108015d19b25eb19022..7d79d803bfc333b43d85a92ca211b37d558ec3ad 100644 (file)
@@ -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);
   }
   
   /**