/** * generates and returns the Javadoc for the specified start/end tag pair. * * @param index the index in the start/end tag array * @return the generated Javadoc * @throws Exception in case the generation fails */ protected String generateJavadoc(int index) throws Exception { String result; TechnicalInformationHandler handler; result = ""; if (!canInstantiateClass()) return result; if (!ClassDiscovery.hasInterface(TechnicalInformationHandler.class, getInstance().getClass())) throw new Exception("Class '" + getClassname() + "' is not a TechnicalInformationHandler!"); handler = (TechnicalInformationHandler) getInstance(); switch (index) { case 0: // plain text result = toHTML(handler.getTechnicalInformation().toString()) + "\n"; break; case 1: // bibtex // prolog? if (getProlog()) result = "BibTeX:\n"; result += "<pre>\n"; result += toHTML(handler.getTechnicalInformation().toBibTex()).replaceAll("<br/>", "") + "\n"; result += "</pre>\n<p/>\n"; break; } // stars? if (getUseStars()) result = indent(result, 1, "* "); return result; }
/** * Possible calls: * * <ul> * <li>weka.core.ClassDiscovery <packages><br> * Prints all the packages in the current classpath * <li>weka.core.ClassDiscovery <classname> <packagename(s)><br> * Prints the classes it found. * </ul> * * @param args the commandline arguments */ public static void main(String[] args) { Vector list; Vector packages; int i; StringTokenizer tok; if ((args.length == 1) && (args[0].equals("packages"))) { list = findPackages(); for (i = 0; i < list.size(); i++) System.out.println(list.get(i)); } else if (args.length == 2) { // packages packages = new Vector(); tok = new StringTokenizer(args[1], ","); while (tok.hasMoreTokens()) packages.add(tok.nextToken()); // search list = ClassDiscovery.find(args[0], (String[]) packages.toArray(new String[packages.size()])); // print result, if any System.out.println( "Searching for '" + args[0] + "' in '" + args[1] + "':\n" + " " + list.size() + " found."); for (i = 0; i < list.size(); i++) System.out.println(" " + (i + 1) + ". " + list.get(i)); } else { System.out.println("\nUsage:"); System.out.println(ClassDiscovery.class.getName() + " packages"); System.out.println("\tlists all packages in the classpath"); System.out.println(ClassDiscovery.class.getName() + " <classname> <packagename(s)>"); System.out.println("\tlists classes derived from/implementing 'classname' that"); System.out.println("\tcan be found in 'packagename(s)' (comma-separated list"); System.out.println(); System.exit(1); } }