org.infinispan.doclets.jmx.JmxHtmlGenerator Maven / Gradle / Ivy
package org.infinispan.doclets.jmx;
import java.util.List;
import org.infinispan.doclets.html.HtmlGenerator;
public class JmxHtmlGenerator extends HtmlGenerator {
List components;
public JmxHtmlGenerator(String encoding, String title, String bottom, String footer, String header, String metaDescription, List metaKeywords, List components) {
super(encoding, title, bottom, footer, header, metaDescription, metaKeywords);
this.components = components;
}
@Override
protected String generateContents() {
StringBuilder sb = new StringBuilder();
// index of components
sb.append("JMX Components available
");
sb.append("");
for (MBeanComponent mbean : components) {
sb.append("- ").append(mbean.name).append("");
if (isValid(mbean.desc)) sb.append(" (").append(mbean.desc).append(")");
sb.append("
\n");
}
sb.append("
");
sb.append("
");
// a table for each component.
for (MBeanComponent mbean : components) {
sb.append("\n");
sb.append("\n");
sb.append("Component ").append(mbean.name).append(" (Class ").append(mbean.className).append(")");
if (isValid(mbean.desc)) sb.append("
").append(mbean.desc).append("\n");
sb.append(" \n");
if (!mbean.attributes.isEmpty()) {
// Attributes
sb.append("Attributes \n");
sb.append("\n");
sb.append("Name \n");
sb.append("Description \n");
sb.append("Type \n");
sb.append("Writable \n");
for (MBeanAttribute attr : mbean.attributes) {
sb.append("");
sb.append("").append(attr.name).append(" ");
sb.append("").append(attr.desc).append(" ");
sb.append("").append(attr.type).append(" ");
sb.append("").append(attr.writable).append(" ");
sb.append(" ");
}
sb.append("
");
}
if (!mbean.operations.isEmpty()) {
// Operations
sb.append("Operations \n");
sb.append("\n");
sb.append("Name \n");
sb.append("Description \n");
sb.append("Signature \n");
for (MBeanOperation operation : mbean.operations) {
sb.append("");
sb.append("").append(operation.name).append(" ");
sb.append("").append(operation.desc).append(" ");
sb.append("").append(generateSignature(operation)).append(" ");
sb.append(" ");
}
sb.append("
");
}
sb.append("
");
}
return sb.toString();
}
private String toURL(String fqcn) {
return fqcn.replace(".", "/") + ".html";
}
private String generateSignature(MBeanOperation op) {
// ()
StringBuilder sb = new StringBuilder();
if (isValid(op.returnType))
sb.append(op.returnType);
else
sb.append("void");
sb.append(" ").append(op.name);
if (isValid(op.signature))
sb.append("(").append(op.signature).append(")");
else
sb.append("()");
return sb.toString();
}
}