[1367] | 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 | |
---|
| 15 | package de.ugoe.cs.autoquest.plugin.http.eventcore; |
---|
| 16 | |
---|
| 17 | import de.ugoe.cs.autoquest.eventcore.IEventTarget; |
---|
| 18 | import de.ugoe.cs.autoquest.plugin.http.HTTPUtils; |
---|
[1561] | 19 | import de.ugoe.cs.autoquest.plugin.http.logdata.Address; |
---|
[1367] | 20 | |
---|
| 21 | /** |
---|
| 22 | * <p> |
---|
[1383] | 23 | * the event target for HTTP events. Holds a reference to the receiver address of the HTTP exchange |
---|
| 24 | * recorded by the HTTP monitor. |
---|
[1367] | 25 | * </p> |
---|
| 26 | * |
---|
| 27 | * @author Patrick Harms |
---|
| 28 | */ |
---|
| 29 | public class HTTPTarget implements IEventTarget { |
---|
| 30 | |
---|
| 31 | /** */ |
---|
| 32 | private static final long serialVersionUID = 1L; |
---|
| 33 | |
---|
[1383] | 34 | /** |
---|
| 35 | * <p> |
---|
| 36 | * the receiver address of the HTTP exchange |
---|
| 37 | * </p> |
---|
| 38 | */ |
---|
[1367] | 39 | private Address receiver; |
---|
| 40 | |
---|
[1383] | 41 | /** |
---|
| 42 | * <p> |
---|
| 43 | * a string representing the receiver address of the HTTP exchange |
---|
| 44 | * </p> |
---|
| 45 | */ |
---|
[1367] | 46 | private String stringIdentifier; |
---|
| 47 | |
---|
| 48 | /** |
---|
[1383] | 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 |
---|
[1367] | 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) |
---|
[1417] | 77 | * @see java.lang.Object#toString() |
---|
| 78 | */ |
---|
| 79 | @Override |
---|
| 80 | public String toString() { |
---|
| 81 | return stringIdentifier; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | /* (non-Javadoc) |
---|
[1367] | 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 | } |
---|