public static EncodingReader getReadFactory(final String encoding)
throws UnsupportedEncodingException
{
String encKey = encoding == null ? "iso-8859-1" : encoding;
EncodingReader factory = _readEncodingFactories.get(encKey);
if (factory == null) {
try {
String javaEncoding = Encoding.getJavaName(encoding);
if (javaEncoding == null)
javaEncoding = "ISO8859_1";
String className = "com.caucho.vfs.i18n." + javaEncoding + "Reader";
Class cl = Class.forName(className);
factory = (EncodingReader) cl.newInstance();
factory.setJavaEncoding(javaEncoding);
} catch (Throwable e) {
}
if (factory == null) {
String javaEncoding = Encoding.getJavaName(encoding);
if (javaEncoding == null)
javaEncoding = "ISO8859_1";
factory = new JDKReader();
factory.setJavaEncoding(javaEncoding);
}
_readEncodingFactories.put(encKey, factory);
}