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

Last change on this file since 1264 was 1264, checked in by pharms, 11 years ago
  • improved logging
File size: 3.4 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 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    /* (non-Javadoc)
97     * @see java.lang.Object#toString()
98     */
99    @Override
100    public String toString() {
101        return "Document(" + getPath() + ", \"" + getTitle() + "\")";
102    }
103
104    /**
105     * <p>
106     * TODO: comment
107     * </p>
108     *
109     * @return
110     */
111    public HTMLServerSpec getServer() {
112        return server;
113    }
114
115    /**
116     * <p>
117     * TODO: comment
118     * </p>
119     *
120     * @return
121     */
122    String getPath() {
123        return path;
124    }
125
126    /**
127     * <p>
128     * TODO: comment
129     * </p>
130     *
131     * @return
132     */
133    String getQuery() {
134        return query;
135    }
136
137    /**
138     * <p>
139     * TODO: comment
140     * </p>
141     *
142     * @return
143     */
144    String getTitle() {
145        return title;
146    }
147
148}
Note: See TracBrowser for help on using the repository browser.