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

Last change on this file since 1276 was 1276, checked in by pharms, 11 years ago
  • added some Java Docs
File size: 4.6 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 * a GUI element specification of an HTML document, i.e., a page on an HTML server. This is the
22 * element for a GUI model of an HTML web site being always and only the children of servers. It
23 * is identified through the server on which it resists, its path, a potential query, and a title.
24 * Its children are HTML page elements
25 * </p>
26 *
27 * @author Patrick Harms
28 */
29public class HTMLDocumentSpec extends HTMLGUIElementSpec implements IGUIElementSpec {
30
31    /**
32     * <p>
33     * default serial version UID
34     * </p>
35     */
36    private static final long serialVersionUID = 1L;
37   
38    /**
39     * <p>
40     * the server on which the document resists
41     * </p>
42     */
43    private HTMLServerSpec server;
44   
45    /**
46     * <p>
47     * the path in the URL of the document
48     * </p>
49     */
50    private String path;
51   
52    /**
53     * <p>
54     * the query in the URL of the document
55     * </p>
56     */
57    private String query;
58   
59    /**
60     * <p>
61     * the title of the document
62     * </p>
63     */
64    private String title;
65   
66    /**
67     * <p>
68     * initializes the document with its server, path, query, and title
69     * </p>
70     *
71     * @param server the server on which the document resists
72     * @param path   the path in the URL of the document
73     * @param query  the query in the URL of the document
74     * @param title  the title of the document
75     *
76     * @throws IllegalArgumentException if the server or path are invalid, i.e. null
77     */
78    public HTMLDocumentSpec(HTMLServerSpec server, String path, String query, String title) {
79        super("document");
80       
81        if (server == null) {
82            throw new IllegalArgumentException("server must not be null");
83        }
84        else if (path == null) {
85            throw new IllegalArgumentException("pagePath must not be null");
86        }
87       
88        this.server = server;
89        this.path = path;
90        this.query = query;
91        this.title = title;
92    }
93
94    /* (non-Javadoc)
95     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec)
96     */
97    @Override
98    public boolean getSimilarity(IGUIElementSpec other) {
99        if (other instanceof HTMLDocumentSpec) {
100            HTMLDocumentSpec otherSpec = (HTMLDocumentSpec) other;
101           
102            if (!super.getSimilarity(otherSpec)) {
103                return false;
104            }
105            else if (!server.getSimilarity(otherSpec.server)) {
106                return false;
107            }
108            else if (!path.equals(otherSpec.path)) {
109                return false;
110            }
111            else if (query != null ? !query.equals(otherSpec.query) : otherSpec.query != null) {
112                return false;
113            }
114            else {
115                return (title != null ? title.equals(otherSpec.title) : otherSpec.title == null);
116            }
117        }
118       
119        return false;
120    }
121
122    /* (non-Javadoc)
123     * @see java.lang.Object#toString()
124     */
125    @Override
126    public String toString() {
127        return "Document(" + getPath() + ", \"" + getTitle() + "\")";
128    }
129
130    /**
131     * <p>
132     * returns the server on which the document resists
133     * </p>
134     *
135     * @return the server on which the document resists
136     */
137    public HTMLServerSpec getServer() {
138        return server;
139    }
140
141    /**
142     * <p>
143     * returns the path in the URL of the document
144     * </p>
145     *
146     * @return the path in the URL of the document
147     */
148    String getPath() {
149        return path;
150    }
151
152    /**
153     * <p>
154     * returns the query in the URL of the document
155     * </p>
156     *
157     * @return the query in the URL of the document
158     */
159    String getQuery() {
160        return query;
161    }
162
163    /**
164     * <p>
165     * returns the title of the document
166     * </p>
167     *
168     * @return the title of the document
169     */
170    String getTitle() {
171        return title;
172    }
173
174}
Note: See TracBrowser for help on using the repository browser.