diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java b/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java index 644818ba6..4d253b0cb 100644 --- a/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java +++ b/java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java @@ -19,13 +19,24 @@ package com.android.inputmethod.latin.makedict; import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * Class representing dictionary header. */ public final class DictionaryHeader { public final int mBodyOffset; + @Nonnull public final DictionaryOptions mDictionaryOptions; + @Nonnull public final FormatOptions mFormatOptions; + @Nonnull + public final String mLocaleString; + @Nonnull + public final String mVersionString; + @Nonnull + public final String mIdString; // Note that these are corresponding definitions in native code in latinime::HeaderPolicy // and latinime::HeaderReadWriteUtils. @@ -46,39 +57,32 @@ public final class DictionaryHeader { public static final String ATTRIBUTE_VALUE_TRUE = "1"; public static final String CODE_POINT_TABLE_KEY = "codePointTable"; - public DictionaryHeader(final int headerSize, final DictionaryOptions dictionaryOptions, - final FormatOptions formatOptions) throws UnsupportedFormatException { + public DictionaryHeader(final int headerSize, + @Nonnull final DictionaryOptions dictionaryOptions, + @Nonnull final FormatOptions formatOptions) throws UnsupportedFormatException { mDictionaryOptions = dictionaryOptions; mFormatOptions = formatOptions; mBodyOffset = formatOptions.mVersion < FormatSpec.VERSION4 ? headerSize : 0; - if (null == getLocaleString()) { + final String localeString = dictionaryOptions.mAttributes.get(DICTIONARY_LOCALE_KEY); + if (null == localeString) { throw new UnsupportedFormatException("Cannot create a FileHeader without a locale"); } - if (null == getVersion()) { + final String versionString = dictionaryOptions.mAttributes.get(DICTIONARY_VERSION_KEY); + if (null == versionString) { throw new UnsupportedFormatException( "Cannot create a FileHeader without a version"); } - if (null == getId()) { + final String idString = dictionaryOptions.mAttributes.get(DICTIONARY_ID_KEY); + if (null == idString) { throw new UnsupportedFormatException("Cannot create a FileHeader without an ID"); } - } - - // Helper method to get the locale as a String - public String getLocaleString() { - return mDictionaryOptions.mAttributes.get(DICTIONARY_LOCALE_KEY); - } - - // Helper method to get the version String - public String getVersion() { - return mDictionaryOptions.mAttributes.get(DICTIONARY_VERSION_KEY); - } - - // Helper method to get the dictionary ID as a String - public String getId() { - return mDictionaryOptions.mAttributes.get(DICTIONARY_ID_KEY); + mLocaleString = localeString; + mVersionString = versionString; + mIdString = idString; } // Helper method to get the description + @Nullable public String getDescription() { // TODO: Right now each dictionary file comes with a description in its own language. // It will display as is no matter the device's locale. It should be internationalized. |