source: trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/plugin/android/guimodel/ANDROIDGUIElement.java @ 1869

Last change on this file since 1869 was 1869, checked in by funger, 9 years ago
  • clean up
  • comments improved
  • add name, implement getSimilartiy, correct equals and hashCode in ANDROIDGUIElementSpec
  • add get and set methods to ANDROIDGUIElement
  • Property svn:mime-type set to text/plain
File size: 4.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.android.guimodel;
16
17import de.ugoe.cs.autoquest.eventcore.guimodel.AbstractDefaultGUIElement;
18import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement;
19import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
20
21/**
22 * <p>
23 * Base class for all Android GUI elements.
24 * </p>
25 *
26 * @version 1.0
27 * @author Florian Unger
28 */
29public class ANDROIDGUIElement extends AbstractDefaultGUIElement {
30
31    /**
32     * <p>
33     * Id for object serialization.
34     * </p>
35     */
36    private static final long serialVersionUID = 1L;
37
38    /**
39     * <p>
40     * Specification of the GUI Element
41     * </p>
42     */
43    private ANDROIDGUIElementSpec specification;
44
45    /**
46     * <p>
47     * Constructor. Creates a new JFCGUIElement.
48     * </p>
49     *
50     * @param specification
51     *            specification of created GUI element
52     * @param parent
53     *            parent of the created GUI element; null means that the element is a top-level
54     *            window
55     */
56    public ANDROIDGUIElement(ANDROIDGUIElementSpec specification, ANDROIDGUIElement parent) {
57        super(specification, parent);
58        this.specification = specification;
59    }
60
61    /*
62     * (non-Javadoc)
63     *
64     * @see
65     * de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#updateSpecification(de.ugoe.cs.autoquest
66     * .eventcore .guimodel.IGUIElementSpec)
67     */
68    @Override
69    public void updateSpecification(IGUIElementSpec furtherSpec) {
70        // nothing do do here up to now.
71    }
72
73    /*
74     * (non-Javadoc)
75     *
76     * @see de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement#getDistanceTo(IGUIElement)
77     */
78    @Override
79    public double getDistanceTo(IGUIElement otherElement) {
80        throw new UnsupportedOperationException("not implemented yet");
81    }
82
83    /**
84     * <p>
85     * Returns the type of the GUI element, i.e., the name of its Java class.
86     * </p>
87     *
88     * @return the Java class name
89     */
90    public String getSpecType() {
91        return specification.getType();
92    }
93
94    /*
95     * (non-Javadoc)
96     *
97     * @see de.ugoe.cs.autoquest.eventcore.IEventTarget#getPlatform()
98     */
99    @Override
100    public String getPlatform() {
101        return "Android";
102    }
103   
104    /**
105     * <p>
106     * Returns the type of the GUI element, i.e., the name of its Android class.
107     * </p>
108     *
109     * @return the Android class name
110     */
111    public String getAndroidType() {
112        return specification.getType();
113    }
114   
115    /**
116     * <p>
117     * Returns the name of the GUI element.
118     * </p>
119     *
120     * @return the name
121     */
122    public String getName() {
123        return specification.getName();
124    }
125   
126    /**
127     * <p>
128     * Returns the path of the GUI element.
129     * </p>
130     *
131     * @return the path
132     */
133    public String getPath() {
134        return specification.getPath();
135    }
136   
137    /**
138     * <p>
139     * Returns the GUI element identifier.
140     * </p>
141     *
142     * @return identifier of the GUI element
143     */
144    int getIndex() {
145        return specification.getIndex();
146    }
147   
148    /**
149     * <p>
150     * Returns the object hash of the GUI element.
151     * </p>
152     *
153     * @return the object hash
154     */
155    int getElementHash() {
156        return specification.getElementHash();
157    }
158
159    /*
160     * (non-Javadoc)
161     *
162     * @see java.lang.Object#toString()
163     */
164    @Override
165    public String getStringIdentifier() {
166        String str = this.toString();
167        if (getParent() != null) {
168            return str + "<-" + getParent().getStringIdentifier();
169        }
170        return str;
171    }
172   
173    /*
174     * (non-Javadoc)
175     *
176     * @see java.lang.Object#toString()
177     */
178    @Override
179    public String toString() {
180        String str =
181            getElementDescriptor() + "(" + getName() + "," + getElementHash() + "," + getPath() +
182                "," + getIndex() + ")";
183        return str;
184    }
185
186    /**
187     * <p>
188     * A short string describing the GUI element, e.g., Button, Canvas, or ScrollBar.
189     * </p>
190     *
191     * @return short element descriptor
192     */
193    protected String getElementDescriptor() {
194        return "Default";
195    }
196
197}
Note: See TracBrowser for help on using the repository browser.