diff options
author | 2013-12-13 04:15:33 +0000 | |
---|---|---|
committer | 2013-12-13 04:15:33 +0000 | |
commit | 18d033405c18a8dc28f60ca22d1d0df23a679384 (patch) | |
tree | 77ae6dc696eb7f2942e6d5bfebdccb95eebf8a6e /tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java | |
parent | 95050f54e92ff5465e713990315e8cf421836a64 (diff) | |
parent | c95efbbd575239b97db20b71fb347b543b5808f8 (diff) | |
download | latinime-18d033405c18a8dc28f60ca22d1d0df23a679384.tar.gz latinime-18d033405c18a8dc28f60ca22d1d0df23a679384.tar.xz latinime-18d033405c18a8dc28f60ca22d1d0df23a679384.zip |
Merge branch 'master' of https://googleplex-android.googlesource.com/_direct/platform/packages/inputmethods/LatinIME
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java deleted file mode 100644 index 34226dcd3..000000000 --- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.makedict; - -import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader; -import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; -import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; - -import java.io.File; -import java.util.HashMap; - -public class BinaryDictUtils { - public static final int USE_BYTE_ARRAY = 1; - public static final int USE_BYTE_BUFFER = 2; - - public static final String TEST_DICT_FILE_EXTENSION = ".testDict"; - - public static final FormatSpec.FormatOptions VERSION2_OPTIONS = - new FormatSpec.FormatOptions(FormatSpec.VERSION2); - public static final FormatSpec.FormatOptions VERSION3_OPTIONS = - new FormatSpec.FormatOptions(FormatSpec.VERSION3); - public static final FormatSpec.FormatOptions VERSION4_OPTIONS_WITHOUT_TIMESTAMP = - new FormatSpec.FormatOptions(FormatSpec.VERSION4, false /* hasTimestamp */); - public static final FormatSpec.FormatOptions VERSION4_OPTIONS_WITH_TIMESTAMP = - new FormatSpec.FormatOptions(FormatSpec.VERSION4, true /* hasTimestamp */); - - public static DictionaryOptions makeDictionaryOptions(final String id, final String version) { - final DictionaryOptions options = new DictionaryOptions(new HashMap<String, String>()); - options.mAttributes.put(FileHeader.DICTIONARY_LOCALE_ATTRIBUTE, "en_US"); - options.mAttributes.put(FileHeader.DICTIONARY_ID_ATTRIBUTE, id); - options.mAttributes.put(FileHeader.DICTIONARY_VERSION_ATTRIBUTE, version); - return options; - } - - public static File getDictFile(final String name, final String version, - final FormatOptions formatOptions, final File directory) { - if (formatOptions.mVersion == FormatSpec.VERSION2 - || formatOptions.mVersion == FormatSpec.VERSION3) { - return new File(directory, name + "." + version + TEST_DICT_FILE_EXTENSION); - } else if (formatOptions.mVersion == FormatSpec.VERSION4) { - return new File(directory, name + "." + version); - } else { - throw new RuntimeException("the format option has a wrong version : " - + formatOptions.mVersion); - } - } - - public static DictEncoder getDictEncoder(final File file, final FormatOptions formatOptions, - final File cacheDir) { - if (formatOptions.mVersion == FormatSpec.VERSION4) { - return new Ver4DictEncoder(cacheDir); - } else if (formatOptions.mVersion == FormatSpec.VERSION3 - || formatOptions.mVersion == FormatSpec.VERSION2) { - return new Ver3DictEncoder(file); - } else { - throw new RuntimeException("The format option has a wrong version : " - + formatOptions.mVersion); - } - } - - public static DictUpdater getDictUpdater(final File file, final FormatOptions formatOptions) - throws UnsupportedFormatException { - if (formatOptions.mVersion == FormatSpec.VERSION4) { - return new Ver4DictUpdater(file, DictDecoder.USE_WRITABLE_BYTEBUFFER); - } else if (formatOptions.mVersion == FormatSpec.VERSION3) { - return new Ver3DictUpdater(file, DictDecoder.USE_WRITABLE_BYTEBUFFER); - } else { - throw new UnsupportedFormatException("The format option has a wrong version : " - + formatOptions.mVersion); - } - } -} |