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.FieldDoc; 18 19 26 public class FieldMember extends Member 27 { 28 private int typeDimension; 29 private ClassType type; 30 private String typeName; 31 32 private static String TABLENAME = "FIELD"; 33 34 public FieldMember(String qualifiedName, String qualifiedTypeName) 35 { 36 super(qualifiedName, Member.FIELD_MEMBER); 37 setTypeName(qualifiedTypeName); 38 } 39 40 public FieldMember(Member member, String 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 conn) throws SQLException 54 { 55 super.store(conn); 56 Map fieldInfo = new HashMap (10); 57 fieldInfo.put("ID", new Integer (getId(conn))); 58 fieldInfo.put("TYPEDIMENSION", new Integer (getTypeDimension())); 59 fieldInfo.put("TYPENAME", StringUtils.truncate(getTypeName(), 150)); 60 DBUtils.insert(conn, TABLENAME, fieldInfo); 61 } 62 63 public static void delete(Connection conn, int memberid, int docid) throws SQLException 64 { 65 Map constraint = new HashMap (); 66 constraint.put("ID", new Integer (memberid)); 67 DBUtils.delete(conn, TABLENAME, constraint); 68 69 Member.delete(conn, memberid, docid); 70 } 71 72 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 getTypeName() { return typeName; } 80 public void setTypeName(String typeName) { this.typeName = typeName; } 81 } 82 | Popular Tags |