diff options
author | 2013-12-05 18:02:20 +0900 | |
---|---|---|
committer | 2013-12-06 14:53:03 +0900 | |
commit | a72e8f1ede3dc11fb60bd1346e6c7cb07c5d126e (patch) | |
tree | 8e5cbf3259e4ab4097e803f8c787d5f2516e004f /java/src | |
parent | cb27d955f334754e6cad0a5c3f8e13e913803f4a (diff) | |
download | latinime-a72e8f1ede3dc11fb60bd1346e6c7cb07c5d126e.tar.gz latinime-a72e8f1ede3dc11fb60bd1346e6c7cb07c5d126e.tar.xz latinime-a72e8f1ede3dc11fb60bd1346e6c7cb07c5d126e.zip |
[RF3] Cleanups
Make the version number a single number on native and java side.
Also, remove the hasValidContents method. It's useless since the
native code already checks this when creating the dictionary (I
wish I had known that when I added it).
Bug: 11281748
Change-Id: I572d37429972b2f280e4bdb748b709e5d0d7737e
Diffstat (limited to 'java/src')
6 files changed, 9 insertions, 25 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index aa530ffb9..a41cc6a82 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -121,7 +121,6 @@ public final class BinaryDictionary extends Dictionary { String[] attributeKeyStringArray, String[] attributeValueStringArray); private static native long openNative(String sourceDir, long dictOffset, long dictSize, boolean isUpdatable); - private static native boolean hasValidContentsNative(long dict); private static native void flushNative(long dict, String filePath); private static native boolean needsToRunGCNative(long dict, boolean mindsBlockByGC); private static native void flushWithGCNative(long dict, String filePath); @@ -243,10 +242,6 @@ public final class BinaryDictionary extends Dictionary { return mNativeDict != 0; } - public boolean hasValidContents() { - return hasValidContentsNative(mNativeDict); - } - public int getFormatVersion() { return getFormatVersionNative(mNativeDict); } diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java index bcb38da38..e09c309ea 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java @@ -63,7 +63,7 @@ public final class DictionaryFactory { final ReadOnlyBinaryDictionary readOnlyBinaryDictionary = new ReadOnlyBinaryDictionary(f.mFilename, f.mOffset, f.mLength, useFullEditDistance, locale, Dictionary.TYPE_MAIN); - if (readOnlyBinaryDictionary.hasValidContents()) { + if (readOnlyBinaryDictionary.isValidDictionary()) { dictList.add(readOnlyBinaryDictionary); } else { readOnlyBinaryDictionary.close(); diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index 98a18f6d3..41661573d 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -63,7 +63,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { */ protected static final int MAX_WORD_LENGTH = Constants.DICTIONARY_MAX_WORD_LENGTH; - private static final int DICTIONARY_FORMAT_VERSION = 4; + private static final int DICTIONARY_FORMAT_VERSION = FormatSpec.VERSION4; /** * A static map of update controllers, each of which records the time of accesses to a single @@ -139,8 +139,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { return formatVersion == 2; } - public boolean hasValidContents() { - return mBinaryDictionary.hasValidContents(); + public boolean isValidDictionary() { + return mBinaryDictionary.isValidDictionary(); } protected String getFileNameExtentionToOpenDict() { @@ -563,8 +563,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { loadDictionaryAsync(); mDictionaryWriter.write(mFilename, getHeaderAttributeMap()); } else { - if (mBinaryDictionary == null || !mBinaryDictionary.isValidDictionary() - || !hasValidContents() + if (mBinaryDictionary == null || !isValidDictionary() // TODO: remove the check below || !matchesExpectedBinaryDictFormatVersionForThisType( mBinaryDictionary.getFormatVersion())) { @@ -665,8 +664,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { // load the shared dictionary. loadBinaryDictionary(); } - if (mBinaryDictionary != null && !(mBinaryDictionary.isValidDictionary() - && hasValidContents() + if (mBinaryDictionary != null && !(isValidDictionary() // TODO: remove the check below && matchesExpectedBinaryDictFormatVersionForThisType( mBinaryDictionary.getFormatVersion()))) { diff --git a/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java index c8e4014bb..68505ce38 100644 --- a/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ReadOnlyBinaryDictionary.java @@ -44,15 +44,6 @@ public final class ReadOnlyBinaryDictionary extends Dictionary { locale, dictType, false /* isUpdatable */); } - public boolean hasValidContents() { - mLock.readLock().lock(); - try { - return mBinaryDictionary.hasValidContents(); - } finally { - mLock.readLock().unlock(); - } - } - public boolean isValidDictionary() { return mBinaryDictionary.isValidDictionary(); } diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java index 93ccc62b4..b81c8d8e5 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java @@ -204,8 +204,8 @@ public final class FormatSpec { static final int NOT_A_VERSION_NUMBER = -1; static final int FIRST_VERSION_WITH_DYNAMIC_UPDATE = 3; static final int FIRST_VERSION_WITH_TERMINAL_ID = 4; - static final int VERSION3 = 3; - static final int VERSION4 = 4; + public static final int VERSION3 = 3; + public static final int VERSION4 = 4; // These options need to be the same numeric values as the one in the native reading code. static final int GERMAN_UMLAUT_PROCESSING_FLAG = 0x1; diff --git a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java index 8833c35aa..2cbec7cec 100644 --- a/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java +++ b/java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java @@ -161,7 +161,7 @@ public class Ver4DictDecoder extends AbstractDictDecoder { } final FileHeader header = super.readHeader(mDictBuffer); final int version = header.mFormatOptions.mVersion; - if (version != 4) { + if (version != FormatSpec.VERSION4) { throw new UnsupportedFormatException("File header has a wrong version : " + version); } return header; |