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

Last change on this file since 2146 was 2146, checked in by pharms, 7 years ago
  • refactored GUI model so that hierarchical event target structures can also be used and created by plugins not being strictly for GUIs
File size: 2.9 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.IEventTargetSpec;
18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
19
20/**
21 * <p>
22 * base class for all GUI element specifications in the context of HTML
23 * </p>
24 *
25 * @author Patrick Harms
26 */
27public class HTMLGUIElementSpec implements IGUIElementSpec {
28
29    /**
30     * <p>
31     * default serial version UID
32     * </p>
33     */
34    private static final long serialVersionUID = 1L;
35   
36    /**
37     * <p>
38     * the type of GUI element represented by this specification, which is usually the tag name of
39     * the HTML GUI element
40     * </p>
41     */
42    private String type;
43
44    /**
45     * <p>
46     * the hashCode of this GUI element specification
47     * </p>
48     */
49    private int hashCode;
50   
51    /**
52     * <p>
53     * instantiated the specification with the type, i.e., tag name of the represented GUI element
54     * </p>
55     *
56     * @param type  the type, i.e., tag name of the represented GUI element
57     *
58     * @throws IllegalArgumentException if the provided type is null
59     */
60    public HTMLGUIElementSpec(String type, int hashCode) {
61        if (type == null) {
62            throw new IllegalArgumentException("type must not be null");
63        }
64
65        this.type = type;
66        this.hashCode = hashCode;
67    }
68
69    /* (non-Javadoc)
70     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getType()
71     */
72    @Override
73    public String getType() {
74        return type;
75    }
76
77    /* (non-Javadoc)
78     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec)
79     */
80    @Override
81    public boolean getSimilarity(IEventTargetSpec other) {
82        if (other instanceof HTMLGUIElementSpec) {
83            HTMLGUIElementSpec otherSpec = (HTMLGUIElementSpec) other;
84            return type.equals(otherSpec.type);
85        }
86       
87        return false;
88    }
89
90    /* (non-Javadoc)
91     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getTypeHierarchy()
92     */
93    @Override
94    public String[] getTypeHierarchy() {
95        return new String[] { type };
96    }
97
98    /* (non-Javadoc)
99     * @see java.lang.Object#hashCode()
100     */
101    @Override
102    public int hashCode() {
103        return hashCode;
104    }
105
106}
Note: See TracBrowser for help on using the repository browser.