1 16 package web.struts; 17 18 import java.lang.reflect.*; 19 import java.sql.ResultSet ; 20 21 25 class _ResultSet implements InvocationHandler { 26 27 private final static Class [] infs = new Class []{ResultSet .class}; 28 29 public _ResultSet(ResultSet rs, boolean decode) { 30 this.rs = rs; 31 this.decode = decode; 32 } 33 34 38 public ResultSet getResultSet() { 39 return (ResultSet )Proxy.newProxyInstance( 40 rs.getClass().getClassLoader(), infs, this); 41 } 42 43 public Object invoke(Object proxy, Method m, Object args[]) throws Throwable 44 { 45 String method = m.getName(); 46 if (decode && GETSTRING.equals(method)) 47 try { 48 String result = (String ) m.invoke(rs, args); 49 if (result != null) 50 return new String (result.getBytes("8859_1")); 51 else 52 return null; 53 } catch (InvocationTargetException e) { 54 throw e.getTargetException(); 55 } 56 try { 57 return m.invoke(rs, args); 58 } catch (InvocationTargetException e) { 59 throw e.getTargetException(); 60 } 61 } 62 63 private ResultSet rs; 64 65 private boolean decode; 66 67 private static final String GETSTRING = "getString"; 68 } | Popular Tags |