Loading java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java +15 −13 Original line number Diff line number Diff line Loading @@ -120,16 +120,10 @@ public class Ver2DictDecoder extends AbstractDictDecoder { // used only for testing. private final DictionaryBufferFactory mBufferFactory; protected DictBuffer mDictBuffer; private final BinaryDictionary mBinaryDictionary; /* package */ Ver2DictDecoder(final File file, final int factoryFlag) { mDictionaryBinaryFile = file; mDictBuffer = null; // dictType is not being used in dicttool. Passing an empty string. mBinaryDictionary = new BinaryDictionary(file.getAbsolutePath(), 0 /* offset */, file.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); if ((factoryFlag & MASK_DICTBUFFER) == USE_READONLY_BYTEBUFFER) { mBufferFactory = new DictionaryBufferFromReadOnlyByteBufferFactory(); } else if ((factoryFlag & MASK_DICTBUFFER) == USE_BYTEARRAY) { Loading @@ -144,10 +138,6 @@ public class Ver2DictDecoder extends AbstractDictDecoder { /* package */ Ver2DictDecoder(final File file, final DictionaryBufferFactory factory) { mDictionaryBinaryFile = file; mBufferFactory = factory; // dictType is not being used in dicttool. Passing an empty string. mBinaryDictionary = new BinaryDictionary(file.getAbsolutePath(), 0 /* offset */, file.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); } @Override Loading @@ -172,7 +162,13 @@ public class Ver2DictDecoder extends AbstractDictDecoder { @Override public DictionaryHeader readHeader() throws IOException, UnsupportedFormatException { final DictionaryHeader header = mBinaryDictionary.getHeader(); // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary = new BinaryDictionary( mDictionaryBinaryFile.getAbsolutePath(), 0 /* offset */, mDictionaryBinaryFile.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); final DictionaryHeader header = binaryDictionary.getHeader(); binaryDictionary.close(); if (header == null) { throw new IOException("Cannot read the dictionary header."); } Loading Loading @@ -254,6 +250,11 @@ public class Ver2DictDecoder extends AbstractDictDecoder { @Override public FusionDictionary readDictionaryBinary(final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException { // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary = new BinaryDictionary( mDictionaryBinaryFile.getAbsolutePath(), 0 /* offset */, mDictionaryBinaryFile.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); final DictionaryHeader header = readHeader(); final FusionDictionary fusionDict = new FusionDictionary(new FusionDictionary.PtNodeArray(), header.mDictionaryOptions); Loading @@ -261,11 +262,11 @@ public class Ver2DictDecoder extends AbstractDictDecoder { final ArrayList<WordProperty> wordProperties = CollectionUtils.newArrayList(); do { final BinaryDictionary.GetNextWordPropertyResult result = mBinaryDictionary.getNextWordProperty(token); binaryDictionary.getNextWordProperty(token); final WordProperty wordProperty = result.mWordProperty; if (wordProperty == null) { binaryDictionary.close(); if (deleteDictIfBroken) { mBinaryDictionary.close(); mDictionaryBinaryFile.delete(); } return null; Loading Loading @@ -294,6 +295,7 @@ public class Ver2DictDecoder extends AbstractDictDecoder { fusionDict.setBigram(word0, bigram.mWord, bigram.mProbabilityInfo); } } binaryDictionary.close(); return fusionDict; } Loading java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java +17 −9 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ public class Ver4DictDecoder extends AbstractDictDecoder { private static final String TAG = Ver4DictDecoder.class.getSimpleName(); final File mDictDirectory; final BinaryDictionary mBinaryDictionary; @UsedForTesting /* package */ Ver4DictDecoder(final File dictDirectory, final int factoryFlag) { Loading @@ -45,24 +44,32 @@ public class Ver4DictDecoder extends AbstractDictDecoder { @UsedForTesting /* package */ Ver4DictDecoder(final File dictDirectory, final DictionaryBufferFactory factory) { mDictDirectory = dictDirectory; // dictType is not being used in dicttool. Passing an empty string. mBinaryDictionary = new BinaryDictionary(dictDirectory.getAbsolutePath(), 0 /* offset */, 0 /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, true /* isUpdatable */); } @Override public DictionaryHeader readHeader() throws IOException, UnsupportedFormatException { final DictionaryHeader header = mBinaryDictionary.getHeader(); // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary= new BinaryDictionary( mDictDirectory.getAbsolutePath(), 0 /* offset */, 0 /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, true /* isUpdatable */); final DictionaryHeader header = binaryDictionary.getHeader(); binaryDictionary.close(); if (header == null) { throw new IOException("Cannot read the dictionary header."); } return mBinaryDictionary.getHeader(); return header; } @Override public FusionDictionary readDictionaryBinary(final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException { // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary = new BinaryDictionary( mDictDirectory.getAbsolutePath(), 0 /* offset */, 0 /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, true /* isUpdatable */); final DictionaryHeader header = readHeader(); final FusionDictionary fusionDict = new FusionDictionary(new FusionDictionary.PtNodeArray(), header.mDictionaryOptions); Loading @@ -70,11 +77,11 @@ public class Ver4DictDecoder extends AbstractDictDecoder { final ArrayList<WordProperty> wordProperties = CollectionUtils.newArrayList(); do { final BinaryDictionary.GetNextWordPropertyResult result = mBinaryDictionary.getNextWordProperty(token); binaryDictionary.getNextWordProperty(token); final WordProperty wordProperty = result.mWordProperty; if (wordProperty == null) { binaryDictionary.close(); if (deleteDictIfBroken) { mBinaryDictionary.close(); FileUtils.deleteRecursively(mDictDirectory); } return null; Loading Loading @@ -103,6 +110,7 @@ public class Ver4DictDecoder extends AbstractDictDecoder { fusionDict.setBigram(word0, bigram.mWord, bigram.mProbabilityInfo); } } binaryDictionary.close(); return fusionDict; } } Loading
java/src/com/android/inputmethod/latin/makedict/Ver2DictDecoder.java +15 −13 Original line number Diff line number Diff line Loading @@ -120,16 +120,10 @@ public class Ver2DictDecoder extends AbstractDictDecoder { // used only for testing. private final DictionaryBufferFactory mBufferFactory; protected DictBuffer mDictBuffer; private final BinaryDictionary mBinaryDictionary; /* package */ Ver2DictDecoder(final File file, final int factoryFlag) { mDictionaryBinaryFile = file; mDictBuffer = null; // dictType is not being used in dicttool. Passing an empty string. mBinaryDictionary = new BinaryDictionary(file.getAbsolutePath(), 0 /* offset */, file.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); if ((factoryFlag & MASK_DICTBUFFER) == USE_READONLY_BYTEBUFFER) { mBufferFactory = new DictionaryBufferFromReadOnlyByteBufferFactory(); } else if ((factoryFlag & MASK_DICTBUFFER) == USE_BYTEARRAY) { Loading @@ -144,10 +138,6 @@ public class Ver2DictDecoder extends AbstractDictDecoder { /* package */ Ver2DictDecoder(final File file, final DictionaryBufferFactory factory) { mDictionaryBinaryFile = file; mBufferFactory = factory; // dictType is not being used in dicttool. Passing an empty string. mBinaryDictionary = new BinaryDictionary(file.getAbsolutePath(), 0 /* offset */, file.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); } @Override Loading @@ -172,7 +162,13 @@ public class Ver2DictDecoder extends AbstractDictDecoder { @Override public DictionaryHeader readHeader() throws IOException, UnsupportedFormatException { final DictionaryHeader header = mBinaryDictionary.getHeader(); // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary = new BinaryDictionary( mDictionaryBinaryFile.getAbsolutePath(), 0 /* offset */, mDictionaryBinaryFile.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); final DictionaryHeader header = binaryDictionary.getHeader(); binaryDictionary.close(); if (header == null) { throw new IOException("Cannot read the dictionary header."); } Loading Loading @@ -254,6 +250,11 @@ public class Ver2DictDecoder extends AbstractDictDecoder { @Override public FusionDictionary readDictionaryBinary(final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException { // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary = new BinaryDictionary( mDictionaryBinaryFile.getAbsolutePath(), 0 /* offset */, mDictionaryBinaryFile.length() /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, false /* isUpdatable */); final DictionaryHeader header = readHeader(); final FusionDictionary fusionDict = new FusionDictionary(new FusionDictionary.PtNodeArray(), header.mDictionaryOptions); Loading @@ -261,11 +262,11 @@ public class Ver2DictDecoder extends AbstractDictDecoder { final ArrayList<WordProperty> wordProperties = CollectionUtils.newArrayList(); do { final BinaryDictionary.GetNextWordPropertyResult result = mBinaryDictionary.getNextWordProperty(token); binaryDictionary.getNextWordProperty(token); final WordProperty wordProperty = result.mWordProperty; if (wordProperty == null) { binaryDictionary.close(); if (deleteDictIfBroken) { mBinaryDictionary.close(); mDictionaryBinaryFile.delete(); } return null; Loading Loading @@ -294,6 +295,7 @@ public class Ver2DictDecoder extends AbstractDictDecoder { fusionDict.setBigram(word0, bigram.mWord, bigram.mProbabilityInfo); } } binaryDictionary.close(); return fusionDict; } Loading
java/src/com/android/inputmethod/latin/makedict/Ver4DictDecoder.java +17 −9 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ public class Ver4DictDecoder extends AbstractDictDecoder { private static final String TAG = Ver4DictDecoder.class.getSimpleName(); final File mDictDirectory; final BinaryDictionary mBinaryDictionary; @UsedForTesting /* package */ Ver4DictDecoder(final File dictDirectory, final int factoryFlag) { Loading @@ -45,24 +44,32 @@ public class Ver4DictDecoder extends AbstractDictDecoder { @UsedForTesting /* package */ Ver4DictDecoder(final File dictDirectory, final DictionaryBufferFactory factory) { mDictDirectory = dictDirectory; // dictType is not being used in dicttool. Passing an empty string. mBinaryDictionary = new BinaryDictionary(dictDirectory.getAbsolutePath(), 0 /* offset */, 0 /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, true /* isUpdatable */); } @Override public DictionaryHeader readHeader() throws IOException, UnsupportedFormatException { final DictionaryHeader header = mBinaryDictionary.getHeader(); // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary= new BinaryDictionary( mDictDirectory.getAbsolutePath(), 0 /* offset */, 0 /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, true /* isUpdatable */); final DictionaryHeader header = binaryDictionary.getHeader(); binaryDictionary.close(); if (header == null) { throw new IOException("Cannot read the dictionary header."); } return mBinaryDictionary.getHeader(); return header; } @Override public FusionDictionary readDictionaryBinary(final boolean deleteDictIfBroken) throws FileNotFoundException, IOException, UnsupportedFormatException { // dictType is not being used in dicttool. Passing an empty string. final BinaryDictionary binaryDictionary = new BinaryDictionary( mDictDirectory.getAbsolutePath(), 0 /* offset */, 0 /* length */, true /* useFullEditDistance */, null /* locale */, "" /* dictType */, true /* isUpdatable */); final DictionaryHeader header = readHeader(); final FusionDictionary fusionDict = new FusionDictionary(new FusionDictionary.PtNodeArray(), header.mDictionaryOptions); Loading @@ -70,11 +77,11 @@ public class Ver4DictDecoder extends AbstractDictDecoder { final ArrayList<WordProperty> wordProperties = CollectionUtils.newArrayList(); do { final BinaryDictionary.GetNextWordPropertyResult result = mBinaryDictionary.getNextWordProperty(token); binaryDictionary.getNextWordProperty(token); final WordProperty wordProperty = result.mWordProperty; if (wordProperty == null) { binaryDictionary.close(); if (deleteDictIfBroken) { mBinaryDictionary.close(); FileUtils.deleteRecursively(mDictDirectory); } return null; Loading Loading @@ -103,6 +110,7 @@ public class Ver4DictDecoder extends AbstractDictDecoder { fusionDict.setBigram(word0, bigram.mWord, bigram.mProbabilityInfo); } } binaryDictionary.close(); return fusionDict; } }