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

Last change on this file since 231 was 231, checked in by sherbold, 13 years ago
  • the path of the URI is now used as target of de.ugoe.cs.eventbench.web.data.WebEvent?
  • Property svn:mime-type set to text/plain
File size: 2.1 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 url
62         *            URL of the server that received the event
63         * @param path
64         *            path of the URI
65         * @param timestamp
66         *            timestamp of when the event took place
67         * @param postVars
68         *            POST variables send with the event
69         * @param getVars
70         *            GET variables send with the event
71         */
72        public WebEvent(String url, String path, long timestamp,
73                        List<String> postVars, List<String> getVars) {
74                super(makeType(path, postVars, getVars));
75                this.timestamp = timestamp;
76                super.setTarget(path);
77                addReplayEvent(new WebRequest(url, path, postVars, getVars));
78        }
79
80        /**
81         * <p>
82         * Returns the timestamp of the event.
83         * </p>
84         *
85         * @return timestamp of th event
86         */
87        public long getTimestamp() {
88                return timestamp;
89        }
90
91}
Note: See TracBrowser for help on using the repository browser.