01: package net.sourceforge.cruisecontrol;
02:
03: import net.sourceforge.cruisecontrol.listeners.ProgressChangedEvent;
04:
05: import java.io.Serializable;
06: import java.util.Date;
07:
08: /**
09: * Allow progress updates as projects are processed during various ProjectStates.
10: * @author Dan Rollo
11: * Date: Jul 20, 2007
12: * Time: 1:46:54 PM
13: */
14: public class ProgressImpl implements Progress {
15:
16: private static final long serialVersionUID = -660370539956160650L;
17:
18: /** The parent Project. */
19: private final Project project;
20:
21: /** current progress value. */
22: private Serializable val;
23:
24: private Date lastUpdated = new Date();
25:
26: ProgressImpl(final Project project) {
27: this .project = project;
28: }
29:
30: /** @param value new progress value. */
31: public void setValue(String value) {
32: val = value;
33: lastUpdated = new Date();
34: project.notifyListeners(new ProgressChangedEvent(project
35: .getName(), this ));
36: }
37:
38: /** @return current progress value represented as a String, prefixed with last update date. */
39: public String getValue() {
40: return DateFormatFactory.getTimeFormat().format(lastUpdated)
41: + " " + val;
42: }
43: }
|