Over a million developers have joined DZone.

Eclipse PropertyTester Finder

·
// description of your code here
Prints all Eclipse Property Testers, as an HTML table. You have to specify the eclipse directory to search it.


public class PropertyTestFinder {

	static DocumentBuilder builder;

	public static void main(String[] args) throws Exception {

		if (args.length == 0 || !new File(args[0]).isDirectory()) {
			System.out.println("Usage Searcher ");
		} else {
			builder  = DocumentBuilderFactory.newInstance().newDocumentBuilder();
			String dir = args[0];
			System.out.println(""
					+ ""
					+ ""
					+ ""
					+ ""
					+ ""
					+ ""
					+ "");
			findString(new File(dir));
			System.out.println("
NamespacePropertiesTypeClassLocation
"); } } public static void findString(File dir) throws Exception { File[] files = dir.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) findString(file); else { if (!file.canRead()) { System.out.println("Can not read " + file); } else { if (file.getName().endsWith(".zip") || file.getName().endsWith(".jar")) { ZipInputStream zipIS = new ZipInputStream(new FileInputStream(file)); BufferedReader reader = new BufferedReader(new InputStreamReader(zipIS)); ZipEntry entry; try { while ((entry = zipIS.getNextEntry()) != null) { if (entry.getName().endsWith("plugin.xml")) { StringBuilder sb = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { sb.append(line + " "); } ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes()); Document doc = builder.parse(in); check(doc.getDocumentElement(), file.getName()); } } } catch (Exception ex) { ex.printStackTrace(); } zipIS.close(); } else { if (file.getName().endsWith("plugin.xml")) { Document doc = builder.parse(new FileInputStream(file)); check(doc.getDocumentElement(), file.getParentFile().getName()); } } } } } } } public static void check(Element element, String location) { if (element.getNodeName().equals("propertyTester")) { String type = element.getAttribute("type"); type = type.substring(type.lastIndexOf('.') + 1); String clazz = element.getAttribute("class"); clazz = clazz.substring(clazz.lastIndexOf('.') + 1); System.out.println("" + "" + element.getAttribute("namespace") + "" + "" + element.getAttribute("properties").replace(",", ", ") + "" + "" + type + "" + "" + clazz + "" + "" + location + "" + ""); } NodeList children = element.getChildNodes(); for (int i=0; i < children.getLength(); i++) { Node child = children.item(i); if (child instanceof Element) { check((Element) child, location); } } } }
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}