當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodDoc.parameters方法代碼示例

本文整理匯總了Java中com.sun.javadoc.MethodDoc.parameters方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodDoc.parameters方法的具體用法?Java MethodDoc.parameters怎麽用?Java MethodDoc.parameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sun.javadoc.MethodDoc的用法示例。


在下文中一共展示了MethodDoc.parameters方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTestMethods

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
/**
 * Returns an array containing all of the "test" methods (including those that are inherited) for
 * the given class.
 */
private static MethodDoc[] getTestMethods(ClassDoc c) {
  Set set = new TreeSet();
  while (c != null) {
    MethodDoc[] methods = c.methods();
    for (int i = 0; i < methods.length; i++) {
      MethodDoc method = methods[i];
      if (method.isPublic() && method.parameters().length == 0
          && method.name().startsWith("test")) {
        set.add(method);
      }
    }

    c = c.superclass();
  }

  return (MethodDoc[]) set.toArray(new MethodDoc[0]);
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:22,代碼來源:UnitTestDoclet.java

示例2: foundMethod

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
private boolean foundMethod(ClassDoc clazz, boolean include,
        String methodName, int parameterCount) {
    if (include) {
        for (MethodDoc m : clazz.methods()) {
            if (m.name().equals(methodName)
                    && m.parameters().length == parameterCount) {
                return true;
            }
        }
    }
    for (ClassDoc doc : clazz.interfaces()) {
        if (foundMethod(doc, true, methodName, parameterCount)) {
            return true;
        }
    }
    clazz = clazz.superclass();
    return clazz != null
            && foundMethod(clazz, true, methodName, parameterCount);
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:20,代碼來源:Doclet.java

示例3: getPropName

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
protected static String getPropName(MethodDoc m, boolean includeSetters) {
    if (m.parameters().length > 0) {
        return null;
    }
    if (m.name().startsWith("get") && m.name().length() > 3) {
        if (m.returnType().typeName().equals(Void.TYPE.getName())) {
            return null;
        }
        return m.name().substring(3, 4).toLowerCase() + m.name().substring(4);
    }
    if (m.name().startsWith("is") && m.name().length() > 2) {
        if (m.returnType().typeName().equals(Boolean.TYPE.getName())) {
            return null;
        }
        return m.name().substring(2, 3).toLowerCase() + m.name().substring(3);
    }
    if (includeSetters && m.name().startsWith("set") && m.name().length() > 3) {
        if (!m.returnType().typeName().equals(Void.TYPE.getName())
                || m.parameters().length != 1) {
            return null;
        }
        return m.name().substring(3, 4).toLowerCase() + m.name().substring(4);
    }
    return null;
}
 
開發者ID:teamfx,項目名稱:openjfx-8u-dev-tests,代碼行數:26,代碼來源:Template.java

示例4: start

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
public static boolean start(RootDoc root) {
  ClassDoc[] classes = root.classes();
  for (int i = 0; i < classes.length; i++) {
    System.out.println(classes[i]);
    ClassDoc classdoc = classes[i];
    String x = classdoc.getRawCommentText();
    System.out.println(x);
    MethodDoc[] methods = classes[i].methods();
    for (int j = 0; j < methods.length; j++) {
      MethodDoc m = methods[j];
      System.out.println(m.getRawCommentText());
      if (m.isPublic()) {
        System.out.println("\t" + m.name());
        Parameter[] parameters = m.parameters();
        for (int k = 0; k < parameters.length; k++) {
          Parameter p = parameters[k];
          System.out.println("\t\t" + p.name() + ": " + p.type().qualifiedTypeName());
        }
      }
    }
  }
  return true;
}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:24,代碼來源:ListMethodsDoclet.java

示例5: extractQueryParams

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
private void extractQueryParams(MethodDoc method, RestMethod restMethod)
{
  Parameter[] params = method.parameters();
  for (Parameter param : params)
  {
    AnnotationDesc queryParamAnnotation = getAnnotation(param.annotations(), "QueryParam");

    if (queryParamAnnotation != null)
    {
      RestDocItem di = new RestDocItem();

      di.setName(stripQuotes(queryParamAnnotation.elementValues()[0].value().toString()));
      di.setComment(getParamComment(method.paramTags(), param.name()));

      restMethod.getQueryParams().add(di);
    }
  }
}
 
開發者ID:rabidgremlin,項目名稱:JerseyDoc,代碼行數:19,代碼來源:DocGenerator.java

示例6: extractPathParams

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
private void extractPathParams(MethodDoc method, RestMethod restMethod)
{
  Parameter[] params = method.parameters();
  for (Parameter param : params)
  {
    AnnotationDesc queryParamAnnotation = getAnnotation(param.annotations(), "PathParam");

    if (queryParamAnnotation != null)
    {
      RestDocItem di = new RestDocItem();

      di.setName(stripQuotes(queryParamAnnotation.elementValues()[0].value().toString()));
      di.setComment(getParamComment(method.paramTags(), param.name()));

      restMethod.getPathParams().add(di);
    }
  }
}
 
開發者ID:rabidgremlin,項目名稱:JerseyDoc,代碼行數:19,代碼來源:DocGenerator.java

示例7: PSOperatorDoc

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
private PSOperatorDoc(ClassDoc classDoc, MethodDoc methodDoc) {
        this.declaringClassDoc = classDoc;
        this.methodDoc = methodDoc;
        this.description = methodDoc.commentText().replace('\n', ' ');
        this.paramDesc = "";

        Tag[] paramTags = methodDoc.tags("param");
        for (Tag paramTag : paramTags) {
            String paraStr = paramTag.text();
            String paraName = paraStr.substring(0, paraStr.indexOf(' ')).replace('\n', ' ');;
            String paraDesc = paraStr.substring(paraStr.indexOf(' ') + 1).replace('\n', ' ');;
            this.paramDesc += "<br> - `" + paraName + "`: " + paraDesc;
        }

        this.returnType = methodDoc.returnType();
//        ParameterizedType returnType = methodDoc.returnType().asParameterizedType();
//        this.inputType = returnType.typeArguments()[0];
//        this.outputType = returnType.typeArguments()[1];
//        this.completeSignature = "Function<" + this.inputType + ", " + this.outputType + "> " + methodDoc.toString();

        String shortSignature = classDoc.name() + "." + methodDoc.name() + "(";
        boolean firstParameter = true;
        for (Parameter parameter : methodDoc.parameters()) {
            if (firstParameter) {
                shortSignature += Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
                firstParameter = false;
            } else {
                shortSignature += ", " + Utils.getSimpleTypeName(parameter.type()) + " " + parameter.name();
            }
        }
        shortSignature += ")";
        this.shortSignature = shortSignature;
    }
 
開發者ID:PrivacyStreams,項目名稱:PrivacyStreams,代碼行數:34,代碼來源:PSOperatorDoc.java

示例8: isGetterMethod

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
protected boolean isGetterMethod(MethodDoc methodDoc) {
	if (methodDoc.parameters() != null && methodDoc.parameters().length == 0
			&& (!"boolean".equalsIgnoreCase(methodDoc.returnType().qualifiedTypeName())
					&& methodDoc.name().matches("^get.+"))
			|| (("boolean".equalsIgnoreCase(methodDoc.returnType().qualifiedTypeName())
					&& methodDoc.name().matches("^is.+")))) {
		return true;
	}
	return false;
}
 
開發者ID:WinRoad-NET,項目名稱:wrdocletbase,代碼行數:11,代碼來源:AbstractDocBuilder.java

示例9: isSetterMethod

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
protected boolean isSetterMethod(MethodDoc methodDoc) {
	if (methodDoc.parameters() != null && methodDoc.parameters().length == 1
			&& methodDoc.name().matches("^set.+")) {
		return true;
	}
	return false;
}
 
開發者ID:WinRoad-NET,項目名稱:wrdocletbase,代碼行數:8,代碼來源:AbstractDocBuilder.java

示例10: methodDescriptorOf

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
/**
 * Returns the method descriptor for the specified method.
 *
 * See section 4.3.3 of The Java Virtual Machine Specification
 * Second Edition for the definition of a "method descriptor".
 **/
static String methodDescriptorOf(MethodDoc method) {
    String desc = "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        desc += typeDescriptorOf(parameters[i].type());
    }
    desc += ")" + typeDescriptorOf(method.returnType());
    return desc;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:Util.java

示例11: getFriendlyUnqualifiedSignature

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:Util.java

示例12: paramTypes

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
/**
 * 獲取指定方法的所有入參類型,便於反射
 *
 * @param methodDoc
 * @return
 * @throws ClassNotFoundException
 */
private static Class[] paramTypes(MethodDoc methodDoc) throws ClassNotFoundException {
    Parameter[] parameters = methodDoc.parameters();
    Class[] types = new Class[parameters.length];
    for (int i = 0; i < parameters.length; i++) {
        String className = parameters[i].type().qualifiedTypeName();
        types[i] = ClassUtils.toBae(className);
        if (types[i] == null) {
            types[i] = Class.forName(className);
        }
    }
    return types;
}
 
開發者ID:treeleafj,項目名稱:xDoc,代碼行數:20,代碼來源:SunDocHandler.java

示例13: getInheritedParamTags

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
/**
 * Resolve inherited @param tags.
 *
 * This method compiles a list of param tags for each of the given methodDoc's parameters.
 * If a paramTag is missing from the given methodDoc, it is searched for in the method's
 * inheritance chain.
 * 
 * @return a list of @param tags for the given methodDoc, some of which may be inherited.
 */
protected List<ParamTag> getInheritedParamTags(MethodDoc methodDoc, MethodDoc specifiedByMethodDoc) {

    List<ParamTag> retMe = new ArrayList<ParamTag>();

    for ( Parameter parameter : methodDoc.parameters() ) {
        
        ParamTag paramTag = getInheritedParamTag( methodDoc, parameter.name(), specifiedByMethodDoc);
        if (paramTag != null) {
            retMe.add( paramTag );
        } 
    }
    
    return retMe;
}
 
開發者ID:rob4lderman,項目名稱:javadoc-json-doclet,代碼行數:24,代碼來源:JsonDoclet.java

示例14: start

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
public static boolean start(RootDoc root) throws IOException {
    parseOptions(root.options());
    ResourceInfo resourceInfo = new ResourceInfo();
    for (ClassDoc clazz : root.classes()) {
        Resource resource = null;
        for (MethodDoc method : clazz.methods()) {
            if (getAnnotation(method, "org.apache.axis2.transport.testkit.tests.Setup") != null) {
                if (resource == null) {
                    resource = new Resource(clazz.qualifiedName());
                }
                ParamTag[] paramTags = method.paramTags();
                for (Parameter parameter : method.parameters()) {
                    Type type = parameter.type();
                    String name = parameter.name();
                    String comment = null;
                    for (ParamTag paramTag : paramTags) {
                        if (paramTag.parameterName().equals(name)) {
                            comment = paramTag.parameterComment();
                            break;
                        }
                    }
                    if (comment == null) {
                        comment = getFirstSentence(root.classNamed(type.qualifiedTypeName()));
                    }
                    resource.addDependency(type.qualifiedTypeName(),
                                           type.dimension().equals("[]") ? "0..*" : "1", 
                                           comment);
                }
            }
        }
        if (resource != null) {
            resourceInfo.addResource(resource);
        }
    }
    ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(outFile));
    out.writeObject(resourceInfo);
    out.close();
    return true;
}
 
開發者ID:wso2,項目名稱:wso2-axis2-transports,代碼行數:40,代碼來源:ResourceInfoDoclet.java

示例15: getAbbrParams

import com.sun.javadoc.MethodDoc; //導入方法依賴的package包/類
/**
 * Gets the abbreviated form of the parameters type of given method.
 *
 * @param doc
 * @return In the parameter declared order returns the begin letter of the
 * parameters types. For example for method foo(String, int, float) the
 * result would be "sif"
 */
private static String getAbbrParams(MethodDoc doc) {
    //the following method returns parameters in the declared order (otherwise, there would be no chance to have it unique)
    com.sun.javadoc.Parameter[] params = doc.parameters();
    String abbrParams = "";

    for (int i = 0; i < params.length; i++) {
        switch (params[i].typeName()) {
            case "int":
                abbrParams += "@int";
                break;
            case "double":
                abbrParams += "@double";
                break;
            case "float":
                abbrParams += "@float";
                break;
            case "String":
                abbrParams += "@java.lang.String";
                break;
            default:
                //enum situation
                abbrParams += "@" + params[i].type().toString();
                break;
        }
    }

    return abbrParams;
}
 
開發者ID:arahusky,項目名稱:performance_javadoc,代碼行數:37,代碼來源:PerformanceNamingUtils.java


注:本文中的com.sun.javadoc.MethodDoc.parameters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。