KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > ParameterInfo


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

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

27 public class ParameterInfo implements Serializable JavaDoc
28 {
29     private String JavaDoc name;
30     private String JavaDoc description;
31     private int listedOrder;
32     private ClassType type;
33     private String JavaDoc typeName;
34     private int typeDimension;
35     private ExecMember containingMember;
36     
37     private static String JavaDoc TABLENAME = "PARAMETER";
38     
39     public ParameterInfo(String JavaDoc typeName)
40     {
41        setTypeName(typeName);
42        setName("");
43        setDescription("");
44     }
45    
46     public ParameterInfo(Parameter parameter, int listedOrder, String JavaDoc 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 JavaDoc conn) throws SQLException JavaDoc
57    {
58       Map JavaDoc fieldInfo = new HashMap JavaDoc(10);
59       fieldInfo.put("NAME", StringUtils.truncate(getName(), 50));
60       fieldInfo.put("DESCRIPTION", getDescription());
61       fieldInfo.put("LISTEDORDER", new Integer JavaDoc(getListedOrder()));
62       fieldInfo.put("TYPEDIMENSION", new Integer JavaDoc(getTypeDimension()));
63       fieldInfo.put("TYPENAME", StringUtils.truncate(getTypeName(), 150));
64       fieldInfo.put("EXECMEMBERID", new Integer JavaDoc(getContainingMember().getId(conn)));
65       
66       try
67       {
68          DBUtils.insert(conn, TABLENAME, fieldInfo);
69       }
70       catch (SQLException JavaDoc ex)
71       {
72          fieldInfo.put("DESCRIPTION", StringUtils.truncate(getDescription(), 350));
73          DBUtils.insert(conn, TABLENAME, fieldInfo);
74       }
75    }
76    
77     // accessors
78
public String JavaDoc getName(){ return name; }
79     public void setName(String JavaDoc name)
80     {
81        this.name = StringUtils.avoidNull(name);
82     }
83
84     public String JavaDoc getDescription(){ return description; }
85     public void setDescription(String JavaDoc 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 JavaDoc getTypeName() { return typeName; }
94     public void setTypeName(String JavaDoc 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