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

Last change on this file was 1561, checked in by pharms, 10 years ago
  • update of namespaces for HTTP logfiles
File size: 2.8 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.plugin.http.HTTPUtils;
19import de.ugoe.cs.autoquest.plugin.http.logdata.Address;
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#toString()
78     */
79    @Override
80    public String toString() {
81        return stringIdentifier;
82    }
83
84    /* (non-Javadoc)
85     * @see java.lang.Object#equals(java.lang.Object)
86     */
87    @Override
88    public boolean equals(Object obj) {
89        if (obj == this) {
90            return true;
91        }
92        else if (obj instanceof HTTPTarget) {
93            return stringIdentifier.equals(((HTTPTarget) obj).stringIdentifier);
94        }
95        else {
96            return false;
97        }
98    }
99
100    /* (non-Javadoc)
101     * @see java.lang.Object#hashCode()
102     */
103    @Override
104    public int hashCode() {
105        return stringIdentifier.hashCode();
106    }
107
108}
Note: See TracBrowser for help on using the repository browser.