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