1 package org.ashkelon; 2 7 8 import java.io.Serializable ; 9 import java.sql.Connection ; 10 import java.sql.SQLException ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 import org.ashkelon.db.DBUtils; 15 import org.ashkelon.util.JDocUtil; 16 import org.ashkelon.util.StringUtils; 17 18 import com.sun.javadoc.Parameter; 19 20 27 public class ParameterInfo implements Serializable 28 { 29 private String name; 30 private String description; 31 private int listedOrder; 32 private ClassType type; 33 private String typeName; 34 private int typeDimension; 35 private ExecMember containingMember; 36 37 private static String TABLENAME = "PARAMETER"; 38 39 public ParameterInfo(String typeName) 40 { 41 setTypeName(typeName); 42 setName(""); 43 setDescription(""); 44 } 45 46 public ParameterInfo(Parameter parameter, int listedOrder, String description, ExecMember containingMember) 47 { 48 setName(parameter.name()); 49 setDescription(description); 50 setListedOrder(listedOrder); 51 setTypeName(parameter.type().qualifiedTypeName()); 52 setTypeDimension(JDocUtil.getDimension(parameter.type())); 53 setContainingMember(containingMember); 54 } 55 56 public void store(Connection conn) throws SQLException 57 { 58 Map fieldInfo = new HashMap (10); 59 fieldInfo.put("NAME", StringUtils.truncate(getName(), 50)); 60 fieldInfo.put("DESCRIPTION", getDescription()); 61 fieldInfo.put("LISTEDORDER", new Integer (getListedOrder())); 62 fieldInfo.put("TYPEDIMENSION", new Integer (getTypeDimension())); 63 fieldInfo.put("TYPENAME", StringUtils.truncate(getTypeName(), 150)); 64 fieldInfo.put("EXECMEMBERID", new Integer (getContainingMember().getId(conn))); 65 66 try 67 { 68 DBUtils.insert(conn, TABLENAME, fieldInfo); 69 } 70 catch (SQLException ex) 71 { 72 fieldInfo.put("DESCRIPTION", StringUtils.truncate(getDescription(), 350)); 73 DBUtils.insert(conn, TABLENAME, fieldInfo); 74 } 75 } 76 77 public String getName(){ return name; } 79 public void setName(String name) 80 { 81 this.name = StringUtils.avoidNull(name); 82 } 83 84 public String getDescription(){ return description; } 85 public void setDescription(String description) 86 { 87 this.description = StringUtils.avoidNull(description); 88 } 89 90 public ClassType getType(){ return type; } 91 public void setType(ClassType type){ this.type = type; } 92 93 public String getTypeName() { return typeName; } 94 public void setTypeName(String typeName) 95 { 96 this.typeName = StringUtils.avoidNull(typeName); 97 } 98 99 public int getTypeDimension(){ return typeDimension; } 100 public void setTypeDimension(int typeDimension){ this.typeDimension = typeDimension; } 101 102 public int getListedOrder(){ return listedOrder; } 103 public void setListedOrder(int listedOrder){ this.listedOrder = listedOrder; } 104 105 public ExecMember getContainingMember(){ return containingMember; } 106 public void setContainingMember(ExecMember containingMember){ this.containingMember = containingMember; } 107 108 } 109 | Popular Tags |