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

Last change on this file since 1069 was 1069, checked in by pharms, 11 years ago
  • support of new HTML logging format
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 HTMLPageElementSpec extends HTMLGUIElementSpec implements IGUIElementSpec {
27
28    /**  */
29    private static final long serialVersionUID = 1L;
30   
31    /** */
32    private HTMLDocumentSpec page;
33   
34    /** */
35    private String tagName;
36   
37    /** */
38    private String htmlId;
39   
40    /** */
41    private int index;
42
43    /**
44     * <p>
45     * TODO: comment
46     * </p>
47     *
48     * @param type
49     * @param index
50     * @param id
51     */
52    public HTMLPageElementSpec(HTMLDocumentSpec page, String tagName, String htmlId, int index) {
53        super(tagName);
54       
55        if (page == null) {
56            throw new IllegalArgumentException("page must not be null");
57        }
58        else if (tagName == null) {
59            throw new IllegalArgumentException("tag must not be null");
60        }
61        else if ((htmlId == null) && (index < 0)) {
62            throw new IllegalArgumentException
63                ("either id must not be null or the index must be greater or equal to 0");
64        }
65       
66        this.page = page;
67        this.tagName = tagName;
68        this.htmlId = htmlId;
69        this.index = index;
70    }
71
72    /* (non-Javadoc)
73     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec)
74     */
75    @Override
76    public boolean getSimilarity(IGUIElementSpec other) {
77        if (other instanceof HTMLPageElementSpec) {
78            HTMLPageElementSpec otherSpec = (HTMLPageElementSpec) other;
79           
80            if (!super.getSimilarity(otherSpec)) {
81                return false;
82            }
83            else if (!page.getSimilarity(otherSpec.page)) {
84                return false;
85            }
86            else if (!tagName.equals(otherSpec.tagName)) {
87                return false;
88            }
89           
90            if (htmlId != null) {
91                return htmlId.equals(otherSpec.htmlId);
92            }
93            else if (index >= 0) {
94                return index == otherSpec.index;
95            }
96        }
97       
98        return false;
99    }
100
101    /**
102     * <p>
103     * TODO: comment
104     * </p>
105     *
106     * @return
107     */
108    HTMLDocumentSpec getPage() {
109        return page;
110    }
111
112    /**
113     * <p>
114     * TODO: comment
115     * </p>
116     *
117     * @return
118     */
119    String getTagName() {
120        return tagName;
121    }
122
123    /**
124     * <p>
125     * TODO: comment
126     * </p>
127     *
128     * @return
129     */
130    String getHtmlId() {
131        return htmlId;
132    }
133
134    /**
135     * <p>
136     * TODO: comment
137     * </p>
138     *
139     * @return
140     */
141    int getIndex() {
142        return index;
143    }
144
145}
Note: See TracBrowser for help on using the repository browser.