KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > scm > SubversionChangeLogParser


1 package hudson.scm;
2
3 import hudson.model.AbstractBuild;
4 import hudson.scm.SubversionChangeLogSet.LogEntry;
5 import hudson.scm.SubversionChangeLogSet.Path;
6 import hudson.util.IOException2;
7 import org.apache.commons.digester.Digester;
8 import org.xml.sax.SAXException JavaDoc;
9
10 import java.io.File JavaDoc;
11 import java.io.IOException JavaDoc;
12 import java.util.ArrayList JavaDoc;
13
14 /**
15  * {@link ChangeLogParser} for Subversion.
16  *
17  * @author Kohsuke Kawaguchi
18  */

19 public class SubversionChangeLogParser extends ChangeLogParser {
20     public SubversionChangeLogSet parse(AbstractBuild build, File JavaDoc changelogFile) throws IOException JavaDoc, SAXException JavaDoc {
21         // http://svn.collab.net/repos/svn/trunk/subversion/svn/schema/
22

23         Digester digester = new Digester();
24         ArrayList JavaDoc<LogEntry> r = new ArrayList JavaDoc<LogEntry>();
25         digester.push(r);
26
27         digester.addObjectCreate("*/logentry", LogEntry.class);
28         digester.addSetProperties("*/logentry");
29         digester.addBeanPropertySetter("*/logentry/author","user");
30         digester.addBeanPropertySetter("*/logentry/date");
31         digester.addBeanPropertySetter("*/logentry/msg");
32         digester.addSetNext("*/logentry","add");
33
34         digester.addObjectCreate("*/logentry/paths/path", Path.class);
35         digester.addSetProperties("*/logentry/paths/path");
36         digester.addBeanPropertySetter("*/logentry/paths/path","value");
37         digester.addSetNext("*/logentry/paths/path","addPath");
38
39         try {
40             digester.parse(changelogFile);
41         } catch (IOException JavaDoc e) {
42             throw new IOException2("Failed to parse "+changelogFile,e);
43         } catch (SAXException JavaDoc e) {
44             throw new IOException2("Failed to parse "+changelogFile,e);
45         }
46
47         return new SubversionChangeLogSet(build,r);
48     }
49
50 }
51
Popular Tags