diff options
author | 2014-11-17 18:07:35 +0900 | |
---|---|---|
committer | 2014-11-21 12:02:06 +0900 | |
commit | ebe5b42f71bd63973edffbda691b498611326c6f (patch) | |
tree | 3678307310e30775937e01d6cb2add65c1f7d52f /java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java | |
parent | a94733cbca5bc3544fa73fa1649bbb1dadf31356 (diff) | |
download | latinime-ebe5b42f71bd63973edffbda691b498611326c6f.tar.gz latinime-ebe5b42f71bd63973edffbda691b498611326c6f.tar.xz latinime-ebe5b42f71bd63973edffbda691b498611326c6f.zip |
Make LocaleUtils.constructLocaleFromString as @Nonnull
Change-Id: I82d574c67b25239510f3ecc8882efe46e40677eb
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/DictionaryHeader.java')
-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. |