1 28 29 package com.caucho.amber.type; 30 31 import com.caucho.java.JavaWriter; 32 import com.caucho.util.L10N; 33 34 import java.io.IOException ; 35 import java.sql.PreparedStatement ; 36 import java.sql.ResultSet ; 37 import java.sql.SQLException ; 38 39 42 public class ObjectType extends Type { 43 private static final L10N L = new L10N(ObjectType.class); 44 45 private static final ObjectType OBJECT_TYPE = new ObjectType(); 46 47 private ObjectType() 48 { 49 } 50 51 54 public static ObjectType create() 55 { 56 return OBJECT_TYPE; 57 } 58 59 62 public String getName() 63 { 64 return "java.lang.Object"; 65 } 66 67 70 public int generateLoad(JavaWriter out, String rs, 71 String indexVar, int index) 72 throws IOException 73 { 74 out.print(rs + ".getObject(" + indexVar + " + " + index + ")"); 75 76 return index + 1; 77 } 78 79 82 public void generateSet(JavaWriter out, String pstmt, 83 String index, String value) 84 throws IOException 85 { 86 out.println(pstmt + ".setObject(" + index + "++, " + value + ");"); 87 } 88 89 92 public void setParameter(PreparedStatement pstmt, int index, Object value) 93 throws SQLException 94 { 95 pstmt.setObject(index, value); 96 } 97 98 101 public Object getObject(ResultSet rs, int index) 102 throws SQLException 103 { 104 return rs.getObject(index); 105 } 106 } 107 | Popular Tags |