diff options
author | 2014-03-05 17:42:36 +0900 | |
---|---|---|
committer | 2014-03-06 18:53:09 +0900 | |
commit | 3ad4af2354e7003ac288dafe3600268fe860d752 (patch) | |
tree | 17cd14195a5330c8db1f5edd4bf2295446db71af /java/src/com/android/inputmethod/latin/makedict/FormatSpec.java | |
parent | 516f86815ddec465e3d3ff59540d26913b05236f (diff) | |
download | latinime-3ad4af2354e7003ac288dafe3600268fe860d752.tar.gz latinime-3ad4af2354e7003ac288dafe3600268fe860d752.tar.xz latinime-3ad4af2354e7003ac288dafe3600268fe860d752.zip |
Move DictionaryOptions from FusionDictionary to FormatSpec.
Bug: 8187060
Bug:13035567
Change-Id: Id4f45e589521ae98c926a4c0607be10ce1a983f2
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/FormatSpec.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/FormatSpec.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java index 484bb4b23..07217e48e 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java +++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java @@ -21,6 +21,8 @@ import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.makedict.DictDecoder.DictionaryBufferFactory; import java.io.File; +import java.util.Date; +import java.util.HashMap; /** * Dictionary File Format Specification. @@ -323,6 +325,45 @@ public final class FormatSpec { } /** + * Options global to the dictionary. + */ + public static final class DictionaryOptions { + public final HashMap<String, String> mAttributes; + public DictionaryOptions(final HashMap<String, String> attributes) { + mAttributes = attributes; + } + @Override + public String toString() { // Convenience method + return toString(0, false); + } + public String toString(final int indentCount, final boolean plumbing) { + final StringBuilder indent = new StringBuilder(); + if (plumbing) { + indent.append("H:"); + } else { + for (int i = 0; i < indentCount; ++i) { + indent.append(" "); + } + } + final StringBuilder s = new StringBuilder(); + for (final String optionKey : mAttributes.keySet()) { + s.append(indent); + s.append(optionKey); + s.append(" = "); + if ("date".equals(optionKey) && !plumbing) { + // Date needs a number of milliseconds, but the dictionary contains seconds + s.append(new Date( + 1000 * Long.parseLong(mAttributes.get(optionKey))).toString()); + } else { + s.append(mAttributes.get(optionKey)); + } + s.append("\n"); + } + return s.toString(); + } + } + + /** * Returns new dictionary decoder. * * @param dictFile the dictionary file. |