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

Last change on this file since 1436 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
RevLine 
[950]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>
[1276]21 * base class for all GUI element specifications in the context of HTML
[950]22 * </p>
23 *
24 * @author Patrick Harms
25 */
26public class HTMLGUIElementSpec implements IGUIElementSpec {
27
[1276]28    /**
29     * <p>
30     * default serial version UID
31     * </p>
32     */
[950]33    private static final long serialVersionUID = 1L;
34   
[1276]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     */
[950]41    private String type;
[1436]42
43    /**
44     * <p>
45     * the hashCode of this GUI element specification
46     * </p>
47     */
48    private int hashCode;
[950]49   
50    /**
51     * <p>
[1276]52     * instantiated the specification with the type, i.e., tag name of the represented GUI element
[950]53     * </p>
54     *
[1276]55     * @param type  the type, i.e., tag name of the represented GUI element
56     *
57     * @throws IllegalArgumentException if the provided type is null
[950]58     */
[1436]59    public HTMLGUIElementSpec(String type, int hashCode) {
[961]60        if (type == null) {
[950]61            throw new IllegalArgumentException("type must not be null");
62        }
[961]63
[950]64        this.type = type;
[1436]65        this.hashCode = hashCode;
[950]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;
[961]83            return type.equals(otherSpec.type);
[950]84        }
85       
86        return false;
87    }
88
[1276]89    /* (non-Javadoc)
90     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getTypeHierarchy()
[1054]91     */
[966]92    @Override
[990]93    public String[] getTypeHierarchy() {
94        return new String[] { type };
[966]95    }
96
[1436]97    /* (non-Javadoc)
98     * @see java.lang.Object#hashCode()
99     */
100    @Override
101    public int hashCode() {
102        return hashCode;
103    }
104
[950]105}
Note: See TracBrowser for help on using the repository browser.