public Tag[] tags() { if (tags == null) tags = wrapped.tags(); return tags; }
protected ClassDoc getValidClass(ClassDoc[] classarr) { if (!nodeprecated) { return classarr[0]; } for (int i = 0; i < classarr.length; i++) { if (classarr[i].tags("deprecated").length == 0) { return classarr[i]; } } return null; }
protected ClassDoc getValidClass( ClassDoc[] classarr ) { if( !nodeprecated ) { return classarr[0]; } for( int i = 0; i < classarr.length; i++ ) { if( classarr[i].tags( "deprecated" ).length == 0 ) { return classarr[i]; } } return null; }
public Tag[] tags(String arg0) { return wrapped.tags(arg0); }
/** * Returns all the tags of a class including its super classes * * @param classDoc the class to check * @return a list of tags */ private static List<Tag> getInheritableTags(ClassDoc classDoc) { List<Tag> tags = new ArrayList<>(); while (classDoc != null) { tags.addAll(asList(classDoc.tags())); classDoc = classDoc.superclass(); } Collections.reverse(tags); return tags; }
private String getLineColor(PackageDoc pkg, ClassDoc cls, ClassDoc node) { String color = "#000000"; if (cls != node && node.tags(TAG_LANDMARK).length <= 0 && node.tags(TAG_CATEGORY).length > 0 && categories.containsKey(node.tags(TAG_CATEGORY)[0].text())) { color = categories.get(node.tags(TAG_CATEGORY)[0].text()).getLineColor(); } if (node.containingPackage() != pkg) { //grey out the fill color final StringBuffer sb = new StringBuffer("#"); sb.append(shiftColor(color.substring(1,3))); sb.append(shiftColor(color.substring(3,5))); sb.append(shiftColor(color.substring(5,7))); color = sb.toString(); } return color; }
private String getFillColor(PackageDoc pkg, ClassDoc cls, ClassDoc node) { String color = "white"; if (cls == null) { //we are rendering for a package summary since there is no cls //see if the node has a fill color if (node.tags(TAG_CATEGORY).length > 0 && categories.containsKey(node.tags(TAG_CATEGORY)[0].text())) { color = categories.get(node.tags(TAG_CATEGORY)[0].text()).getFillColor(); } //override any previous values if a landmark is set if (node.containingPackage() == pkg && node.tags(TAG_LANDMARK).length > 0) { color = "khaki1"; } } else if (cls == node) { //this is class we are rending the class diagram for color = "khaki1"; } else if (node.tags(TAG_CATEGORY).length > 0 && categories.containsKey(node.tags(TAG_CATEGORY)[0].text())) { //not the class for the class diagram so use its fill color color = categories.get(node.tags(TAG_CATEGORY)[0].text()).getFillColor(); if (node.containingPackage() != pkg && color.matches("^[!@#$%^&*+=][0-9A-Fa-f]{6}$")) { //grey out the fill color final StringBuffer sb = new StringBuffer("#"); sb.append(shiftColor(color.substring(1,3))); sb.append(shiftColor(color.substring(3,5))); sb.append(shiftColor(color.substring(5,7))); color = sb.toString(); } } return color; }
/** * Add high-level summary information about toProcess to root, such as its * name, summary, description, version, etc. * * @param root */ protected void addHighLevelBindings(Map<String, Object> root) { root.put("name", toProcess.classDoc.name()); // Extract overrides from the doc tags. StringBuilder summaryBuilder = new StringBuilder(); for (Tag tag : toProcess.classDoc.firstSentenceTags()) summaryBuilder.append(tag.text()); root.put("summary", summaryBuilder.toString()); root.put("description", toProcess.classDoc.commentText().substring(summaryBuilder.toString().length())); root.put("timestamp", toProcess.buildTimestamp); root.put("version", toProcess.absoluteVersion); for (Tag tag : toProcess.classDoc.tags()) { root.put(tag.name(), tag.text()); } }
/** Set the options based on the tag elements of the ClassDoc parameter */ public void setOptions(ClassDoc p) { if (p == null) return; for (Tag tag : p.tags("opt")) { String[] opt = StringUtil.tokenize(tag.text()); opt[0] = "-" + opt[0]; setOption(opt); } }
/** * Builds a view given the class that contains its definition */ public View(RootDoc root, ClassDoc c, OptionProvider provider) { this.viewDoc = c; this.provider = provider; this.root = root; Tag[] tags = c.tags(); ClassMatcher currMatcher = null; // parse options, get the global ones, and build a map of the // pattern matched overrides globalOptions = new ArrayList<String[]>(); for (int i = 0; i < tags.length; i++) { if (tags[i].name().equals("@match")) { currMatcher = buildMatcher(tags[i].text()); if(currMatcher != null) { optionOverrides.put(currMatcher, new ArrayList<String[]>()); } } else if (tags[i].name().equals("@opt")) { String[] opts = StringUtil.tokenize(tags[i].text()); opts[0] = "-" + opts[0]; if (currMatcher == null) { globalOptions.add(opts); } else { optionOverrides.get(currMatcher).add(opts); } } } }
/** * Builds a view along with its parent views, recursively */ private static View buildView(RootDoc root, ClassDoc viewClass, OptionProvider provider) { ClassDoc superClass = viewClass.superclass(); if(superClass == null || superClass.tags("view").length == 0) return new View(root, viewClass, provider); return new View(root, viewClass, buildView(root, superClass, provider)); }
/** * Builds a view along with its parent views, recursively */ private static View buildView(RootDoc root, ClassDoc viewClass, OptionProvider provider) { ClassDoc superClass = viewClass.superclass(); if(superClass == null || superClass.tags("view").length == 0) return new View(root, viewClass, provider); return new View(root, viewClass, buildView(root, superClass, provider)); }
private static String getStereotype(ClassDoc node) { String stereotype = node.isInterface()? "interface" : null; if (node.isException() || node.isError()) { stereotype = "exception"; } else if (node.isAnnotationType()) { stereotype = "annotation"; } else if (node.isEnum()) { stereotype = "enum"; } else if (isStaticType(node)) { stereotype = "static"; } if (node.tags(TAG_STEREOTYPE).length > 0) { stereotype = node.tags(TAG_STEREOTYPE)[0].text(); } return escape(stereotype); }
/** * Print all relations for a given's class's tag * @param tagname the tag containing the given relation * @param from the source class * @param edgetype the dot edge specification */ private void allRelation(Options opt, RelationType rt, ClassDoc from) { String tagname = rt.lower; for (Tag tag : from.tags(tagname)) { String t[] = tokenize(tag.text()); // l-src label l-dst target t = t.length == 1 ? new String[] { "-", "-", "-", t[0] } : t; // Shorthand if (t.length != 4) { System.err.println("Error in " + from + "\n" + tagname + " expects four fields (l-src label l-dst target): " + tag.text()); return; } ClassDoc to = from.findClass(t[3]); if (to != null) { if(hidden(to)) continue; relation(opt, rt, from, to, t[0], t[1], t[2]); } else { if(hidden(t[3])) continue; relation(opt, rt, from, from.toString(), to, t[3], t[0], t[1], t[2]); } } }
/** * Print all relations for a given's class's tag * @param tagname the tag containing the given relation * @param from the source class * @param edgetype the dot edge specification */ private void allRelation(Options opt, RelationType rt, ClassDoc from) { String tagname = rt.toString().toLowerCase(); for (Tag tag : from.tags(tagname)) { String t[] = StringUtil.tokenize(tag.text()); // l-src label l-dst target if (t.length != 4) { System.err.println("Error in " + from + "\n" + tagname + " expects four fields (l-src label l-dst target): " + tag.text()); return; } ClassDoc to = from.findClass(t[3]); if (to != null) { if(hidden(to)) continue; relation(opt, rt, from, to, t[0], t[1], t[2]); } else { if(hidden(t[3])) continue; relation(opt, rt, from, from.toString(), to, t[3], t[0], t[1], t[2]); } } }
/** * Return true if the given ClassDoc should be included * in the serialized form. * * @param cd the ClassDoc object to check for serializability. */ private static boolean serialClassInclude(ClassDoc cd) { if (cd.isEnum()) { return false; } try { cd.superclassType(); } catch (NullPointerException e) { //Workaround for null pointer bug in ClassDoc.superclassType(). return false; } if (cd.isSerializable()) { if (cd.tags("serial").length > 0) { return serialDocInclude(cd); } else if (cd.isPublic() || cd.isProtected()) { return true; } else { return false; } } return false; }
/** * Return true if the given ClassDoc should be included * in the serialized form. * * @param cd the ClassDoc object to check for serializability. */ private static boolean serialClassInclude(ClassDoc cd) { if (cd.isEnum()) { return false; } try { cd.superclassType(); } catch (NullPointerException e) { //Workaround for null pointer bug in ClassDoc.superclassType(). return false; } if (cd.isSerializable()) { if (cd.tags("serial").length > 0) { return serialDocInclude(cd); } else if (cd.isPublic() || cd.isProtected()) { return true; } else { return false; } } return false; }
/** * {@inheritDoc} */ public void writeClassDeprecationInfo() { hr(); Tag[] deprs = classDoc.tags( "deprecated" ); if( Util.isDeprecated( classDoc ) ) { strongText( "doclet.Deprecated" ); if( deprs.length > 0 ) { Tag[] commentTags = deprs[0].inlineTags(); if( commentTags.length > 0 ) { space(); printInlineDeprecatedComment( classDoc, deprs[0] ); } } p(); } }
/** * {@inheritDoc} */ public void addClassDeprecationInfo(Content classInfoTree) { Content hr = new HtmlTree(HtmlTag.HR); classInfoTree.addContent(hr); Tag[] deprs = classDoc.tags("deprecated"); if (Util.isDeprecated(classDoc)) { Content deprLabel = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); Content div = HtmlTree.DIV(HtmlStyle.block, deprLabel); if (deprs.length > 0) { Tag[] commentTags = deprs[0].inlineTags(); if (commentTags.length > 0) { div.addContent(getSpace()); addInlineDeprecatedComment(classDoc, deprs[0], div); } } classInfoTree.addContent(div); } }
/** Print a class's relations */ public void printRelations(ClassDoc c) { Options opt = optionProvider.getOptionsFor(c); if (hidden(c) || c.name().equals("")) // avoid phantom classes, they may pop up when the source uses annotations return; // Print generalization (through the Java superclass) Type s = c.superclassType(); ClassDoc sc = s != null && !s.qualifiedTypeName().equals(Object.class.getName()) ? s.asClassDoc() : null; if (sc != null && !c.isEnum() && !hidden(sc)) relation(opt, RelationType.EXTENDS, c, sc, null, null, null); // Print generalizations (through @extends tags) for (Tag tag : c.tags("extends")) if (!hidden(tag.text())) relation(opt, RelationType.EXTENDS, c, c.findClass(tag.text()), null, null, null); // Print realizations (Java interfaces) for (Type iface : c.interfaceTypes()) { ClassDoc ic = iface.asClassDoc(); if (!hidden(ic)) relation(opt, RelationType.IMPLEMENTS, c, ic, null, null, null); } // Print other associations allRelation(opt, RelationType.COMPOSED, c); allRelation(opt, RelationType.NAVCOMPOSED, c); allRelation(opt, RelationType.HAS, c); allRelation(opt, RelationType.NAVHAS, c); allRelation(opt, RelationType.ASSOC, c); allRelation(opt, RelationType.NAVASSOC, c); allRelation(opt, RelationType.DEPEND, c); }