KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > FieldMember


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.FieldDoc;
18
19 /**
20  * Part of Persistable javadoc object model
21  * Analog of com.sun.javadoc.FieldDoc
22  *
23  * @author Eitan Suez
24  * @version 2.0
25  */

26 public class FieldMember extends Member
27 {
28     private int typeDimension;
29     private ClassType type;
30     private String JavaDoc typeName;
31
32     private static String JavaDoc TABLENAME = "FIELD";
33
34     public FieldMember(String JavaDoc qualifiedName, String JavaDoc qualifiedTypeName)
35     {
36        super(qualifiedName, Member.FIELD_MEMBER);
37        setTypeName(qualifiedTypeName);
38     }
39
40    public FieldMember(Member member, String JavaDoc qualifiedTypeName)
41    {
42       super(member);
43       setTypeName(qualifiedTypeName);
44    }
45     
46     public FieldMember(FieldDoc fielddoc, ClassType containingClass)
47     {
48       super(fielddoc, containingClass);
49       setTypeName(fielddoc.type().qualifiedTypeName());
50       setTypeDimension(JDocUtil.getDimension(fielddoc.type()));
51     }
52     
53     public void store(Connection JavaDoc conn) throws SQLException JavaDoc
54     {
55        super.store(conn);
56        Map JavaDoc fieldInfo = new HashMap JavaDoc(10);
57        fieldInfo.put("ID", new Integer JavaDoc(getId(conn)));
58        fieldInfo.put("TYPEDIMENSION", new Integer JavaDoc(getTypeDimension()));
59        fieldInfo.put("TYPENAME", StringUtils.truncate(getTypeName(), 150));
60        DBUtils.insert(conn, TABLENAME, fieldInfo);
61     }
62     
63    public static void delete(Connection JavaDoc conn, int memberid, int docid) throws SQLException JavaDoc
64    {
65       Map JavaDoc constraint = new HashMap JavaDoc();
66       constraint.put("ID", new Integer JavaDoc(memberid));
67       DBUtils.delete(conn, TABLENAME, constraint);
68
69       Member.delete(conn, memberid, docid);
70    }
71
72     // accessor methods:
73
public int getTypeDimension(){ return typeDimension; }
74     public void setTypeDimension(int typeDimension){ this.typeDimension = typeDimension; }
75
76     public ClassType getType(){ return type; }
77     public void setType(ClassType type){ this.type = type; }
78
79     public String JavaDoc getTypeName() { return typeName; }
80     public void setTypeName(String JavaDoc typeName) { this.typeName = typeName; }
81 }
82
Popular Tags