mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@752 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
42ce70e744
commit
1a08b36a78
5 changed files with 189 additions and 0 deletions
82
src/org/fbreader/encoding/ZLEncodingCollection.java
Normal file
82
src/org/fbreader/encoding/ZLEncodingCollection.java
Normal file
|
@ -0,0 +1,82 @@
|
|||
package org.fbreader.encoding;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.zlibrary.core.config.ZLConfigManager;
|
||||
import org.zlibrary.core.library.ZLibrary;
|
||||
import org.zlibrary.core.options.ZLBooleanOption;
|
||||
import org.zlibrary.core.options.ZLOption;
|
||||
|
||||
public class ZLEncodingCollection {
|
||||
private static ZLEncodingCollection ourInstance;
|
||||
private static ZLBooleanOption ourUseWindows1252HackOption;
|
||||
|
||||
public static ZLEncodingCollection instance() {
|
||||
if (ourInstance == null) {
|
||||
ourInstance = new ZLEncodingCollection();
|
||||
}
|
||||
return ourInstance;
|
||||
}
|
||||
public static String encodingDescriptionPath() {
|
||||
return ZLibrary.JAR_DATA_PREFIX + "zlibrary" + File.separator + "encodings";
|
||||
}
|
||||
|
||||
public static ZLBooleanOption useWindows1252HackOption() {
|
||||
if (ourUseWindows1252HackOption == null) {
|
||||
ourUseWindows1252HackOption =
|
||||
new ZLBooleanOption(ZLOption.CONFIG_CATEGORY, "Encoding", "UseWindows1252Hack", true);
|
||||
}
|
||||
return ourUseWindows1252HackOption;
|
||||
}
|
||||
|
||||
public static boolean useWindows1252Hack() {
|
||||
return ZLConfigManager.getInstance() != null/*.isInitialised()*/ && useWindows1252HackOption().getValue();
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<ZLEncodingSet> sets() {
|
||||
init();
|
||||
return mySets;
|
||||
}
|
||||
public ZLEncodingConverterInfo info(String name) {
|
||||
init();
|
||||
String lowerCaseName = name.toLowerCase();
|
||||
if (useWindows1252Hack() && (lowerCaseName == "iso-8859-1")) {
|
||||
lowerCaseName = "windows-1252";
|
||||
}
|
||||
return (ZLEncodingConverterInfo)myInfosByName.get(lowerCaseName);
|
||||
}
|
||||
|
||||
public ZLEncodingConverterInfo info(int code) {
|
||||
String name = "" + code;
|
||||
return info(name);
|
||||
}
|
||||
|
||||
public ZLEncodingConverter defaultConverter() {
|
||||
return null;//DummyEncodingConverterProvider().createConverter();
|
||||
}
|
||||
public void registerProvider(ZLEncodingConverterProvider provider) {
|
||||
myProviders.add(provider);
|
||||
}
|
||||
|
||||
private void addInfo(ZLEncodingConverterInfo info) {
|
||||
|
||||
}
|
||||
ArrayList/*<ZLEncodingConverterProvider>*/ providers() {
|
||||
return myProviders;
|
||||
}
|
||||
|
||||
private ArrayList/*<ZLEncodingSet>*/ mySets;
|
||||
private HashMap/*<String,ZLEncodingConverterInfo>*/ myInfosByName;
|
||||
private ArrayList/*<ZLEncodingConverterProvider>*/ myProviders;
|
||||
|
||||
//private ZLEncodingCollection();
|
||||
private void init() {
|
||||
if (mySets.isEmpty()) {
|
||||
String prefix = encodingDescriptionPath() + File.separator;
|
||||
//new ZLEncodingCollectionReader(this).readDocument(prefix + "Encodings.xml");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue