[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 | |
---|
| 15 | package de.ugoe.cs.autoquest.plugin.html.guimodel; |
---|
| 16 | |
---|
| 17 | import 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 | */ |
---|
| 26 | public 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; |
---|
| 42 | |
---|
| 43 | /** |
---|
| 44 | * <p> |
---|
[1276] | 45 | * instantiated the specification with the type, i.e., tag name of the represented GUI element |
---|
[950] | 46 | * </p> |
---|
| 47 | * |
---|
[1276] | 48 | * @param type the type, i.e., tag name of the represented GUI element |
---|
| 49 | * |
---|
| 50 | * @throws IllegalArgumentException if the provided type is null |
---|
[950] | 51 | */ |
---|
[1047] | 52 | public HTMLGUIElementSpec(String type) { |
---|
[961] | 53 | if (type == null) { |
---|
[950] | 54 | throw new IllegalArgumentException("type must not be null"); |
---|
| 55 | } |
---|
[961] | 56 | |
---|
[950] | 57 | this.type = type; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | /* (non-Javadoc) |
---|
| 61 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getType() |
---|
| 62 | */ |
---|
| 63 | @Override |
---|
| 64 | public String getType() { |
---|
| 65 | return type; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /* (non-Javadoc) |
---|
| 69 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getSimilarity(IGUIElementSpec) |
---|
| 70 | */ |
---|
| 71 | @Override |
---|
| 72 | public boolean getSimilarity(IGUIElementSpec other) { |
---|
| 73 | if (other instanceof HTMLGUIElementSpec) { |
---|
| 74 | HTMLGUIElementSpec otherSpec = (HTMLGUIElementSpec) other; |
---|
[961] | 75 | return type.equals(otherSpec.type); |
---|
[950] | 76 | } |
---|
| 77 | |
---|
| 78 | return false; |
---|
| 79 | } |
---|
| 80 | |
---|
[1276] | 81 | /* (non-Javadoc) |
---|
| 82 | * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec#getTypeHierarchy() |
---|
[1054] | 83 | */ |
---|
[966] | 84 | @Override |
---|
[990] | 85 | public String[] getTypeHierarchy() { |
---|
| 86 | return new String[] { type }; |
---|
[966] | 87 | } |
---|
| 88 | |
---|
[950] | 89 | } |
---|