private static boolean hasDefaultConstructor(ClassDoc classDoc) { ConstructorDoc[] cdocs = classDoc.constructors(); for (int i = 0; i < cdocs.length; i++) { ConstructorDoc cdoc = cdocs[i]; if (cdoc.parameters().length == 0) { if (!cdoc.isPrivate()) { return true; } } } return false; }
/** {@inheritDoc} */ public Content getSignature(ConstructorDoc constructor) { Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(constructor, pre); addModifiers(constructor, pre); if (configuration.linksource) { Content constructorName = new StringContent(constructor.name()); writer.addSrcLink(constructor, constructorName, pre); } else { addName(constructor.name(), pre); } int indent = pre.charCount(); addParameters(constructor, pre, indent); addExceptions(constructor, pre, indent); return pre; }
/** * Parses a constructor type definition * * @param docConstructor * @return */ protected static Constructor ParseConstructor(ConstructorDoc docConstructor) { assert (docConstructor != null); Constructor xmlConstructor = new Constructor(); xmlConstructor.name = docConstructor.name(); xmlConstructor.comment = docConstructor.commentText(); xmlConstructor.scope = DetermineScope(docConstructor); xmlConstructor.isVarArgs = docConstructor.isVarArgs(); xmlConstructor.isDefault = docConstructor.position().line() == docConstructor.containingClass().position().line(); Parameter[] parameters = docConstructor.parameters(); if (parameters != null && parameters.length > 0) { ParamTag[] paramComments = docConstructor.paramTags(); ArrayList<Param> methodList = new ArrayList<Param>(); for (Parameter parameter : parameters) { ParamTag paramComment = null; // look to see if this parameter has comments // if so, paramComment will be set for (ParamTag testParam : paramComments) { String testParamName = testParam.parameterName(); if (testParamName != null) { if (testParamName.compareTo(parameter.name()) == 0) { paramComment = testParam; break; } } } methodList.add(ParseParameter(parameter, paramComment)); } xmlConstructor.parameters = methodList.toArray(new Param[] {}); } else { log.debug("No parameters for method: " + docConstructor.name()); } // parse annotations for the constructor xmlConstructor.annotationInstances = ParseAnnotationInstances(docConstructor.annotations(), docConstructor.qualifiedName()); return xmlConstructor; }
/** Print the class's constructors m */ private boolean operations(Options opt, ConstructorDoc m[]) { boolean printed = false; for (ConstructorDoc cd : m) { if (hidden(cd)) continue; stereotype(opt, cd, Align.LEFT); String cs = visibility(opt, cd) + cd.name(); if (opt.showType) { cs += "(" + parameter(opt, cd.parameters()) + ")"; } else { cs += "()"; } tableLine(Align.LEFT, cs); printed = true; tagvalue(opt, cd); } return printed; }
/** {@inheritDoc} */ public Content getConstructorDocTreeHeader( ConstructorDoc constructor, Content constructorDetailsTree) { String erasureAnchor; if ((erasureAnchor = getErasureAnchor(constructor)) != null) { constructorDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor))); } constructorDetailsTree.addContent(writer.getMarkerAnchor(writer.getAnchor(constructor))); Content constructorDocTree = writer.getMemberTreeHeader(); Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING); heading.addContent(constructor.name()); constructorDocTree.addContent(heading); return constructorDocTree; }