1 package org.codehaus.plexus.maven.plugin.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.ArrayList;
20 import java.util.Iterator;
21 import java.util.List;
22 import java.util.Map;
23 import java.util.SortedMap;
24 import java.util.SortedSet;
25 import java.util.TreeMap;
26 import java.util.TreeSet;
27
28 import org.codehaus.doxia.sink.Sink;
29 import org.jdom.Element;
30
31
32
33
34
35 public class Components
36 {
37 private List components = new ArrayList();
38
39 public Components( Element element )
40 {
41 for ( Iterator it = element.getChildren( "component" ).iterator(); it.hasNext(); )
42 {
43 Element component = (Element) it.next();
44
45 components.add( new Component( component ) );
46 }
47 }
48
49 public void print( Sink sink, String javaDocDestDir, String jxrDestDir )
50 {
51 SortedSet roles = new TreeSet();
52 SortedSet emptyList = new TreeSet();
53 SortedMap roleMap = new TreeMap();
54
55
56
57
58
59 for ( Iterator it = components.iterator(); it.hasNext(); )
60 {
61 Component component = (Component) it.next();
62
63 roles.add( component.getRole() );
64
65 if ( !component.hasRoleHint() )
66 {
67 emptyList.add( component );
68 }
69 else
70 {
71 List list = (List) roleMap.get( component.getRole() );
72
73 if ( list == null )
74 {
75 list = new ArrayList();
76 roleMap.put( component.getRole(), list );
77 }
78
79 list.add( component );
80 }
81 }
82
83
84
85
86
87 sink.section2();
88 sink.sectionTitle2();
89 sink.text( "Index" );
90 sink.sectionTitle2_();
91 sink.section2_();
92
93 sink.paragraph();
94 for ( Iterator it = roles.iterator(); it.hasNext(); )
95 {
96 String role = (String) it.next();
97 sink.link( "#" + role );
98 sink.text( role );
99 sink.link_();
100 sink.lineBreak();
101 }
102 sink.paragraph_();
103
104
105
106
107
108 sink.section2();
109 sink.sectionTitle2();
110 sink.text( "Components without role-hint" );
111 sink.sectionTitle2_();
112 sink.section2_();
113
114 for ( Iterator it = emptyList.iterator(); it.hasNext(); )
115 {
116 Component component = (Component) it.next();
117 sink.anchor( component.getRole() );
118 sink.paragraph();
119 component.print( sink, javaDocDestDir, jxrDestDir );
120 sink.paragraph_();
121 sink.anchor_();
122 }
123
124
125
126
127
128 for ( Iterator it = roleMap.entrySet().iterator(); it.hasNext(); )
129 {
130 Map.Entry entry = (Map.Entry) it.next();
131
132 sink.section2();
133 sink.sectionTitle2();
134 sink.anchor( (String) entry.getKey() );
135 sink.text( "Components implementing " + entry.getKey() );
136 sink.anchor_();
137 sink.sectionTitle2_();
138 sink.section2_();
139
140 for ( Iterator j = ( (List) entry.getValue() ).iterator(); j.hasNext(); )
141 {
142 Component component = (Component) j.next();
143
144 sink.paragraph();
145 component.print( sink, javaDocDestDir, jxrDestDir );
146 sink.paragraph_();
147 }
148 }
149 }
150 }