aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-12-13 04:15:33 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2013-12-13 04:15:33 +0000
commit18d033405c18a8dc28f60ca22d1d0df23a679384 (patch)
tree77ae6dc696eb7f2942e6d5bfebdccb95eebf8a6e /java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
parent95050f54e92ff5465e713990315e8cf421836a64 (diff)
parentc95efbbd575239b97db20b71fb347b543b5808f8 (diff)
downloadlatinime-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 'java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java')
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java48
1 files changed, 14 insertions, 34 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java b/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
index f8fa68f45..fda97dafc 100644
--- a/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
+++ b/java/src/com/android/inputmethod/latin/makedict/AbstractDictDecoder.java
@@ -32,35 +32,36 @@ import java.util.TreeMap;
* A base class of the binary dictionary decoder.
*/
public abstract class AbstractDictDecoder implements DictDecoder {
- private static final int SUCCESS = 0;
- private static final int ERROR_CANNOT_READ = 1;
- private static final int ERROR_WRONG_FORMAT = 2;
-
- protected FileHeader readHeader(final DictBuffer headerBuffer)
+ protected FileHeader readHeader(final DictBuffer dictBuffer)
throws IOException, UnsupportedFormatException {
- if (headerBuffer == null) {
+ if (dictBuffer == null) {
openDictBuffer();
}
- final int version = HeaderReader.readVersion(headerBuffer);
+ final int version = HeaderReader.readVersion(dictBuffer);
if (version < FormatSpec.MINIMUM_SUPPORTED_VERSION
|| version > FormatSpec.MAXIMUM_SUPPORTED_VERSION) {
throw new UnsupportedFormatException("Unsupported version : " + version);
}
// TODO: Remove this field.
- final int optionsFlags = HeaderReader.readOptionFlags(headerBuffer);
- final int headerSize = HeaderReader.readHeaderSize(headerBuffer);
+ final int optionsFlags = HeaderReader.readOptionFlags(dictBuffer);
+
+ final int headerSize = HeaderReader.readHeaderSize(dictBuffer);
+
if (headerSize < 0) {
throw new UnsupportedFormatException("header size can't be negative.");
}
- final HashMap<String, String> attributes = HeaderReader.readAttributes(headerBuffer,
+ final HashMap<String, String> attributes = HeaderReader.readAttributes(dictBuffer,
headerSize);
final FileHeader header = new FileHeader(headerSize,
- new FusionDictionary.DictionaryOptions(attributes),
- new FormatOptions(version,
- 0 != (optionsFlags & FormatSpec.CONTAINS_TIMESTAMP_FLAG)));
+ new FusionDictionary.DictionaryOptions(attributes,
+ 0 != (optionsFlags & FormatSpec.GERMAN_UMLAUT_PROCESSING_FLAG),
+ 0 != (optionsFlags & FormatSpec.FRENCH_LIGATURE_PROCESSING_FLAG)),
+ new FormatOptions(version,
+ 0 != (optionsFlags & FormatSpec.SUPPORTS_DYNAMIC_UPDATE),
+ 0 != (optionsFlags & FormatSpec.CONTAINS_TIMESTAMP_FLAG)));
return header;
}
@@ -203,25 +204,4 @@ public abstract class AbstractDictDecoder implements DictDecoder {
return readLength;
}
}
-
- /**
- * Check whether the header contains the expected information. This is a no-error method,
- * that will return an error code and never throw a checked exception.
- * @return an error code, either ERROR_* or SUCCESS.
- */
- private int checkHeader() {
- try {
- readHeader();
- } catch (IOException e) {
- return ERROR_CANNOT_READ;
- } catch (UnsupportedFormatException e) {
- return ERROR_WRONG_FORMAT;
- }
- return SUCCESS;
- }
-
- @Override
- public boolean hasValidRawBinaryDictionary() {
- return checkHeader() == SUCCESS;
- }
}