/** Convert to a CovReport-like signature - <classname>.<method>(). */ protected String getMethodSignature(ClassFile clazz, MethodInfo method) { StringBuffer buf = new StringBuffer(clazz.getFullName()); buf.append("."); buf.append(method.getName()); buf.append("()"); return buf.toString(); }
/** serialize a classfile into XML */ protected void serializeClass(ClassFile classFile) { // the class already is reported so ignore it String fullclassname = classFile.getFullName(); log("Looking for '" + fullclassname + "'"); Element clazz = (Element) classMap.get(fullclassname); // ignore classes that are already reported, all the information is // already there. if (clazz != null) { log("Ignoring " + fullclassname); removeAbstractMethods(classFile, clazz); return; } // ignore interfaces files, there is no code in there to cover. if (Utils.isInterface(classFile.getAccess())) { return; } Vector methods = getFilteredMethods(classFile); // no need to process, there are no methods to add for this class. if (methods.size() == 0) { return; } String pkgname = classFile.getPackage(); // System.out.println("Looking for package " + pkgname); Element pkgElem = (Element) pkgMap.get(pkgname); if (pkgElem == null) { pkgElem = createPackageElement(pkgname); report.getDocumentElement().appendChild(pkgElem); pkgMap.put(pkgname, pkgElem); // add the pkg to the map } // this is a brand new class, so we have to create a new node // create the class element Element classElem = createClassElement(classFile); pkgElem.appendChild(classElem); int total_lines = 0; int total_methods = 0; final int count = methods.size(); for (int i = 0; i < count; i++) { // create the method element MethodInfo method = (MethodInfo) methods.elementAt(i); if (Utils.isAbstract(method.getAccessFlags())) { continue; // no need to report abstract methods } Element methodElem = createMethodElement(method); classElem.appendChild(methodElem); total_lines += method.getNumberOfLines(); total_methods++; } // create the class cov.data element Element classData = getCovDataChild(classElem); classData.setAttribute("total_methods", String.valueOf(total_methods)); classData.setAttribute("total_lines", String.valueOf(total_lines)); // add itself to the node map classMap.put(fullclassname, classElem); }