KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > MethodMember


1 package org.ashkelon;
2 /**
3  * Ashkelon
4  * Copyright UptoData Inc. 2001
5  * March 2001
6  */

7
8 import java.sql.Connection JavaDoc;
9 import java.sql.SQLException JavaDoc;
10 import java.util.HashMap JavaDoc;
11 import java.util.Map JavaDoc;
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 /**
20  * Part of Persistable javadoc object model
21  * Analog of com.sun.javadoc.MethodDoc
22  *
23  * @author Eitan Suez
24  * @version 2.0
25  */

26 public class MethodMember extends ExecMember
27 {
28    private boolean isAbstract;
29    private ClassType returnType;
30    private String JavaDoc returnTypeName;
31    private int returnTypeDimension;
32    private String JavaDoc returnDescription;
33    
34    private static String JavaDoc TABLENAME = "METHOD";
35
36    public MethodMember(String JavaDoc qualifiedName, String JavaDoc signature)
37    {
38       super(qualifiedName, signature, Member.METHOD_MEMBER);
39       setReturnTypeName("");
40       setReturnDescription("");
41    }
42    
43    public MethodMember(Member member, String JavaDoc 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 JavaDoc conn) throws SQLException JavaDoc
58     {
59        super.store(conn);
60        Map JavaDoc fieldInfo = new HashMap JavaDoc(5);
61        fieldInfo.put("ID", new Integer JavaDoc(getId(conn)));
62        
63        //fieldInfo.put("ISABSTRACT", new Boolean(isAbstract()));
64
int boolvalue = isAbstract() ? 1 : 0;
65        fieldInfo.put("ISABSTRACT", new Integer JavaDoc(boolvalue));
66        
67        fieldInfo.put("RETURNTYPENAME", StringUtils.truncate(getReturnTypeName(), 150));
68        fieldInfo.put("RETURNTYPEDIMENSION", new Integer JavaDoc(getReturnTypeDimension()));
69        fieldInfo.put("RETURNDESCRIPTION", getReturnDescription());
70        
71        try
72        {
73           DBUtils.insert(conn, TABLENAME, fieldInfo);
74        }
75        catch (SQLException JavaDoc 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 JavaDoc conn, int memberid, int docid) throws SQLException JavaDoc
83     {
84        Map JavaDoc constraint = new HashMap JavaDoc();
85        constraint.put("ID", new Integer JavaDoc(memberid));
86        DBUtils.delete(conn, TABLENAME, constraint);
87        
88        ExecMember.delete(conn, memberid, docid);
89     }
90     
91     // accessor methods:
92
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 JavaDoc getReturnTypeName(){ return returnTypeName; }
99     public void setReturnTypeName(String JavaDoc 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 JavaDoc getReturnDescription(){ return returnDescription; }
108     public void setReturnDescription(String JavaDoc returnDescription) { this.returnDescription = returnDescription; }
109     
110 }
111
Popular Tags