1 22 package org.aspectj.tools.doclets.standard; 23 import org.aspectj.ajdoc.AspectDoc; 24 import org.aspectj.ajdoc.IntroducedDoc; 25 import org.aspectj.ajdoc.IntroductionDoc; 26 27 import com.sun.javadoc.ClassDoc; 28 import com.sun.javadoc.MemberDoc; 29 import com.sun.javadoc.ProgramElementDoc; 30 31 import java.util.ArrayList ; 32 import java.util.Collections ; 33 import java.util.HashSet ; 34 import java.util.Iterator ; 35 import java.util.List ; 36 import java.util.Set ; 37 38 public class FieldIntroductionSubWriter extends FieldSubWriter { 39 40 public FieldIntroductionSubWriter 41 (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, 42 AspectDoc ad) 43 { 44 super(writer, ad); 45 } 46 47 public FieldIntroductionSubWriter 48 (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) 49 { 50 super(writer); 51 } 52 53 protected final String keyName() { return "Field_Introduction"; } 54 55 public void printInheritedSummaryAnchor(ClassDoc cd) {} 56 public void printInheritedSummaryLabel(ClassDoc cd) {} 57 protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {} 58 59 protected List getMembers(ClassDoc cd) { 60 if (!(cd instanceof AspectDoc)) return super.getMembers(cd); 61 IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); 62 List list = new ArrayList (); 63 if (introductions == null) return list; 64 for (int i = 0; i < introductions.length; i++) { 65 IntroductionDoc id = introductions[i]; 66 if (!(id instanceof IntroducedDoc)) continue; 67 MemberDoc member = ((IntroducedDoc)id).member(); 68 if (member.isField()) { 69 list.add(member); } 73 } 74 return list; 75 } 76 77 79 public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { 80 org.aspectj.ajdoc.FieldDoc field = (org.aspectj.ajdoc.FieldDoc)member; 81 IntroducedDoc intro = field.introduced(); 82 ClassDoc[] targets = intro.targets(); 84 if (targets.length > 0) { 85 writer.dt(); writer.boldText("doclet.Introduced_on"); 87 writer.dd(); 88 writer.code(); 89 for (int i = 0; i < targets.length; i++) { 90 if (i > 0) writer.print(", "); 91 ClassDoc target = targets[i]; 92 writer.printClassLink(target, 93 "fields_introduced_from_class_" + 94 cd.qualifiedName(), 95 target.name()); 96 97 } 98 writer.codeEnd(); 99 writer.ddEnd(); } 101 } 102 103 public void printSummaryCrosscuts(ClassDoc cd, 104 ProgramElementDoc member) { 105 Set set = new HashSet (); 106 org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; 107 IntroducedDoc intro = md.introduced(); 108 ClassDoc[] targets = intro.targets(); 109 for (int i = 0; i < targets.length; i++) { 110 set.add(targets[i]); 111 } 112 if (targets.length > 0) { 113 writer.boldText("doclet.Advises"); 114 List list = new ArrayList (set); 115 Collections.sort(list); 116 for (Iterator i = list.iterator(); i.hasNext();) { 117 print(' '); 118 ClassDoc target = (ClassDoc)i.next(); 119 writer.printClassLink(target, 120 "fields_introduced_from_class_" 121 + cd.qualifiedName(), 122 target.name()); 123 if (i.hasNext()) print(","); 124 } 125 } 126 } 127 128 public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { 129 return true; 130 } 131 } 132 | Popular Tags |