1 package org.ashkelon; 2 7 8 import java.io.Serializable ; 9 import java.sql.Connection ; 10 import java.sql.SQLException ; 11 import java.util.HashMap ; 12 import java.util.Map ; 13 14 import org.ashkelon.db.DBUtils; 15 import org.ashkelon.util.Logger; 16 import org.ashkelon.util.StringUtils; 17 18 import com.sun.javadoc.ExecutableMemberDoc; 19 import com.sun.javadoc.SeeTag; 20 21 28 public class Reference implements Serializable 29 { 30 private String label; 31 private DocInfo refDoc; 32 private String refDocName; 33 private int refDocType; 34 private DocInfo sourceDoc; 35 private String qualifiedSourceName; 36 37 38 private static String TABLENAME = "REFERENCE"; 39 40 public Reference(String refDocName) 41 { 42 setRefDocName(refDocName); 43 setLabel(""); 44 setRefDoc(new DocInfo()); 45 } 46 47 public Reference(DocInfo sourceDoc, SeeTag seetag) 48 { 49 Logger log = Logger.getInstance(); 50 51 setSourceDoc(sourceDoc); 52 setLabel(seetag.label()); 53 54 String refDocName = ""; 55 int refDocType = 0; 56 57 if (seetag.referencedMember() == null) 58 { 59 if (seetag.referencedClass() == null) 60 { 61 if (seetag.referencedPackage() != null) 62 { 63 refDocName = seetag.referencedPackage().name(); 64 refDocType = DocInfo.PACKAGE_TYPE; 65 } 66 } else 67 { 68 refDocName = seetag.referencedClass().qualifiedName(); 69 refDocType = DocInfo.CLASS_TYPE; 70 } 71 } else 72 { 73 refDocName = seetag.referencedMember().qualifiedName(); 74 refDocType = DocInfo.MEMBER_TYPE; 75 if (seetag.referencedMember() instanceof ExecutableMemberDoc) 76 { 77 refDocType = DocInfo.EXECMEMBER_TYPE; 78 refDocName += ((ExecutableMemberDoc) seetag.referencedMember()).signature(); 79 } 80 } 81 82 if (StringUtils.isBlank(refDocName)) 83 { 84 refDocName = seetag.referencedMemberName(); 85 if (StringUtils.isBlank(refDocName)) 86 { 87 refDocName = seetag.referencedClassName(); 88 if (!StringUtils.isBlank(refDocName)) 89 { 90 log.debug("class ref doc name: "+refDocName); 91 refDocType = DocInfo.CLASS_TYPE; 92 } 93 } 94 else 95 { 96 log.debug("member ref doc name: "+refDocName); 97 refDocType = DocInfo.MEMBER_TYPE; 98 } 99 } 100 101 if(StringUtils.isBlank(refDocName)) 102 { 103 refDocName = ""; 104 log.debug("still have blank refdocnames!"); 105 } 106 107 setRefDocName(refDocName); 108 setRefDocType(refDocType); 109 } 110 111 public void store(Connection conn) throws SQLException 112 { 113 Map fieldInfo = new HashMap (5); 114 115 fieldInfo.put("LABEL", StringUtils.truncate(getLabel(), 60)); 116 fieldInfo.put("SOURCEDOC_ID", new Integer (getSourceDoc().getId(conn))); 117 fieldInfo.put("REFDOC_NAME", StringUtils.truncate(getRefDocName(), 450)); 118 fieldInfo.put("REFDOC_TYPE", new Integer (getRefDocType())); 119 DBUtils.insert(conn, TABLENAME, fieldInfo); 120 } 121 122 public String getLabel() { return label; } 124 public void setLabel(String label) { this.label = label; } 125 126 public DocInfo getRefDoc() { return refDoc; } 127 public void setRefDoc(DocInfo refDoc) { this.refDoc = refDoc; } 128 129 public String getRefDocName() { return refDocName; } 130 public void setRefDocName(String refDocName) { this.refDocName = refDocName; } 131 132 public DocInfo getSourceDoc() { return sourceDoc; } 133 public void setSourceDoc(DocInfo sourceDoc) { this.sourceDoc = sourceDoc; } 134 135 public int getRefDocType() { return refDocType; } 136 public void setRefDocType(int refDocType) { this.refDocType = refDocType; } 137 138 public String toString() 139 { 140 return getLabel() + "("+getRefDocName()+")"; 141 } 142 143 public String getQualifiedSourceName() 144 { 145 return qualifiedSourceName; 146 } 147 public void setQualifiedSourceName(String qsn) 148 { 149 this.qualifiedSourceName = qsn; 150 } 151 152 } 153 | Popular Tags |