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

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