package com.healthmarketscience.jackcess;
import java.io.IOException;
+import java.nio.charset.Charset;
/**
* Interface for a provider which can generate CodecHandlers for various types
* 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;
}
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
/**
* Default implementation of CodecProvider which does not have any actual
* 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();
case MSISAM:
// always encoded, we don't handle it
return UNSUPPORTED_HANDLER;
+
default:
throw new RuntimeException("Unknown codec type " + format.CODEC_TYPE);
}
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);
}
/**