[961] | 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 | */ |
---|
[1069] | 26 | public class HTMLDocumentSpec extends HTMLGUIElementSpec implements IGUIElementSpec { |
---|
[961] | 27 | |
---|
| 28 | /** */ |
---|
| 29 | private static final long serialVersionUID = 1L; |
---|
| 30 | |
---|
| 31 | /** */ |
---|
| 32 | private HTMLServerSpec server; |
---|
| 33 | |
---|
| 34 | /** */ |
---|
[1069] | 35 | private String path; |
---|
[961] | 36 | |
---|
| 37 | /** */ |
---|
[1069] | 38 | private String query; |
---|
[961] | 39 | |
---|
[1069] | 40 | /** */ |
---|
| 41 | private String title; |
---|
| 42 | |
---|
[961] | 43 | /** |
---|
| 44 | * <p> |
---|
| 45 | * TODO: comment |
---|
| 46 | * </p> |
---|
| 47 | * |
---|
| 48 | * @param server |
---|
| 49 | * @param pagePath |
---|
| 50 | * @param pageTitle |
---|
| 51 | */ |
---|
[1069] | 52 | public HTMLDocumentSpec(HTMLServerSpec server, String path, String query, String title) { |
---|
| 53 | super("document"); |
---|
[961] | 54 | |
---|
| 55 | if (server == null) { |
---|
| 56 | throw new IllegalArgumentException("server must not be null"); |
---|
| 57 | } |
---|
[1069] | 58 | else if (path == null) { |
---|
[961] | 59 | throw new IllegalArgumentException("pagePath must not be null"); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | this.server = server; |
---|
[1069] | 63 | this.path = path; |
---|
| 64 | this.query = query; |
---|
| 65 | this.title = title; |
---|
[961] | 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) { |
---|
[1069] | 73 | if (other instanceof HTMLDocumentSpec) { |
---|
| 74 | HTMLDocumentSpec otherSpec = (HTMLDocumentSpec) other; |
---|
[961] | 75 | |
---|
| 76 | if (!super.getSimilarity(otherSpec)) { |
---|
| 77 | return false; |
---|
| 78 | } |
---|
| 79 | else if (!server.getSimilarity(otherSpec.server)) { |
---|
| 80 | return false; |
---|
| 81 | } |
---|
[1069] | 82 | else if (!path.equals(otherSpec.path)) { |
---|
[961] | 83 | return false; |
---|
| 84 | } |
---|
[1069] | 85 | else if (query != null ? !query.equals(otherSpec.query) : otherSpec.query != null) { |
---|
| 86 | return false; |
---|
| 87 | } |
---|
[961] | 88 | else { |
---|
[1069] | 89 | return (title != null ? title.equals(otherSpec.title) : otherSpec.title == null); |
---|
[961] | 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 | */ |
---|
[1069] | 114 | String getPath() { |
---|
| 115 | return path; |
---|
[961] | 116 | } |
---|
| 117 | |
---|
| 118 | /** |
---|
| 119 | * <p> |
---|
| 120 | * TODO: comment |
---|
| 121 | * </p> |
---|
| 122 | * |
---|
| 123 | * @return |
---|
| 124 | */ |
---|
[1069] | 125 | String getQuery() { |
---|
| 126 | return query; |
---|
[961] | 127 | } |
---|
| 128 | |
---|
[1069] | 129 | /** |
---|
| 130 | * <p> |
---|
| 131 | * TODO: comment |
---|
| 132 | * </p> |
---|
| 133 | * |
---|
| 134 | * @return |
---|
| 135 | */ |
---|
| 136 | String getTitle() { |
---|
| 137 | return title; |
---|
| 138 | } |
---|
| 139 | |
---|
[961] | 140 | } |
---|