Mercurial > 510Connectbot
comparison src/org/tn5250j/encoding/ToolboxCodePageFactory.java @ 25:5949eb469a79 tn5250
adding tn5250 files, native android logging
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 03 Jun 2014 12:10:21 -0700 |
parents | cbdff98c45ea |
children | b29b39f386a4 |
comparison
equal
deleted
inserted
replaced
24:d1c549560aff | 25:5949eb469a79 |
---|---|
27 package org.tn5250j.encoding; | 27 package org.tn5250j.encoding; |
28 | 28 |
29 import java.lang.reflect.Constructor; | 29 import java.lang.reflect.Constructor; |
30 import java.lang.reflect.Method; | 30 import java.lang.reflect.Method; |
31 | 31 |
32 import org.tn5250j.tools.logging.TN5250jLogFactory; | 32 import android.util.Log; |
33 import org.tn5250j.tools.logging.TN5250jLogger; | 33 |
34 | 34 |
35 /* package */ class ToolboxCodePageFactory { | 35 /* package */ class ToolboxCodePageFactory { |
36 | 36 |
37 private final static String[] CODEPAGES = { "Big5", "Cp037", "Cp273", "Cp277", "Cp278", | 37 private final static String[] CODEPAGES = { "Big5", "Cp037", "Cp273", "Cp277", "Cp278", |
38 "Cp280", "Cp284", "Cp285", "Cp297", "Cp420", "Cp424", "Cp437", | 38 "Cp280", "Cp284", "Cp285", "Cp297", "Cp420", "Cp424", "Cp437", |
53 private static final String TOBYTES_NAME = "stringToByteArray"; | 53 private static final String TOBYTES_NAME = "stringToByteArray"; |
54 private static final String TOSTRING_NAME = "byteArrayToString"; | 54 private static final String TOSTRING_NAME = "byteArrayToString"; |
55 | 55 |
56 private static ToolboxCodePageFactory singleton; | 56 private static ToolboxCodePageFactory singleton; |
57 | 57 |
58 private final TN5250jLogger log = TN5250jLogFactory.getLogger(this.getClass()); | 58 |
59 | 59 |
60 private ToolboxCodePageFactory() { | 60 private ToolboxCodePageFactory() { |
61 /* private for singleton */ | 61 /* private for singleton */ |
62 } | 62 } |
63 | 63 |
75 try { | 75 try { |
76 final ClassLoader loader = getClassLoader(); | 76 final ClassLoader loader = getClassLoader(); |
77 Class.forName(CONVERTER_NAME, false, loader); | 77 Class.forName(CONVERTER_NAME, false, loader); |
78 return CODEPAGES; | 78 return CODEPAGES; |
79 } catch (Exception e) { | 79 } catch (Exception e) { |
80 log.info("Couldn't locate JT400 Toolbox in classpath. Charset converters can't be used."); | 80 Log.i(TAG,"Couldn't locate JT400 Toolbox in classpath. Charset converters can't be used."); |
81 return new String[0]; | 81 return new String[0]; |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 /** | 85 /** |
94 Method toBytes_method = conv_class.getMethod(TOBYTES_NAME, new Class[] { String.class }); | 94 Method toBytes_method = conv_class.getMethod(TOBYTES_NAME, new Class[] { String.class }); |
95 Method toString_method = conv_class.getMethod(TOSTRING_NAME, new Class[] { byte[].class }); | 95 Method toString_method = conv_class.getMethod(TOSTRING_NAME, new Class[] { byte[].class }); |
96 Object convobj = conv_constructor.newInstance(new Object[] { encoding }); | 96 Object convobj = conv_constructor.newInstance(new Object[] { encoding }); |
97 return new ToolboxConverterProxy(convobj, toBytes_method, toString_method); | 97 return new ToolboxConverterProxy(convobj, toBytes_method, toString_method); |
98 } catch (Exception e) { | 98 } catch (Exception e) { |
99 log.warn("Can't load charset converter from JT400 Toolbox for code page " + encoding, e); | 99 Log.w(TAG,"Can't load charset converter from JT400 Toolbox for code page " + encoding, e); |
100 return null; | 100 return null; |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 private static final ClassLoader getClassLoader() { | 104 private static final ClassLoader getClassLoader() { |