source: trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/HTTPTarget.java @ 1383

Last change on this file since 1383 was 1383, checked in by pharms, 10 years ago
File size: 2.6 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.plugin.http.eventcore;
16
17import de.ugoe.cs.autoquest.eventcore.IEventTarget;
18import de.ugoe.cs.autoquest.httpmonitor.exchange.Address;
19import de.ugoe.cs.autoquest.plugin.http.HTTPUtils;
20
21/**
22 * <p>
23 * the event target for HTTP events. Holds a reference to the receiver address of the HTTP exchange
24 * recorded by the HTTP monitor.
25 * </p>
26 *
27 * @author Patrick Harms
28 */
29public class HTTPTarget implements IEventTarget {
30
31    /**  */
32    private static final long serialVersionUID = 1L;
33   
34    /**
35     * <p>
36     * the receiver address of the HTTP exchange
37     * </p>
38     */
39    private Address receiver;
40
41    /**
42     * <p>
43     * a string representing the receiver address of the HTTP exchange
44     * </p>
45     */
46    private String stringIdentifier;
47
48    /**
49     * <p>
50     * initializes the target with the receiver address of the HTTP exchange
51     * </p>
52     *
53     * @param receiver the receiver address of the HTTP exchange
54     */
55    public HTTPTarget(Address receiver) {
56        this.receiver = receiver;
57        this.stringIdentifier = HTTPUtils.toString(this.receiver);
58    }
59
60    /* (non-Javadoc)
61     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
62     */
63    @Override
64    public String getPlatform() {
65        return "HTTP";
66    }
67
68    /* (non-Javadoc)
69     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getStringIdentifier()
70     */
71    @Override
72    public String getStringIdentifier() {
73        return stringIdentifier;
74    }
75
76    /* (non-Javadoc)
77     * @see java.lang.Object#equals(java.lang.Object)
78     */
79    @Override
80    public boolean equals(Object obj) {
81        if (obj == this) {
82            return true;
83        }
84        else if (obj instanceof HTTPTarget) {
85            return stringIdentifier.equals(((HTTPTarget) obj).stringIdentifier);
86        }
87        else {
88            return false;
89        }
90    }
91
92    /* (non-Javadoc)
93     * @see java.lang.Object#hashCode()
94     */
95    @Override
96    public int hashCode() {
97        return stringIdentifier.hashCode();
98    }
99
100}
Note: See TracBrowser for help on using the repository browser.