@@ -0,0 +1,1601 @@
+package pete.metrics.adaptability;%0A%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport java.nio.charset.Charset;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.util.HashMap;%0Aimport java.util.concurrent.atomic.AtomicInteger;%0A%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.NodeList;%0A%0Apublic class ElementCounter %7B%0A%0A%09private HashMap%3CString, AtomicInteger%3E elements;%0A%0A%09private boolean elementsOnly;%0A%0A%09public ElementCounter(boolean elementsOnly) %7B%0A%09%09elements = new HashMap%3CString, AtomicInteger%3E();%0A%09%09this.elementsOnly = elementsOnly;%0A%09%7D%0A%0A%09public void addToCounts(Node node) %7B%0A%09%09addToMap(node);%0A%0A%09%09NodeList children = node.getChildNodes();%0A%09%09if (children != null) %7B%0A%09%09%09for (int i = 0; i %3C children.getLength(); i++) %7B%0A%09%09%09%09addToCounts(children.item(i));%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09private void addToMap(Node node) %7B%0A%09%09if (elementsOnly && node.getNodeType() != Node.ELEMENT_NODE) %7B%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09String nodeName = node.getLocalName();%0A%09%09if (elements.containsKey(nodeName)) %7B%0A%09%09%09AtomicInteger count = elements.get(nodeName);%0A%09%09%09count.incrementAndGet();%0A%09%09%7D else %7B%0A%09%09%09elements.put(nodeName, new AtomicInteger(1));%0A%09%09%7D%0A%09%7D%0A%0A%09public void clear() %7B%0A%09%09elements = new HashMap%3CString, AtomicInteger%3E();%0A%09%7D%0A%0A%09public void writeToCsv(Path file) %7B%0A%09%09try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(file,%0A%09%09%09%09Charset.defaultCharset()))) %7B%0A%09%09%09writer.println(%22element;number%22);%0A%09%09%09for (String key : elements.keySet()) %7B%0A%09%09%09%09AtomicInteger value = elements.get(key);%0A%09%09%09%09writer.println(key + %22;%22 + value);%0A%09%09%09%7D%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09System.err.println(e.getMessage());%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add missing class ElementCounter