예제 #1
0
 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;
 }
예제 #2
0
  /**
   * 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;
  }
예제 #3
0
 /** 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;
 }