/** Return the list of ProgramElementDoc objects as Array. */ public static ProgramElementDoc[] toProgramElementDocArray(List list) { ProgramElementDoc[] pgmarr = new ProgramElementDoc[list.size()]; for (int i = 0; i < list.size(); i++) { pgmarr[i] = (ProgramElementDoc) (list.get(i)); } return pgmarr; }
/** * Given a string, return an array of tokens. The separator can be escaped with the '\' character. * The '\' character may also be escaped by the '\' character. * * @param s the string to tokenize. * @param separator the separator char. * @param maxTokens the maxmimum number of tokens returned. If the max is reached, the remaining * part of s is appended to the end of the last token. * @return an array of tokens. */ public static String[] tokenize(String s, char separator, int maxTokens) { List tokens = new ArrayList(); StringBuilder token = new StringBuilder(); boolean prevIsEscapeChar = false; for (int i = 0; i < s.length(); i += Character.charCount(i)) { int currentChar = s.codePointAt(i); if (prevIsEscapeChar) { // Case 1: escaped character token.appendCodePoint(currentChar); prevIsEscapeChar = false; } else if (currentChar == separator && tokens.size() < maxTokens - 1) { // Case 2: separator tokens.add(token.toString()); token = new StringBuilder(); } else if (currentChar == '\\') { // Case 3: escape character prevIsEscapeChar = true; } else { // Case 4: regular character token.appendCodePoint(currentChar); } } if (token.length() > 0) { tokens.add(token.toString()); } return (String[]) tokens.toArray(new String[] {}); }
/** * Add deprecated information to the documentation tree * * @param deprmembers list of deprecated members * @param headingKey the caption for the deprecated members table * @param tableSummary the summary for the deprecated members table * @param tableHeader table headers for the deprecated members table * @param contentTree the content tree to which the deprecated members table will be added */ protected void addDeprecatedAPI( List<Doc> deprmembers, String headingKey, String tableSummary, String[] tableHeader, Content contentTree) { if (deprmembers.size() > 0) { Content caption = writer.getTableCaption(configuration.getResource(headingKey)); Content table = (configuration.isOutputHtml5()) ? HtmlTree.TABLE(HtmlStyle.deprecatedSummary, caption) : HtmlTree.TABLE(HtmlStyle.deprecatedSummary, tableSummary, caption); table.addContent(writer.getSummaryTableHeader(tableHeader, "col")); Content tbody = new HtmlTree(HtmlTag.TBODY); for (int i = 0; i < deprmembers.size(); i++) { ProgramElementDoc member = (ProgramElementDoc) deprmembers.get(i); HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member)); if (member.tags("deprecated").length > 0) writer.addInlineDeprecatedComment(member, member.tags("deprecated")[0], td); HtmlTree tr = HtmlTree.TR(td); if (i % 2 == 0) tr.addStyle(HtmlStyle.altColor); else tr.addStyle(HtmlStyle.rowColor); tbody.addContent(tr); } table.addContent(tbody); Content li = HtmlTree.LI(HtmlStyle.blockList, table); Content ul = HtmlTree.UL(HtmlStyle.blockList, li); contentTree.addContent(ul); } }
/** * Return a list of all direct or indirect, sub-classes and subinterfaces of the ClassDoc * argument. * * @param cd ClassDoc whose sub-classes or sub-interfaces are requested. * @param isEnum true if the subclasses should be forced to come from the enum tree. */ public List allSubs(ClassDoc cd, boolean isEnum) { List list = subs(cd, isEnum); for (int i = 0; i < list.size(); i++) { cd = (ClassDoc) list.get(i); List tlist = subs(cd, isEnum); for (int j = 0; j < tlist.size(); j++) { ClassDoc tcd = (ClassDoc) tlist.get(j); if (!list.contains(tcd)) { list.add(tcd); } } } Collections.sort(list); return list; }
/** * Build the field documentation. * * @param elements the XML elements that specify how to construct this documentation. */ public void buildFieldDoc(List<?> elements) { if (writer == null) { return; } for (currentFieldIndex = 0; currentFieldIndex < fields.size(); currentFieldIndex++) { build(elements); } }
/** * Add the navigation summary link. * * @param members members to be linked * @param visibleMemberMap the visible inherited members map * @param liNav the content tree to which the navigation summary link will be added */ protected void addNavSummaryLink( List<?> members, VisibleMemberMap visibleMemberMap, Content liNav) { if (members.size() > 0) { liNav.addContent(getNavSummaryLink(null, true)); return; } ClassDoc icd = classdoc.superclass(); while (icd != null) { List<?> inhmembers = visibleMemberMap.getMembersFor(icd); if (inhmembers.size() > 0) { liNav.addContent(getNavSummaryLink(icd, true)); return; } icd = icd.superclass(); } liNav.addContent(getNavSummaryLink(null, false)); }
/** * Add use information to the documentation tree. * * @param mems list of program elements for which the use information will be added * @param heading the section heading * @param tableSummary the summary for the use table * @param contentTree the content tree to which the use information will be added */ protected void addUseInfo( List<? extends ProgramElementDoc> mems, Content heading, String tableSummary, Content contentTree) { if (mems == null) { return; } List<? extends ProgramElementDoc> members = mems; boolean printedUseTableHeader = false; if (members.size() > 0) { Content caption = writer.getTableCaption(heading); Content table = (configuration.isOutputHtml5()) ? HtmlTree.TABLE(HtmlStyle.useSummary, caption) : HtmlTree.TABLE(HtmlStyle.useSummary, tableSummary, caption); Content tbody = new HtmlTree(HtmlTag.TBODY); Iterator<? extends ProgramElementDoc> it = members.iterator(); for (int i = 0; it.hasNext(); i++) { ProgramElementDoc pgmdoc = it.next(); ClassDoc cd = pgmdoc.containingClass(); if (!printedUseTableHeader) { table.addContent(writer.getSummaryTableHeader(this.getSummaryTableHeader(pgmdoc), "col")); printedUseTableHeader = true; } HtmlTree tr = new HtmlTree(HtmlTag.TR); if (i % 2 == 0) { tr.addStyle(HtmlStyle.altColor); } else { tr.addStyle(HtmlStyle.rowColor); } HtmlTree tdFirst = new HtmlTree(HtmlTag.TD); tdFirst.addStyle(HtmlStyle.colFirst); writer.addSummaryType(this, pgmdoc, tdFirst); tr.addContent(tdFirst); HtmlTree tdLast = new HtmlTree(HtmlTag.TD); tdLast.addStyle(HtmlStyle.colLast); if (cd != null && !(pgmdoc instanceof ConstructorDoc) && !(pgmdoc instanceof ClassDoc)) { HtmlTree name = new HtmlTree(HtmlTag.SPAN); name.addStyle(HtmlStyle.typeNameLabel); name.addContent(cd.name() + "."); tdLast.addContent(name); } addSummaryLink( pgmdoc instanceof ClassDoc ? LinkInfoImpl.Kind.CLASS_USE : LinkInfoImpl.Kind.MEMBER, cd, pgmdoc, tdLast); writer.addSummaryLinkComment(this, pgmdoc, tdLast); tr.addContent(tdLast); tbody.addContent(tr); } table.addContent(tbody); contentTree.addContent(table); } }
/** * Build the enum constant documentation. * * @param elements the XML elements that specify how to construct this documentation. */ public void buildEnumConstant(List<?> elements) { if (writer == null) { return; } for (currentEnumConstantsIndex = 0; currentEnumConstantsIndex < enumConstants.size(); currentEnumConstantsIndex++) { build(elements); } }
/** * Build the method documentation. * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added */ public void buildMethodDoc(XMLNode node, Content memberDetailsTree) { if (writer == null) { return; } int size = methods.size(); if (size > 0) { Content methodDetailsTree = writer.getMethodDetailsTreeHeader(classDoc, memberDetailsTree); for (currentMethodIndex = 0; currentMethodIndex < size; currentMethodIndex++) { Content methodDocTree = writer.getMethodDocTreeHeader( (MethodDoc) methods.get(currentMethodIndex), methodDetailsTree); buildChildren(node, methodDocTree); methodDetailsTree.addContent( writer.getMethodDoc(methodDocTree, (currentMethodIndex == size - 1))); } memberDetailsTree.addContent(writer.getMethodDetails(methodDetailsTree)); } }
/** * Build the field documentation. * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added */ public void buildFieldDoc(XMLNode node, Content memberDetailsTree) { if (writer == null) { return; } int size = fields.size(); if (size > 0) { Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(classDoc, memberDetailsTree); for (currentFieldIndex = 0; currentFieldIndex < size; currentFieldIndex++) { Content fieldDocTree = writer.getFieldDocTreeHeader( (FieldDoc) fields.get(currentFieldIndex), fieldDetailsTree); buildChildren(node, fieldDocTree); fieldDetailsTree.addContent( writer.getFieldDoc(fieldDocTree, (currentFieldIndex == size - 1))); } memberDetailsTree.addContent(writer.getFieldDetails(fieldDetailsTree)); } }
/** {@inheritDoc} */ public boolean hasMembersToDocument() { return methods.size() > 0; }
/** summaryOrder.size() */ public boolean hasMembersToDocument() { return enumConstants.size() > 0; }
/** summaryOrder.size() */ public boolean hasMembersToDocument() { return fields.size() > 0; }
/** * Add the navigation detail link. * * @param members the members to be linked * @param liNav the content tree to which the navigation detail link will be added */ protected void addNavDetailLink(List<?> members, Content liNav) { addNavDetailLink(members.size() > 0 ? true : false, liNav); }