am 32326a9d: Merge "Move DictionaryOptions from FusionDictionary to FormatSpec."

* commit '32326a9d7ad07f19dcdd2c0bfb578b2582eb2993':
  Move DictionaryOptions from FusionDictionary to FormatSpec.
main
Keisuke Kuroyanagi 2014-03-07 02:44:39 -08:00 committed by Android Git Automerger
commit 7a15267e58
8 changed files with 48 additions and 47 deletions

View File

@ -25,7 +25,7 @@ import com.android.inputmethod.keyboard.ProximityInfo;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.makedict.DictionaryHeader; import com.android.inputmethod.latin.makedict.DictionaryHeader;
import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions; import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import com.android.inputmethod.latin.makedict.WordProperty; import com.android.inputmethod.latin.makedict.WordProperty;
import com.android.inputmethod.latin.personalization.PersonalizationHelper; import com.android.inputmethod.latin.personalization.PersonalizationHelper;

View File

@ -16,8 +16,8 @@
package com.android.inputmethod.latin.makedict; package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
/** /**
* Class representing dictionary header. * Class representing dictionary header.

View File

@ -21,6 +21,8 @@ import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.makedict.DictDecoder.DictionaryBufferFactory; import com.android.inputmethod.latin.makedict.DictDecoder.DictionaryBufferFactory;
import java.io.File; import java.io.File;
import java.util.Date;
import java.util.HashMap;
/** /**
* Dictionary File Format Specification. * Dictionary File Format Specification.
@ -322,6 +324,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. * Returns new dictionary decoder.
* *

View File

@ -18,12 +18,11 @@ package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.annotations.UsedForTesting;
import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@ -280,45 +279,6 @@ public final class FusionDictionary implements Iterable<WordProperty> {
} }
} }
/**
* 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();
}
}
public final DictionaryOptions mOptions; public final DictionaryOptions mOptions;
public final PtNodeArray mRootNodeArray; public final PtNodeArray mRootNodeArray;

View File

@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.ProbabilityInfo; import com.android.inputmethod.latin.makedict.ProbabilityInfo;
import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
@ -32,7 +33,7 @@ import java.util.HashMap;
public class FusionDictionaryTests extends AndroidTestCase { public class FusionDictionaryTests extends AndroidTestCase {
public void testFindWordInTree() { public void testFindWordInTree() {
FusionDictionary dict = new FusionDictionary(new PtNodeArray(), FusionDictionary dict = new FusionDictionary(new PtNodeArray(),
new FusionDictionary.DictionaryOptions(new HashMap<String,String>())); new DictionaryOptions(new HashMap<String,String>()));
dict.add("abc", new ProbabilityInfo(10), null, false /* isNotAWord */); dict.add("abc", new ProbabilityInfo(10), null, false /* isNotAWord */);
assertNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "aaa")); assertNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "aaa"));

View File

@ -16,8 +16,8 @@
package com.android.inputmethod.latin.makedict; package com.android.inputmethod.latin.makedict;
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;

View File

@ -17,8 +17,8 @@
package com.android.inputmethod.latin.dicttool; package com.android.inputmethod.latin.dicttool;
import com.android.inputmethod.latin.makedict.FormatSpec; import com.android.inputmethod.latin.makedict.FormatSpec;
import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
import com.android.inputmethod.latin.makedict.ProbabilityInfo; import com.android.inputmethod.latin.makedict.ProbabilityInfo;
import com.android.inputmethod.latin.makedict.WeightedString; import com.android.inputmethod.latin.makedict.WeightedString;

View File

@ -17,7 +17,6 @@
package com.android.inputmethod.latin.dicttool; package com.android.inputmethod.latin.dicttool;
import com.android.inputmethod.latin.makedict.FusionDictionary; import com.android.inputmethod.latin.makedict.FusionDictionary;
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
import com.android.inputmethod.latin.makedict.ProbabilityInfo; import com.android.inputmethod.latin.makedict.ProbabilityInfo;
import com.android.inputmethod.latin.makedict.WeightedString; import com.android.inputmethod.latin.makedict.WeightedString;