[927] | 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 | |
---|
[857] | 15 | package de.ugoe.cs.autoquest.htmlmonitor; |
---|
| 16 | |
---|
| 17 | import java.net.URL; |
---|
| 18 | |
---|
| 19 | /** |
---|
| 20 | * <p> |
---|
[870] | 21 | * represents infos of a client together with a shown URL and its title |
---|
[857] | 22 | * </p> |
---|
| 23 | * |
---|
| 24 | * @author Patrick Harms |
---|
| 25 | */ |
---|
[871] | 26 | class HtmlClientInfos { |
---|
[857] | 27 | |
---|
| 28 | /** |
---|
[870] | 29 | * id of a client |
---|
[857] | 30 | */ |
---|
| 31 | private String clientId; |
---|
| 32 | |
---|
| 33 | /** |
---|
[870] | 34 | * browser used by the client |
---|
[857] | 35 | */ |
---|
| 36 | private String userAgent; |
---|
| 37 | |
---|
| 38 | /** |
---|
[870] | 39 | * URL of the web site shown by the browser of the client |
---|
[857] | 40 | */ |
---|
| 41 | private URL url; |
---|
| 42 | |
---|
| 43 | /** |
---|
[870] | 44 | * title of the web site shown by the browser of the client |
---|
[857] | 45 | */ |
---|
| 46 | private String title; |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * <p> |
---|
[870] | 50 | * instantiates an infos object with client id, browser at client side, the URL of the |
---|
| 51 | * shown website and its title. |
---|
[857] | 52 | * </p> |
---|
| 53 | * |
---|
[870] | 54 | * @param clientId id of a client |
---|
| 55 | * @param userAgent browser used by the client |
---|
| 56 | * @param url URL of the web site shown by the browser of the client |
---|
| 57 | * @param title title of the web site shown by the browser of the client |
---|
[857] | 58 | */ |
---|
[1019] | 59 | HtmlClientInfos(String clientId, String userAgent, URL url, String title) { |
---|
[857] | 60 | this.clientId = clientId; |
---|
| 61 | this.userAgent = userAgent; |
---|
| 62 | this.url = url; |
---|
| 63 | this.title = title; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * @return the clientId |
---|
| 68 | */ |
---|
| 69 | String getClientId() { |
---|
| 70 | return clientId; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * @return the userAgent |
---|
| 75 | */ |
---|
| 76 | String getUserAgent() { |
---|
| 77 | return userAgent; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * @return the url |
---|
| 82 | */ |
---|
| 83 | URL getUrl() { |
---|
| 84 | return url; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * @return the title |
---|
| 89 | */ |
---|
| 90 | String getTitle() { |
---|
| 91 | return title; |
---|
| 92 | } |
---|
| 93 | |
---|
[1227] | 94 | /** |
---|
| 95 | * @return the id of the monitored web application which is the host and port |
---|
| 96 | */ |
---|
| 97 | String getWebAppId() { |
---|
| 98 | String id = url.getHost(); |
---|
| 99 | if ("".equals(id)) { |
---|
| 100 | id = "unknown"; |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | if (url.getPort() > 0) { |
---|
| 104 | id += "_" + url.getPort(); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | return id; |
---|
| 108 | } |
---|
| 109 | |
---|
[857] | 110 | } |
---|