01: package net.sourceforge.cruisecontrol.dashboard.saxhandler;
02:
03: import java.util.Map;
04:
05: import org.xml.sax.Attributes;
06: import org.xml.sax.SAXException;
07:
08: public class BasicInfoExtractor extends SAXBasedExtractor {
09:
10: private boolean readingInfo;
11:
12: private String projectName;
13:
14: private String label;
15:
16: public void startElement(String uri, String localName,
17: String qName, Attributes attributes) throws SAXException {
18: if ("info".equals(qName)) {
19: readingInfo = true;
20: return;
21: }
22: if (readingInfo && "property".equals(qName)) {
23: String propName = attributes.getValue("name");
24: if ("projectname".equals(propName)) {
25: projectName = attributes.getValue("value");
26: }
27: if ("label".equals(propName)) {
28: label = attributes.getValue("value");
29: }
30: }
31: }
32:
33: public void endElement(String uri, String localName, String qName)
34: throws SAXException {
35: if ("info".equals(qName)) {
36: readingInfo = false;
37: canStop(true);
38: }
39: }
40:
41: public void report(Map resultSet) {
42: resultSet.put("projectname", projectName);
43: resultSet.put("label", label);
44: }
45: }
|