KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > scm > ChangeLogSet


1 package hudson.scm;
2
3 import hudson.MarkupText;
4 import hudson.Util;
5 import hudson.model.AbstractBuild;
6 import hudson.model.User;
7
8 import java.util.Collection JavaDoc;
9 import java.util.Collections JavaDoc;
10
11 /**
12  * Represents SCM change list.
13  *
14  * Use the "index" view of this object to render the changeset detail page,
15  * and use the "digest" view of this object to render the summary page.
16  *
17  * @author Kohsuke Kawaguchi
18  */

19 public abstract class ChangeLogSet<T extends ChangeLogSet.Entry> implements Iterable JavaDoc<T> {
20
21     /**
22      * {@link AbstractBuild} whose change log this object represents.
23      */

24     public final AbstractBuild<?,?> build;
25
26     protected ChangeLogSet(AbstractBuild<?, ?> build) {
27         this.build = build;
28     }
29
30     /**
31      * Returns true if there's no change.
32      */

33     public abstract boolean isEmptySet();
34
35     /**
36      * Constant instance that represents no changes.
37      */

38     public static ChangeLogSet<? extends ChangeLogSet.Entry> createEmpty(AbstractBuild build) {
39         return new CVSChangeLogSet(build,Collections.<CVSChangeLogSet.CVSChangeLog>emptyList());
40     }
41
42     public static abstract class Entry {
43         private ChangeLogSet parent;
44
45         public ChangeLogSet getParent() {
46             return parent;
47         }
48
49         /**
50          * Should be invoked before a {@link ChangeLogSet} is exposed to public.
51          */

52         protected void setParent(ChangeLogSet parent) {
53             this.parent = parent;
54         }
55
56         /**
57          * Gets the "commit message".
58          *
59          * <p>
60          * The exact definition depends on the individual SCM implementation.
61          *
62          * @return
63          * Can be empty but never null.
64          */

65         public abstract String JavaDoc getMsg();
66
67         /**
68          * The user who made this change.
69          *
70          * @return
71          * never null.
72          */

73         public abstract User getAuthor();
74
75         /**
76          * Returns a set of paths in the workspace that was
77          * affected by this change.
78          *
79          * <p>
80          * Contains string like 'foo/bar/zot'. No leading/trailing '/',
81          * and separator must be normalized to '/'.
82          *
83          * @return never null.
84          */

85         public abstract Collection JavaDoc<String JavaDoc> getAffectedPaths();
86
87         /**
88          * Gets the text fully marked up by {@link ChangeLogAnnotator}.
89          */

90         public String JavaDoc getMsgAnnotated() {
91             MarkupText markup = new MarkupText(getMsgEscaped());
92             for (ChangeLogAnnotator a : ChangeLogAnnotator.annotators)
93                 a.annotate(parent.build,this,markup);
94
95             return markup.toString();
96         }
97
98         /**
99          * Message escaped for HTML
100          */

101         public String JavaDoc getMsgEscaped() {
102             return Util.escape(getMsg());
103         }
104     }
105 }
106
Popular Tags