diff --git a/jni/NativeFormats/util/AndroidUtil.cpp b/jni/NativeFormats/util/AndroidUtil.cpp index 1663b83a7..8d430d09d 100644 --- a/jni/NativeFormats/util/AndroidUtil.cpp +++ b/jni/NativeFormats/util/AndroidUtil.cpp @@ -41,7 +41,6 @@ JavaClass AndroidUtil::Class_FileInfo("org/geometerplus/zlibrary/core/fonts/File JavaClass AndroidUtil::Class_FileEncryptionInfo("org/geometerplus/zlibrary/core/drm/FileEncryptionInfo"); JavaClass AndroidUtil::Class_ZLFileImage("org/geometerplus/zlibrary/core/image/ZLFileImage"); JavaClass AndroidUtil::Class_ZLTextModel("org/geometerplus/zlibrary/text/model/ZLTextModel"); -JavaClass AndroidUtil::Class_CachedCharStorageException("org/geometerplus/zlibrary/text/model/CachedCharStorageException"); JavaClass AndroidUtil::Class_Encoding("org/geometerplus/zlibrary/core/encodings/Encoding"); JavaClass AndroidUtil::Class_EncodingConverter("org/geometerplus/zlibrary/core/encodings/EncodingConverter"); diff --git a/jni/NativeFormats/util/AndroidUtil.h b/jni/NativeFormats/util/AndroidUtil.h index 66222da40..f756dcfdf 100644 --- a/jni/NativeFormats/util/AndroidUtil.h +++ b/jni/NativeFormats/util/AndroidUtil.h @@ -80,7 +80,6 @@ public: static JavaClass Class_FileEncryptionInfo; static JavaClass Class_ZLFileImage; static JavaClass Class_ZLTextModel; - static JavaClass Class_CachedCharStorageException; static JavaClass Class_NativeFormatPlugin; static JavaClass Class_PluginCollection; static JavaClass Class_Encoding; diff --git a/src/org/geometerplus/fbreader/bookmodel/BookModelImpl.java b/src/org/geometerplus/fbreader/bookmodel/BookModelImpl.java index 610c435cc..00b667f52 100644 --- a/src/org/geometerplus/fbreader/bookmodel/BookModelImpl.java +++ b/src/org/geometerplus/fbreader/bookmodel/BookModelImpl.java @@ -28,7 +28,7 @@ import org.geometerplus.zlibrary.text.model.*; import org.geometerplus.fbreader.book.Book; abstract class BookModelImpl extends BookModel { - protected CharStorage myInternalHyperlinks; + protected CachedCharStorage myInternalHyperlinks; protected final HashMap myImageMap = new HashMap(); protected final HashMap myFootnotes = new HashMap(); diff --git a/src/org/geometerplus/fbreader/bookmodel/NativeBookModel.java b/src/org/geometerplus/fbreader/bookmodel/NativeBookModel.java index 0c3ca8093..287c59231 100644 --- a/src/org/geometerplus/fbreader/bookmodel/NativeBookModel.java +++ b/src/org/geometerplus/fbreader/bookmodel/NativeBookModel.java @@ -31,7 +31,7 @@ public class NativeBookModel extends BookModelImpl { } public void initInternalHyperlinks(String directoryName, String fileExtension, int blocksNumber) { - myInternalHyperlinks = new CachedCharStorageRO(directoryName, fileExtension, blocksNumber); + myInternalHyperlinks = new CachedCharStorage(directoryName, fileExtension, blocksNumber); } private TOCTree myCurrentTree = TOCTree; @@ -55,7 +55,7 @@ public class NativeBookModel extends BookModelImpl { int[] paragraphLenghts, int[] textSizes, byte[] paragraphKinds, String directoryName, String fileExtension, int blocksNumber ) { - return new ZLTextNativeModel( + return new ZLTextPlainModel( id, language, paragraphsNumber, entryIndices, entryOffsets, paragraphLenghts, textSizes, paragraphKinds, diff --git a/src/org/geometerplus/zlibrary/text/model/CachedCharStorageRO.java b/src/org/geometerplus/zlibrary/text/model/CachedCharStorage.java similarity index 92% rename from src/org/geometerplus/zlibrary/text/model/CachedCharStorageRO.java rename to src/org/geometerplus/zlibrary/text/model/CachedCharStorage.java index 2f301970c..19862ab48 100644 --- a/src/org/geometerplus/zlibrary/text/model/CachedCharStorageRO.java +++ b/src/org/geometerplus/zlibrary/text/model/CachedCharStorage.java @@ -24,20 +24,20 @@ import java.io.*; import java.util.ArrayList; import java.util.Collections; -public final class CachedCharStorageRO implements CharStorage { +public final class CachedCharStorage { protected final ArrayList> myArray = new ArrayList>(); private final String myDirectoryName; private final String myFileExtension; - public CachedCharStorageRO(String directoryName, String fileExtension, int blocksNumber) { + public CachedCharStorage(String directoryName, String fileExtension, int blocksNumber) { myDirectoryName = directoryName + '/'; myFileExtension = '.' + fileExtension; myArray.addAll(Collections.nCopies(blocksNumber, new WeakReference(null))); } - protected String fileName(int index) { + private String fileName(int index) { return myDirectoryName + index + myFileExtension; } diff --git a/src/org/geometerplus/zlibrary/text/model/CharStorage.java b/src/org/geometerplus/zlibrary/text/model/CharStorage.java deleted file mode 100644 index 3c694d895..000000000 --- a/src/org/geometerplus/zlibrary/text/model/CharStorage.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2007-2015 FBReader.ORG Limited - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -package org.geometerplus.zlibrary.text.model; - -public interface CharStorage { - int size(); - char[] block(int index); -} diff --git a/src/org/geometerplus/zlibrary/text/model/ZLTextNativeModel.java b/src/org/geometerplus/zlibrary/text/model/ZLTextNativeModel.java deleted file mode 100644 index f54aa6658..000000000 --- a/src/org/geometerplus/zlibrary/text/model/ZLTextNativeModel.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2011-2015 FBReader.ORG Limited - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -package org.geometerplus.zlibrary.text.model; - -import java.util.Map; - -import org.geometerplus.zlibrary.core.fonts.FontManager; -import org.geometerplus.zlibrary.core.image.ZLImage; - -public class ZLTextNativeModel extends ZLTextPlainModel { - public ZLTextNativeModel( - String id, String language, int paragraphsNumber, - int[] entryIndices, int[] entryOffsets, - int[] paragraphLengths, int[] textSizes, - byte[] paragraphKinds, - String directoryName, String fileExtension, int blocksNumber, - Map imageMap, - FontManager fontManager - ) { - super( - id, language, - entryIndices, entryOffsets, paragraphLengths, textSizes, paragraphKinds, - new CachedCharStorageRO(directoryName, fileExtension, blocksNumber), - imageMap, - fontManager - ); - myParagraphsNumber = paragraphsNumber; - } -} diff --git a/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java b/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java index ce83300df..fc397bd45 100644 --- a/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java +++ b/src/org/geometerplus/zlibrary/text/model/ZLTextPlainModel.java @@ -25,20 +25,20 @@ import org.geometerplus.zlibrary.core.fonts.FontManager; import org.geometerplus.zlibrary.core.image.ZLImage; import org.geometerplus.zlibrary.core.util.*; -public class ZLTextPlainModel implements ZLTextModel, ZLTextStyleEntry.Feature { +public final class ZLTextPlainModel implements ZLTextModel, ZLTextStyleEntry.Feature { private final String myId; private final String myLanguage; - protected int[] myStartEntryIndices; - protected int[] myStartEntryOffsets; - protected int[] myParagraphLengths; - protected int[] myTextSizes; - protected byte[] myParagraphKinds; + private int[] myStartEntryIndices; + private int[] myStartEntryOffsets; + private int[] myParagraphLengths; + private int[] myTextSizes; + private byte[] myParagraphKinds; - protected int myParagraphsNumber; + private int myParagraphsNumber; - protected final CharStorage myStorage; - protected final Map myImageMap; + private final CachedCharStorage myStorage; + private final Map myImageMap; private ArrayList myMarks; @@ -298,26 +298,30 @@ public class ZLTextPlainModel implements ZLTextModel, ZLTextStyleEntry.Feature { } } - protected ZLTextPlainModel( + public ZLTextPlainModel( String id, String language, + int paragraphsNumber, int[] entryIndices, int[] entryOffsets, - int[] paragraphLenghts, + int[] paragraphLengths, int[] textSizes, byte[] paragraphKinds, - CharStorage storage, + String directoryName, + String fileExtension, + int blocksNumber, Map imageMap, FontManager fontManager ) { myId = id; myLanguage = language; + myParagraphsNumber = paragraphsNumber; myStartEntryIndices = entryIndices; myStartEntryOffsets = entryOffsets; - myParagraphLengths = paragraphLenghts; + myParagraphLengths = paragraphLengths; myTextSizes = textSizes; myParagraphKinds = paragraphKinds; - myStorage = storage; + myStorage = new CachedCharStorage(directoryName, fileExtension, blocksNumber); myImageMap = imageMap; myFontManager = fontManager; }