CrossRefpublic class CrossRef extends APIFormatter CrossRef prints a cross-reference about all classes named in argv.
For each class, all public fields and methods are listed.
"Reflectance" is used to look up the information.
It is expected that the output will be post-processed e.g.,
with sort and awk/perl. Try:
java CrossRef |
uniq | # squeeze out polymorphic forms early
sort | awk '$2=="method" { ... }' > crossref-methods.txt
The part in "{ ... }" is left as an exercise for the reader. :-( |
Methods Summary |
---|
protected void | doClass(java.lang.Class c)Print the fields and methods of one class.
int i, mods;
startClass(c);
try {
Field[] fields = c.getDeclaredFields();
Arrays.sort(fields, new Comparator() {
public int compare(Object o1, Object o2) {
return ((Field)o1).getName().compareTo(((Field)o2).getName());
}
});
for (i = 0; i < fields.length; i++) {
Field field = (Field)fields[i];
if (!Modifier.isPrivate(field.getModifiers()))
putField(field, c);
// else System.err.println("private field ignored: " + field);
}
Method methods[] = c.getDeclaredMethods();
// Arrays.sort(methods);
for (i = 0; i < methods.length; i++) {
if (!Modifier.isPrivate(methods[i].getModifiers()))
putMethod(methods[i], c);
// else System.err.println("pvt: " + methods[i]);
}
} catch (Exception e) {
e.printStackTrace();
}
endClass();
| protected void | endClass()Print the end of a class. Unused in this version,
designed to be overridden
| public static void | main(java.lang.String[] argv)Simple main program, construct self, process each .ZIP file
found in CLASSPATH or in argv.
CrossRef xref = new CrossRef();
xref.doArgs(argv);
| protected final void | println(java.lang.String s)Convenience routine, short for System.out.println
System.out.println(s);
| protected void | putField(java.lang.reflect.Field fld, java.lang.Class c)put a Field's information to the standard output.
println(fld.getName() + " field " + c.getName() + " ");
| protected void | putMethod(java.lang.reflect.Method method, java.lang.Class c)put a Method's information to the standard output.
String methName = method.getName();
println(methName + " method " + c.getName() + " ");
| protected void | startClass(java.lang.Class c)Print the start of a class. Unused in this version,
designed to be overridden
|
|