source: trunk/autoquest-plugin-html/src/main/java/de/ugoe/cs/autoquest/plugin/html/guimodel/HTMLServerSpec.java @ 1264

Last change on this file since 1264 was 1264, checked in by pharms, 11 years ago
  • improved logging
File size: 2.7 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.html.guimodel;
16
17import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
18
19/**
20 * <p>
21 * TODO comment
22 * </p>
23 *
24 * @author Patrick Harms
25 */
26public class HTMLServerSpec extends HTMLGUIElementSpec implements IGUIElementSpec {
27
28    /**  */
29    private static final long serialVersionUID = 1L;
30   
31    /** */
32    private String host;
33   
34    /** */
35    private int port;
36
37    /**
38     * <p>
39     * TODO: comment
40     * </p>
41     *
42     * @param serverName
43     * @param port
44     */
45    public HTMLServerSpec(String host, int port) {
46        super("server");
47       
48        if (host == null) {
49            throw new IllegalArgumentException("host must not be null");
50        }
51       
52        if ((port < -1) || (port > 65536)) {
53            throw new IllegalArgumentException("port " + port + " is not a valid port");
54        }
55
56        this.host = host;
57        this.port = port;
58    }
59
60    /* (non-Javadoc)
61     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec)
62     */
63    @Override
64    public boolean getSimilarity(IGUIElementSpec other) {
65        if (other instanceof HTMLServerSpec) {
66            HTMLServerSpec otherSpec = (HTMLServerSpec) other;
67           
68            if (!super.getSimilarity(otherSpec)) {
69                return false;
70            }
71            else if (!host.equals(otherSpec.host)) {
72                return false;
73            }
74            else {
75                return (port == otherSpec.port);
76            }
77        }
78       
79        return false;
80    }
81
82    /* (non-Javadoc)
83     * @see java.lang.Object#toString()
84     */
85    @Override
86    public String toString() {
87        String str = "Server(" + getHost();
88
89        if (getPort() > -1 ) {
90            str += ":" + getPort();
91        }
92       
93        str += ")";
94        return str;
95    }
96
97    /**
98     * <p>
99     * TODO: comment
100     * </p>
101     *
102     * @return
103     */
104    String getHost() {
105        return this.host;
106    }
107
108    /**
109     * <p>
110     * TODO: comment
111     * </p>
112     *
113     * @return
114     */
115    int getPort() {
116        return this.port;
117    }
118
119}
Note: See TracBrowser for help on using the repository browser.