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.html.guimodel; |
---|
16 | |
---|
17 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec; |
---|
18 | |
---|
19 | /** |
---|
20 | * <p> |
---|
21 | * TODO comment |
---|
22 | * </p> |
---|
23 | * |
---|
24 | * @author Patrick Harms |
---|
25 | */ |
---|
26 | public class HTMLDocumentSpec extends HTMLGUIElementSpec implements IGUIElementSpec { |
---|
27 | |
---|
28 | /** */ |
---|
29 | private static final long serialVersionUID = 1L; |
---|
30 | |
---|
31 | /** */ |
---|
32 | private HTMLServerSpec server; |
---|
33 | |
---|
34 | /** */ |
---|
35 | private String path; |
---|
36 | |
---|
37 | /** */ |
---|
38 | private String query; |
---|
39 | |
---|
40 | /** */ |
---|
41 | private String title; |
---|
42 | |
---|
43 | /** |
---|
44 | * <p> |
---|
45 | * TODO: comment |
---|
46 | * </p> |
---|
47 | * |
---|
48 | * @param server |
---|
49 | * @param pagePath |
---|
50 | * @param pageTitle |
---|
51 | */ |
---|
52 | public HTMLDocumentSpec(HTMLServerSpec server, String path, String query, String title) { |
---|
53 | super("document"); |
---|
54 | |
---|
55 | if (server == null) { |
---|
56 | throw new IllegalArgumentException("server must not be null"); |
---|
57 | } |
---|
58 | else if (path == null) { |
---|
59 | throw new IllegalArgumentException("pagePath must not be null"); |
---|
60 | } |
---|
61 | |
---|
62 | this.server = server; |
---|
63 | this.path = path; |
---|
64 | this.query = query; |
---|
65 | this.title = title; |
---|
66 | } |
---|
67 | |
---|
68 | /* (non-Javadoc) |
---|
69 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec) |
---|
70 | */ |
---|
71 | @Override |
---|
72 | public boolean getSimilarity(IGUIElementSpec other) { |
---|
73 | if (other instanceof HTMLDocumentSpec) { |
---|
74 | HTMLDocumentSpec otherSpec = (HTMLDocumentSpec) other; |
---|
75 | |
---|
76 | if (!super.getSimilarity(otherSpec)) { |
---|
77 | return false; |
---|
78 | } |
---|
79 | else if (!server.getSimilarity(otherSpec.server)) { |
---|
80 | return false; |
---|
81 | } |
---|
82 | else if (!path.equals(otherSpec.path)) { |
---|
83 | return false; |
---|
84 | } |
---|
85 | else if (query != null ? !query.equals(otherSpec.query) : otherSpec.query != null) { |
---|
86 | return false; |
---|
87 | } |
---|
88 | else { |
---|
89 | return (title != null ? title.equals(otherSpec.title) : otherSpec.title == null); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | return false; |
---|
94 | } |
---|
95 | |
---|
96 | /** |
---|
97 | * <p> |
---|
98 | * TODO: comment |
---|
99 | * </p> |
---|
100 | * |
---|
101 | * @return |
---|
102 | */ |
---|
103 | public HTMLServerSpec getServer() { |
---|
104 | return server; |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * <p> |
---|
109 | * TODO: comment |
---|
110 | * </p> |
---|
111 | * |
---|
112 | * @return |
---|
113 | */ |
---|
114 | String getPath() { |
---|
115 | return path; |
---|
116 | } |
---|
117 | |
---|
118 | /** |
---|
119 | * <p> |
---|
120 | * TODO: comment |
---|
121 | * </p> |
---|
122 | * |
---|
123 | * @return |
---|
124 | */ |
---|
125 | String getQuery() { |
---|
126 | return query; |
---|
127 | } |
---|
128 | |
---|
129 | /** |
---|
130 | * <p> |
---|
131 | * TODO: comment |
---|
132 | * </p> |
---|
133 | * |
---|
134 | * @return |
---|
135 | */ |
---|
136 | String getTitle() { |
---|
137 | return title; |
---|
138 | } |
---|
139 | |
---|
140 | } |
---|