source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/web/data/WebEvent.java @ 171

Last change on this file since 171 was 171, checked in by sherbold, 13 years ago
  • code documentation and formatting
  • Property svn:mime-type set to text/plain
File size: 2.0 KB
Line 
1package de.ugoe.cs.eventbench.web.data;
2
3import java.util.List;
4
5import de.ugoe.cs.eventbench.data.ReplayableEvent;
6
7/**
8 * <p>
9 * This class defines web events (of PHP-based web applications).
10 * </p>
11 *
12 * @author Steffen Herbold
13 * @version 1.0
14 *
15 */
16public class WebEvent extends ReplayableEvent<WebRequest> {
17
18        /**
19         * <p>
20         * Id for object serialization.
21         * </p>
22         */
23        private static final long serialVersionUID = 1L;
24
25        /**
26         * Timestamp of the event.
27         */
28        private final long timestamp;
29
30        /**
31         * <p>
32         * Helper method that generates the type of the event based on the of the
33         * URI, the POST variables, and the GET variables.
34         * </p>
35         *
36         * @param path
37         *            path of the URI of the event
38         * @param postVars
39         *            POST variables send with the event
40         * @param getVars
41         *            GET variables send with the event
42         * @return type of the event
43         */
44        private final static String makeType(String path, List<String> postVars,
45                        List<String> getVars) {
46                String type = path;
47                if (getVars != null && !getVars.isEmpty()) {
48                        type += "+GET" + getVars.toString().replace(" ", "");
49                }
50                if (postVars != null && !postVars.isEmpty()) {
51                        type += "+POST" + postVars.toString().replace(" ", "");
52                }
53                return type;
54        }
55
56        /**
57         * <p>
58         * Constructor. Creates a new WebEvent.
59         * </p>
60         *
61         * @param path
62         *            path of the URI
63         * @param timestamp
64         *            timestamp of when the event took place
65         * @param postVars
66         *            POST variables send with the event
67         * @param getVars
68         *            GET variables send with the event
69         */
70        public WebEvent(String path, long timestamp, List<String> postVars,
71                        List<String> getVars) {
72                super(makeType(path, postVars, getVars));
73                this.timestamp = timestamp;
74                addReplayEvent(new WebRequest(path, postVars, getVars));
75        }
76
77        /**
78         * <p>
79         * Returns the timestamp of the event.
80         * </p>
81         *
82         * @return timestamp of th event
83         */
84        public long getTimestamp() {
85                return timestamp;
86        }
87
88}
Note: See TracBrowser for help on using the repository browser.