public static void readResultSet(BufferedReader in, SingleResultSetHolder srs) throws IOException { String line; while ((line = in.readLine()) != null) { line = line.trim(); if (line.startsWith("<test-desc>")) { int index = line.indexOf("<", 11); if (index < 0) { index = line.length(); } line = line.substring(11, index); srs.setDescription(line); } else if (line.startsWith("<sys-prop")) { String key = getStringAttribute(line, "key"); String val = getStringAttribute(line, "value"); if (key != null && val != null) { srs.setProperty(key, val); } } else if (line.startsWith("<test-date")) { srs.setStartTime(getLongAttribute(line, "start")); srs.setEndTime(getLongAttribute(line, "end")); } else if (line.startsWith("<result")) { int numreps = getIntAttribute(line, "num-reps"); int numunits = getIntAttribute(line, "num-units"); String name = getStringAttribute(line, "name"); if (numreps > 0 && numunits >= 0 && name != null) { ResultHolder rh = new ResultHolder(srs); rh.setName(name); rh.setReps(numreps); rh.setUnits(numunits); readResult(in, rh); srs.addResult(rh); } } else if (line.equals("</result-set>")) { break; } else { System.err.println("Unrecognized line in Result-Set: " + line); } } }
public static void readResults(BufferedReader in) throws IOException { String xmlver = in.readLine(); if (xmlver == null || !xmlver.startsWith("<?xml version=\"1.0\"")) { return; } while (true) { String rsline = in.readLine(); if (rsline == null) { break; } rsline = rsline.trim(); if (rsline.startsWith("<result-set version=")) { String title = getStringAttribute(rsline, "name"); if (title == null) { title = "No title"; } SingleResultSetHolder srs = new SingleResultSetHolder(); srs.setTitle(title); readResultSet(in, srs); addResultSet(srs); } } }