in speccompliance/src/main/java/org/apache/vysper/compliance/reporting/DocumentSpecCompliantAnnotationProcessor.java [94:229]
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
// Retrieve all declarations with SpecCompliant annotations
Collection<? extends Element> declarations = roundEnv.getElementsAnnotatedWith(SpecCompliant.class);
System.out.println("number of solitairy @SpecCompliant: " + declarations.size());
for (Element declaration : declarations) {
final SpecDoc doc = new SpecDoc(declaration, declaration.getAnnotation(SpecCompliant.class));
map.put(doc.getKey(), doc);
}
// Retrieve all SpecCompliance-typed declarations and extract SpecCompliant annotations
Collection<? extends Element> moreDeclarations = roundEnv
.getElementsAnnotatedWith(specCompliantCollectionAnnotation);
System.out.println("number of @SpecCompliance: " + moreDeclarations.size());
for (Element declaration : moreDeclarations) {
final SpecCompliance compliance = declaration.getAnnotation(SpecCompliance.class);
final SpecCompliant[] specCompliants = compliance.compliant();
for (SpecCompliant specCompliant : specCompliants) {
if (specCompliant == null) {
continue;
}
final SpecDoc doc = new SpecDoc(declaration, specCompliant);
map.put(doc.getKey(), doc);
}
}
// visit every annotation fromt the now sorted map
// write the HTML file
fileWriter
.println("<html><head>"
+ "<link rel='stylesheet' type='text/css' href='http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css'>\n"
+ "<link rel='stylesheet' type='text/css' href='http://yui.yahooapis.com/2.7.0/build/base/base-min.css'>\n"
+ "</head><body><table><thead><th>spec</th><th>section</th><th>package</th><th>class</th><th>field/method/etc.</th><th>coverage</th><th>implementation</th><th>comment</th></thead>");
for (String key : map.keySet()) {
fileWriter.print("<tr>");
System.out.println(key);
final SpecDoc doc = map.get(key);
// spec
fileWriter.print("<td>");
final String specURL = doc.getSpecDocURL();
if (specURL != null) {
fileWriter.print("<a href='" + specURL + "'>");
}
final String specDoc = doc.getSpecDoc();
if (specDoc != null) {
fileWriter.print(specDoc);
}
if (specURL != null) {
fileWriter.print("</a>");
}
fileWriter.print("</td>");
// spec section
fileWriter.print("<td>");
String specSection = doc.getSpecSection();
if (specSection != null && specSection.length() > 0) {
if (specSection.endsWith(".")) {
specSection = specSection.substring(0, specSection.length() - 1);
}
String anchorLink = Character.isDigit(specSection.charAt(0)) ? "#section-" : "#appendix-";
if (specURL != null) {
fileWriter.print("<a href='" + specURL + anchorLink + specSection + "'>");
}
fileWriter.print(specSection);
if (specURL != null) {
fileWriter.print("</a>");
}
}
fileWriter.print("</td>");
// package
fileWriter.print("<td>");
final String packageName = doc.getPackage();
if (packageName != null) {
fileWriter.print(o_a_v_shortened(packageName));
}
fileWriter.print("</td>");
// class
fileWriter.print("<td>");
final String className = doc.getClassName();
if (className != null) {
fileWriter.print("<a href='" + doc.getFQClassName().replace(".", "/") + ".html'>");
fileWriter.print(o_a_v_cut(packageName, className));
fileWriter.print("</a>");
}
fileWriter.print("</td>");
// class element
fileWriter.print("<td>");
final String member = doc.getMember();
if (member != null) {
if (className != null) {
fileWriter.print("<a href='" + className.replace(".", "/") + ".html#"
+ doc.getMemberAnchor().replace(",", ",%20") + "'>");
}
fileWriter.print(o_a_v_cut(packageName, member));
if (className != null) {
fileWriter.print("</a>");
}
}
fileWriter.print("</td>");
// coverage
fileWriter.print("<td>");
final SpecCompliant.ComplianceCoverage coverage = doc.getCoverageLevel();
if (coverage != null) {
fileWriter.print(coverage.toString().toLowerCase());
}
fileWriter.print("</td>");
// status
fileWriter.print("<td>");
final SpecCompliant.ComplianceStatus complianceStatus = doc.getComplianceStatus();
if (complianceStatus != null) {
fileWriter.print(complianceStatus.toString().toLowerCase());
}
fileWriter.print("</td>");
// comment
fileWriter.print("<td>");
final String comment = doc.getComment();
if (comment != null) {
fileWriter.print(comment);
}
fileWriter.print("</td>");
fileWriter.println("</tr>");
}
fileWriter.println("</table></body>");
return true;
}