1 package org.ashkelon; 2 7 8 import java.sql.Connection ; 9 import java.sql.SQLException ; 10 import java.util.HashMap ; 11 import java.util.Map ; 12 13 import org.ashkelon.db.DBUtils; 14 import org.ashkelon.util.JDocUtil; 15 import org.ashkelon.util.StringUtils; 16 17 import com.sun.javadoc.MethodDoc; 18 19 26 public class MethodMember extends ExecMember 27 { 28 private boolean isAbstract; 29 private ClassType returnType; 30 private String returnTypeName; 31 private int returnTypeDimension; 32 private String returnDescription; 33 34 private static String TABLENAME = "METHOD"; 35 36 public MethodMember(String qualifiedName, String signature) 37 { 38 super(qualifiedName, signature, Member.METHOD_MEMBER); 39 setReturnTypeName(""); 40 setReturnDescription(""); 41 } 42 43 public MethodMember(Member member, String signature) 44 { 45 super(member, signature); 46 } 47 48 public MethodMember(MethodDoc methoddoc, ClassType containingClass) 49 { 50 super(methoddoc, containingClass); 51 setAbstract(methoddoc.isAbstract()); 52 setReturnTypeName(methoddoc.returnType().qualifiedTypeName()); 53 setReturnTypeDimension(JDocUtil.getDimension(methoddoc.returnType())); 54 setReturnDescription(JDocUtil.resolveDescription(this.getDoc(), methoddoc.tags("@return"))); 55 } 56 57 public void store(Connection conn) throws SQLException 58 { 59 super.store(conn); 60 Map fieldInfo = new HashMap (5); 61 fieldInfo.put("ID", new Integer (getId(conn))); 62 63 int boolvalue = isAbstract() ? 1 : 0; 65 fieldInfo.put("ISABSTRACT", new Integer (boolvalue)); 66 67 fieldInfo.put("RETURNTYPENAME", StringUtils.truncate(getReturnTypeName(), 150)); 68 fieldInfo.put("RETURNTYPEDIMENSION", new Integer (getReturnTypeDimension())); 69 fieldInfo.put("RETURNDESCRIPTION", getReturnDescription()); 70 71 try 72 { 73 DBUtils.insert(conn, TABLENAME, fieldInfo); 74 } 75 catch (SQLException ex) 76 { 77 fieldInfo.put("RETURNDESCRIPTION", StringUtils.truncate(getReturnDescription(), 350)); 78 DBUtils.insert(conn, TABLENAME, fieldInfo); 79 } 80 } 81 82 public static void delete(Connection conn, int memberid, int docid) throws SQLException 83 { 84 Map constraint = new HashMap (); 85 constraint.put("ID", new Integer (memberid)); 86 DBUtils.delete(conn, TABLENAME, constraint); 87 88 ExecMember.delete(conn, memberid, docid); 89 } 90 91 public boolean isAbstract(){ return isAbstract; } 93 public void setAbstract(boolean isAbstract){ this.isAbstract = isAbstract; } 94 95 public ClassType getReturnType(){ return returnType; } 96 public void setReturnType(ClassType returnType){ this.returnType = returnType; } 97 98 public String getReturnTypeName(){ return returnTypeName; } 99 public void setReturnTypeName(String returnTypeName) 100 { 101 this.returnTypeName = StringUtils.avoidNull(returnTypeName); 102 } 103 104 public int getReturnTypeDimension(){ return returnTypeDimension; } 105 public void setReturnTypeDimension(int returnTypeDimension){ this.returnTypeDimension = returnTypeDimension; } 106 107 public String getReturnDescription(){ return returnDescription; } 108 public void setReturnDescription(String returnDescription) { this.returnDescription = returnDescription; } 109 110 } 111 | Popular Tags |