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