FileDocCategorySizeDatePackage
CrossRef.javaAPI DocExample2597Tue Apr 08 16:01:44 BST 2003None

CrossRef

public 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. :-(
author
Ian Darwin, Ian@DarwinSys.com
version
$Id: CrossRef.java,v 1.16 2003/04/08 20:01:44 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
protected voiddoClass(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 voidendClass()
Print the end of a class. Unused in this version, designed to be overridden

	
public static voidmain(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 voidprintln(java.lang.String s)
Convenience routine, short for System.out.println

		System.out.println(s);
	
protected voidputField(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 voidputMethod(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 voidstartClass(java.lang.Class c)
Print the start of a class. Unused in this version, designed to be overridden