Merge "Add a parameter isUpdatable to the constructor of BinaryDictionary."

This commit is contained in:
Keisuke Kuroynagi 2013-06-25 08:44:48 +00:00 committed by Android (Google) Code Review
commit 38b542629a
3 changed files with 12 additions and 8 deletions

View File

@ -78,13 +78,15 @@ public final class BinaryDictionary extends Dictionary {
* @param length the length of the binary data.
* @param useFullEditDistance whether to use the full edit distance in suggestions
* @param dictType the dictionary type, as a human-readable string
* @param isUpdatable whether to open the dictionary file in writable mode.
*/
public BinaryDictionary(final String filename, final long offset, final long length,
final boolean useFullEditDistance, final Locale locale, final String dictType) {
final boolean useFullEditDistance, final Locale locale, final String dictType,
final boolean isUpdatable) {
super(dictType);
mLocale = locale;
mNativeSuggestOptions.setUseFullEditDistance(useFullEditDistance);
loadDictionary(filename, offset, length);
loadDictionary(filename, offset, length, isUpdatable);
}
static {
@ -106,8 +108,8 @@ public final class BinaryDictionary extends Dictionary {
// TODO: Move native dict into session
private final void loadDictionary(final String path, final long startOffset,
final long length) {
mNativeDict = openNative(path, startOffset, length, false /* isUpdatable */);
final long length, final boolean isUpdatable) {
mNativeDict = openNative(path, startOffset, length, isUpdatable);
}
@Override

View File

@ -60,7 +60,8 @@ public final class DictionaryFactory {
if (null != assetFileList) {
for (final AssetFileAddress f : assetFileList) {
final BinaryDictionary binaryDictionary = new BinaryDictionary(f.mFilename,
f.mOffset, f.mLength, useFullEditDistance, locale, Dictionary.TYPE_MAIN);
f.mOffset, f.mLength, useFullEditDistance, locale, Dictionary.TYPE_MAIN,
false /* isUpdatable */);
if (binaryDictionary.isValidDictionary()) {
dictList.add(binaryDictionary);
}
@ -113,7 +114,8 @@ public final class DictionaryFactory {
return null;
}
return new BinaryDictionary(sourceDir, afd.getStartOffset(), afd.getLength(),
false /* useFullEditDistance */, locale, Dictionary.TYPE_MAIN);
false /* useFullEditDistance */, locale, Dictionary.TYPE_MAIN,
false /* isUpdatable */);
} catch (android.content.res.Resources.NotFoundException e) {
Log.e(TAG, "Could not find the resource");
return null;
@ -142,7 +144,7 @@ public final class DictionaryFactory {
for (final AssetFileAddress address : dictionaryList) {
final BinaryDictionary binaryDictionary = new BinaryDictionary(address.mFilename,
address.mOffset, address.mLength, useFullEditDistance, locale,
Dictionary.TYPE_MAIN);
Dictionary.TYPE_MAIN, false /* isUpdatable */);
dictionaryCollection.addDictionary(binaryDictionary);
}
return dictionaryCollection;

View File

@ -286,7 +286,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
// Build the new binary dictionary
final BinaryDictionary newBinaryDictionary = new BinaryDictionary(filename, 0, length,
true /* useFullEditDistance */, null, mDictType);
true /* useFullEditDistance */, null, mDictType, false /* isUpdatable */);
if (mBinaryDictionary != null) {
// Ensure all threads accessing the current dictionary have finished before swapping in