source: trunk/EventBenchCore/src/de/ugoe/cs/eventbench/data/ReplayableEvent.java @ 79

Last change on this file since 79 was 79, checked in by sherbold, 13 years ago
  • documentation
File size: 3.3 KB
Line 
1package de.ugoe.cs.eventbench.data;
2
3import java.util.LinkedList;
4import java.util.List;
5
6import de.ugoe.cs.eventbench.IReplayDecorator;
7
8/**
9 * <p>
10 * Subclass of {@link Event} for events that contain all informations required
11 * for replaying them, i.e., generating scripts that can used for automated
12 * software execution.
13 * </p>
14 *
15 * @author Steffen Herbold
16 * @version 1.0
17 *
18 * @param <T>
19 *            Allows only types that extend {@link IReplayable} and is used to
20 *            define a list of replayables that describe the replay of the
21 *            event.
22 */
23public class ReplayableEvent<T extends IReplayable> extends Event<T> {
24
25        /**
26         * <p>
27         * List of {@link IReplayable}s of type T that describes the replay of an
28         * event. The {@link IReplayable}s can be interpreted as <it>sub-events</it>
29         * on the platform level that make up the abstract event.
30         * </p>
31         */
32        private List<T> replayEvents = new LinkedList<T>();;
33
34        /**
35         * <p>
36         * Defines whether the replay is valid or invalid. It may be invalid, e.g.,
37         * due to errors during the generation of the event or lack of vital
38         * information.
39         * </p>
40         */
41        private boolean replayValid = true;
42
43        /**
44         * <p>
45         * {@link IReplayDecorator} used when replays of this type are written.
46         * </p>
47         */
48        private IReplayDecorator decorator = null;
49
50        /**
51         * <p>
52         * Constructor. Creates a new event with the given type.
53         * <p>
54         *
55         * @param type
56         *            type of the event
57         * @see Event#Event(String)
58         */
59        public ReplayableEvent(String type) {
60                super(type);
61        }
62
63        /**
64         * <p>
65         * Adds a new {@link IReplayable} of type T to the replay sequence.
66         * </p>
67         *
68         * @param replayable
69         *            element that is added to the sequence
70         */
71        public void addReplayEvent(T replayable) {
72                replayEvents.add(replayable);
73        }
74
75        /**
76         * <p>
77         * Adds a {@link List}ist of {@link IReplayable} to the replay sequence.
78         * </p>
79         *
80         * @param generatedReplaySeq
81         *            {@link List} that is added to the sequence
82         */
83        public void addReplaySequence(List<T> generatedReplaySeq) {
84                replayEvents.addAll(generatedReplaySeq);
85        }
86
87        /**
88         * <p>
89         * Returns the {@link IReplayDecorator} of the event.
90         * </p>
91         *
92         * @return {@link IReplayDecorator} of the event; null if no decorator has
93         *         been set
94         */
95        public IReplayDecorator getReplayDecorator() {
96                return decorator;
97        }
98
99        /**
100         * <p>
101         * Returns a the list of replay events.
102         * </p>
103         * <p>
104         * The return value is a copy of the list used internally!
105         * </p>
106         *
107         * @return list of replay events.
108         */
109        public List<T> getReplayMessages() {
110                return new LinkedList<T>(replayEvents);
111        }
112
113        /**
114         * <p>
115         * Returns whether the replay is valid or not.
116         * </p>
117         *
118         * @return true, if replay is valid; false otherwise.
119         */
120        public boolean hasValidReplay() {
121                return replayValid;
122        }
123
124        /**
125         * <p>
126         * Marks the replay as invalid. Once marked as invalid, it remains so and
127         * cannot be changed back to valid.
128         * </p>
129         */
130        public void invalidateReplay() {
131                replayValid = false;
132        }
133
134        /**
135         * <p>
136         * Sets the {@link IReplayDecorator} associated with the event.
137         * </p>
138         *
139         * @param decorator
140         *            decorator associated with the event
141         */
142        public void setDecorator(IReplayDecorator decorator) {
143                this.decorator = decorator;
144        }
145
146}
Note: See TracBrowser for help on using the repository browser.