53 * This code and its internal interfaces are subject to change or
54 * deletion without notice.</b>
55 *
56 * @author Jamie Ho
57 * @author Bhavesh Patel (Modified)
58 */
59 public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements ConstantsSummaryWriter {
60
61 /**
62 * The configuration used in this run of the standard doclet.
63 */
64 HtmlConfiguration configuration;
65
66 /**
67 * The current class being documented.
68 */
69 private TypeElement currentTypeElement;
70
71 private final String constantsTableSummary;
72
73 private final List<String> constantsTableHeader;
74
75 /**
76 * The HTML tree for main tag.
77 */
78 private HtmlTree mainTree = HtmlTree.MAIN();
79
80 /**
81 * The HTML tree for constant values summary.
82 */
83 private HtmlTree summaryTree;
84
85 /**
86 * Construct a ConstantsSummaryWriter.
87 * @param configuration the configuration used in this run
88 * of the standard doclet.
89 */
90 public ConstantsSummaryWriterImpl(HtmlConfiguration configuration) {
91 super(configuration, DocPaths.CONSTANT_VALUES);
92 this.configuration = configuration;
93 constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
94 configuration.getText("doclet.Constants_Summary"));
95 constantsTableHeader = new ArrayList<>();
96 constantsTableHeader.add(getModifierTypeHeader());
97 constantsTableHeader.add(configuration.getText("doclet.ConstantField"));
98 constantsTableHeader.add(configuration.getText("doclet.Value"));
99 }
100
101 /**
102 * {@inheritDoc}
103 */
104 public Content getHeader() {
105 String label = configuration.getText("doclet.Constants_Summary");
106 HtmlTree bodyTree = getBody(true, getWindowTitle(label));
107 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
108 ? HtmlTree.HEADER()
109 : bodyTree;
110 addTop(htmlTree);
111 addNavLinks(true, htmlTree);
112 if (configuration.allowTag(HtmlTag.HEADER)) {
113 bodyTree.addContent(htmlTree);
114 }
115 return bodyTree;
116 }
117
118 /**
244 cb.addContent(enclosingPackage.getQualifiedName());
245 cb.addContent(".");
246 cb.addContent(classlink);
247 return getClassName(cb);
248 } else {
249 return getClassName(classlink);
250 }
251 }
252
253 /**
254 * Get the class name in the table caption and the table header.
255 *
256 * @param classStr the class name to print.
257 * @return the table caption and header
258 */
259 protected Content getClassName(Content classStr) {
260 Content caption = getTableCaption(classStr);
261 Content table = (configuration.isOutputHtml5())
262 ? HtmlTree.TABLE(HtmlStyle.constantsSummary, caption)
263 : HtmlTree.TABLE(HtmlStyle.constantsSummary, constantsTableSummary, caption);
264 table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
265 return table;
266 }
267
268 /**
269 * {@inheritDoc}
270 */
271 public void addConstantMembers(TypeElement typeElement, Collection<VariableElement> fields,
272 Content classConstantTree) {
273 currentTypeElement = typeElement;
274 Content tbody = new HtmlTree(HtmlTag.TBODY);
275 boolean altColor = true;
276 for (VariableElement field : fields) {
277 HtmlTree tr = new HtmlTree(HtmlTag.TR);
278 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
279 addConstantMember(field, tr);
280 tbody.addContent(tr);
281 altColor = !altColor;
282 }
283 Content table = getConstantMembersHeader(typeElement);
284 table.addContent(tbody);
|
53 * This code and its internal interfaces are subject to change or
54 * deletion without notice.</b>
55 *
56 * @author Jamie Ho
57 * @author Bhavesh Patel (Modified)
58 */
59 public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements ConstantsSummaryWriter {
60
61 /**
62 * The configuration used in this run of the standard doclet.
63 */
64 HtmlConfiguration configuration;
65
66 /**
67 * The current class being documented.
68 */
69 private TypeElement currentTypeElement;
70
71 private final String constantsTableSummary;
72
73 private final TableHeader constantsTableHeader;
74
75 /**
76 * The HTML tree for main tag.
77 */
78 private HtmlTree mainTree = HtmlTree.MAIN();
79
80 /**
81 * The HTML tree for constant values summary.
82 */
83 private HtmlTree summaryTree;
84
85 /**
86 * Construct a ConstantsSummaryWriter.
87 * @param configuration the configuration used in this run
88 * of the standard doclet.
89 */
90 public ConstantsSummaryWriterImpl(HtmlConfiguration configuration) {
91 super(configuration, DocPaths.CONSTANT_VALUES);
92 this.configuration = configuration;
93 constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
94 configuration.getText("doclet.Constants_Summary"));
95 constantsTableHeader = new TableHeader(
96 contents.modifierAndTypeLabel, contents.constantFieldLabel, contents.valueLabel);
97 }
98
99 /**
100 * {@inheritDoc}
101 */
102 public Content getHeader() {
103 String label = configuration.getText("doclet.Constants_Summary");
104 HtmlTree bodyTree = getBody(true, getWindowTitle(label));
105 HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
106 ? HtmlTree.HEADER()
107 : bodyTree;
108 addTop(htmlTree);
109 addNavLinks(true, htmlTree);
110 if (configuration.allowTag(HtmlTag.HEADER)) {
111 bodyTree.addContent(htmlTree);
112 }
113 return bodyTree;
114 }
115
116 /**
242 cb.addContent(enclosingPackage.getQualifiedName());
243 cb.addContent(".");
244 cb.addContent(classlink);
245 return getClassName(cb);
246 } else {
247 return getClassName(classlink);
248 }
249 }
250
251 /**
252 * Get the class name in the table caption and the table header.
253 *
254 * @param classStr the class name to print.
255 * @return the table caption and header
256 */
257 protected Content getClassName(Content classStr) {
258 Content caption = getTableCaption(classStr);
259 Content table = (configuration.isOutputHtml5())
260 ? HtmlTree.TABLE(HtmlStyle.constantsSummary, caption)
261 : HtmlTree.TABLE(HtmlStyle.constantsSummary, constantsTableSummary, caption);
262 table.addContent(constantsTableHeader.toContent());
263 return table;
264 }
265
266 /**
267 * {@inheritDoc}
268 */
269 public void addConstantMembers(TypeElement typeElement, Collection<VariableElement> fields,
270 Content classConstantTree) {
271 currentTypeElement = typeElement;
272 Content tbody = new HtmlTree(HtmlTag.TBODY);
273 boolean altColor = true;
274 for (VariableElement field : fields) {
275 HtmlTree tr = new HtmlTree(HtmlTag.TR);
276 tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
277 addConstantMember(field, tr);
278 tbody.addContent(tr);
279 altColor = !altColor;
280 }
281 Content table = getConstantMembersHeader(typeElement);
282 table.addContent(tbody);
|