Javadoc API: How far are varargs supported?
I want to write my custom doclet. I don't want to read some existing javadoc that is made with the standard doclet.
I am having problems to figure out how I can query the Javadoc API whether a formal parameter is a varargs paramter. For example if I have the following method:
public static void main(String... args) {
}
How can I determine that the formal parameter args is varargs? I have looked into com.sun.javadoc.Type. But was not able to figure out how to access the information.
Bye
PS: Reflection doesn't help, since reflection is not available inside a doclet I guess. In a doclet you have for example the MethodDoc reflected class, whereas in reflection you have the Method class.
Found it, its an attribute of the MethodDoc super class:
public interface ExecutableMemberDoc {
public boolean isVarArgs();
// Return true if this method was declared to
// take a variable number of arguments.
}
To make it work you have to put the following static (sic!)
method and return value into your doclet class:
public static LanguageVersion languageVersion() {
return LanguageVersion.JAVA_1_5;
}
Oki Doki. Case closed.
I think javadoc API clearly shows if argument is varargs.
Check below APi
http://docs.oracle.com/javase/1.5.0/docs/api/java/io/PrintStream.html
It has a method as given below with varargs
format(Locale l, String format, Object... args )
链接地址: http://www.djcxy.com/p/8850.html上一篇: 在Java中将方法标记为纯函数的惯例