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 MethodIntroductionSubWriter extends MethodSubWriter { 39 40 public MethodIntroductionSubWriter 41 (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, 42 AspectDoc ad) 43 { 44 super(writer, ad); 45 } 46 47 public MethodIntroductionSubWriter 48 (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) 49 { 50 super(writer); 51 } 52 53 protected final String keyName() { return "Method_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.isMethod()) { 69 list.add(member); } 73 } 74 return list; 75 } 76 77 81 public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { 82 org.aspectj.ajdoc.MethodDoc method = (org.aspectj.ajdoc.MethodDoc)member; 83 IntroducedDoc intro = method.introduced(); 84 ClassDoc[] targets = intro.targets(); 85 if (targets.length > 0) { 86 writer.dt(); 87 writer.boldText("doclet.Introduced_on"); 88 writer.dd(); 89 writer.code(); 90 for (int i = 0; i < targets.length; i++) { 91 if (i > 0) writer.print(", "); 92 ClassDoc target = targets[i]; 93 writer.printClassLink(target, 94 "methods_introduced_from_class_" + 95 cd.qualifiedName(), 96 target.name()); 97 } 98 writer.codeEnd(); 99 writer.ddEnd(); } 101 } 102 103 107 public void printSummaryCrosscuts(ClassDoc cd, 108 ProgramElementDoc member) { 109 Set set = new HashSet (); 110 org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; 111 IntroducedDoc intro = md.introduced(); 112 ClassDoc[] targets = intro.targets(); 113 for (int i = 0; i < targets.length; i++) { 114 set.add(targets[i]); 115 } 116 if (targets.length > 0) { 117 writer.boldText("doclet.Advises"); 118 List list = new ArrayList (set); 119 Collections.sort(list); 120 for (Iterator i = list.iterator(); i.hasNext();) { 121 print(' '); 122 ClassDoc target = (ClassDoc)i.next(); 123 124 writer.printClassLink(target, 125 "methods_introduced_from_class_" 126 + cd.qualifiedName(), 127 target.name()); 128 if (i.hasNext()) print(","); 129 } 130 } 131 } 132 133 public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { 134 return true; 135 } 136 } 137 | Popular Tags |