本文整理汇总了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]);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}